/*Window scroll event start*/
window.onscroll = scroll;
/* specify height and width for Message popup*/
var DvMsgBxW = 500;
var DvMsgBxH= 200;

/*This function is used for scrolling of popup*/
function scroll()
{
	
	
	var DvMsgDescBx;
	DvMsgDescBx=document.getElementById('DvMsgDescBx');
	if(DvMsgDescBx){
		if (DvMsgDescBx.style.display == 'block')
		{
		if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) 
		{	
			yScroll = window.innerHeight + window.scrollMaxY;
			xScroll = window.innerWidth + window.scrollMaxX;
			var deff = document.documentElement;
			var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
			var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
			xScroll -= (window.innerWidth - wff);
			yScroll -= (window.innerHeight - hff);
			}
		else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth)
			{ // all but Explorer Mac
			yScroll = document.body.scrollHeight;
			xScroll = document.body.scrollWidth;
			}
	 else 
		 { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			yScroll = document.body.offsetHeight;
			xScroll = document.body.offsetWidth;
	  }
		var arrayPageScroll=TB_getPageScrollTop();
		var pagesize = TB_getPageSize();	
		var arrayPageScroll = TB_getPageScrollTop();
		DvMsgDescBx.style.marginLeft = -(DvMsgBxW/2)+'px';
		DvMsgDescBx.style.top=(arrayPageScroll[1] + (pagesize[1]-DvMsgBxH)/2) + 'px';
		//DvMsgBx.style.height=DvMsgBxH + 'px';
		DvMsgDescBx.style.width=DvMsgBxW + 'px';
	}
}
 // note: you can use window.innerWidth and window.innerHeight to access the width and height of the viewing area
}

/* This function is used for greyed background and to show popup*/
function ShowmyDv()
{
var DvMain,Ifrme,DvMsgDescBx;
DvMain=document.getElementById('MainDv'); //Greyed background
Ifrme=document.getElementById('Ifrm');  //Iframe
DvMsgDescBx=document.getElementById('DvMsgDescBx'); //Popup
Ifrme.style.display='block';
DvMain.style.display='block';
DvMsgDescBx.style.display='block';

/*For Height and width of greyed background*/
	if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) 
	{	
		yScroll = window.innerHeight + window.scrollMaxY;
		xScroll = window.innerWidth + window.scrollMaxX;
		var deff = document.documentElement;
		var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
		var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
		xScroll -= (window.innerWidth - wff);
		yScroll -= (window.innerHeight - hff);
	}
	else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth)
	{ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
		xScroll = document.body.scrollWidth;
	} 
	else 
 { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
		xScroll = document.body.offsetWidth;
  }

//Styles for greyed background
DvMain.style.height=yScroll + 'px';
DvMain.style.width=xScroll + 'px';
Ifrme.style.height=yScroll + 'px';
Ifrme.style.width=xScroll + 'px';

var arrayPageScroll=TB_getPageScrollTop();
var pagesize = TB_getPageSize();	
var arrayPageScroll = TB_getPageScrollTop();
 
//Styles for popup
DvMsgDescBx.style.marginLeft = -(DvMsgBxW/2)+'px';
DvMsgDescBx.style.top=(arrayPageScroll[1] + (pagesize[1]-DvMsgBxH)/2) + 'px';
//DvMsgBx.style.height=DvMsgBxH + 'px';
DvMsgDescBx.style.width=DvMsgBxW + 'px';

}

/* This function is used for greyed background and to show popup*/
function ShowDynamicDv(divId, mainDivId, iframId)
{
var DvMain,Ifrme,DvMsgDescBx;
DvMain=document.getElementById(mainDivId); //Greyed background
Ifrme=document.getElementById(iframId);  //Iframe
DvMsgDescBx=document.getElementById(divId); //Popup
Ifrme.style.display='block';
DvMain.style.display='block';
DvMsgDescBx.style.display='block';

/*For Height and width of greyed background*/
	if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) 
	{	
		yScroll = window.innerHeight + window.scrollMaxY;
		xScroll = window.innerWidth + window.scrollMaxX;
		var deff = document.documentElement;
		var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
		var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
		xScroll -= (window.innerWidth - wff);
		yScroll -= (window.innerHeight - hff);
	}
	else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth)
	{ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
		xScroll = document.body.scrollWidth;
	} 
	else 
 { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
		xScroll = document.body.offsetWidth;
  }

//Styles for greyed background
DvMain.style.height=yScroll + 'px';
DvMain.style.width=xScroll + 'px';
Ifrme.style.height=yScroll + 'px';
Ifrme.style.width=xScroll + 'px';

var arrayPageScroll=TB_getPageScrollTop();
var pagesize = TB_getPageSize();	
var arrayPageScroll = TB_getPageScrollTop();
 
//Styles for popup
DvMsgDescBx.style.marginLeft = -(DvMsgBxW/2)+'px';
DvMsgDescBx.style.top=(arrayPageScroll[1] + (pagesize[1]-DvMsgBxH)/2) + 'px';
//DvMsgBx.style.height=DvMsgBxH + 'px';
DvMsgDescBx.style.width=DvMsgBxW + 'px';
}

function TB_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight
	arrayPageSize = new Array(w,h) 
	return arrayPageSize;
}

function TB_getPageScrollTop()
{
	var yScrolltop;
	var xScrollleft;
	if (self.pageYOffset || self.pageXOffset) 
	{
		yScrolltop = self.pageYOffset;
		xScrollleft = self.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft )
	{	 // Explorer 6 Strict
		yScrolltop = document.documentElement.scrollTop;
		xScrollleft = document.documentElement.scrollLeft;
	}
	else if (document.body)
	{// all other Explorers
		yScrolltop = document.body.scrollTop;
		xScrollleft = document.body.scrollLeft;
	}
	arrayPageScroll = new Array(xScrollleft,yScrolltop) 
	return arrayPageScroll;
}

//Close function for message div close
function DvCloseDesc(Dvname)
{
	var dvname=document.getElementById(Dvname);
	var IfrmComm = document.getElementById('Ifrm');
	//new Effect.Fade(dvname, {duration:3.0});
	//new Effect.Fade(IfrmComm, {duration:3.0});
	document.getElementById('Ifrm').style.display='none'
	document.getElementById(Dvname).style.display='none'
	document.getElementById('MainDv').style.display='none'
}

//Close function for message div close
function DvDynamicClose(Dvname, iFrame, mainDiv)
{
var dvname=document.getElementById(Dvname);
dvname.style.display='none'
document.getElementById(mainDiv).style.display='none'
document.getElementById(iFrame).style.display='none'

}