/*Window scroll event start*/
window.onscroll = scroll;
/* specify height and width for Message popup*/
var DvMsgBxW = 900;
var DvMsgBxH= 500;

/*This function is used for scrolling of popup*/
function scroll()
{
	var DvMsgBx;
	DvMsgBx=document.getElementById('DvMsgBx');
	if (DvMsgBx.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();
	DvMsgBx.style.marginLeft = -(DvMsgBxW/2)+'px';
	DvMsgBx.style.top=(arrayPageScroll[1] + (pagesize[1]-DvMsgBxH)/2) + 'px';
	//DvMsgBx.style.height=DvMsgBxH + 'px';
	DvMsgBx.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 ShowDv()
{
var DvMain,Ifrme,DvMsgBx;

DvMain=document.getElementById('MainDv'); //Greyed background
Ifrme=document.getElementById('Ifrm');  //Iframe
DvMsgBx=document.getElementById('DvMsgBx'); //Popup
 
Ifrme.style.display='block';
DvMain.style.display='block';
DvMsgBx.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
DvMsgBx.style.marginLeft = -(DvMsgBxW/2)+'px';
DvMsgBx.style.top=(arrayPageScroll[1] + (pagesize[1]-DvMsgBxH)/2) + 'px';
//DvMsgBx.style.height=DvMsgBxH + 'px';
DvMsgBx.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 DvClose(Dvname)
{
var dvname=document.getElementById(Dvname);
dvname.style.display='none'
document.getElementById('MainDv').style.display='none'
document.getElementById('Ifrm').style.display='none'

}