// to getting the  page scroll
function getPageScroll(){
	var yScroll= 0;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body.scrollTop) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	//alert(yScroll);
	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}



//
// to getting the  page size= height width
//
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}


// call this function on a tag with parameter

function showDivLayer(popLayer, popCon, TPos, LPos){
    try {
		var browserName = navigator.appName
		var arrayPageSize = getPageSize();
	    var arrayPageScroll = getPageScroll();
		var DvLayerId = document.getElementById(popLayer); 	       // Var for Main full Opaque Layer
		var DvMessageId = document.getElementById(popCon);           // Var for Main content div popup Layer
		var ScrollHeight = document.body.scrollHeight; 					 // Value for scroll height of the page
		var ScrollWidth = document.body.scrollWidth; 					 // Value for scroll width of the page
		var ClientHeight = document.documentElement.clientHeight; 	 // Value for browser height of the page
		var ClietnWidth = document.documentElement.clientWidth; 		 // Value for Browser width of the page
		var OffsetHeight = document.documentElement.offsetHeight; 	 // Value for scroll height for Safari of the page
		var OffsetWidth = document.documentElement.offsetWidth; 		 // Value for height height for Safari of the page


		DvLayerId.style.display="";

 if(ScrollHeight<ClientHeight){
	 //if(BrowserDetect.browser=="Explorer" || BrowserDetect.browser=="Firefox" || BrowserDetect.browser=="Netscape")
	 if(browserName=="Microsoft Internet Explorer" || browserName=="Firefox" || browserName=="Netscape")
		DvLayerId.style.height=ClientHeight+30+"px";
		else
		DvLayerId.style.height=ScrollHeight+30+"px";
	}
	else
 	DvLayerId.style.height=ScrollHeight+30+"px";


//alert(document.body.scrollWidth);
var TotalW = document.body.scrollWidth;
var PosLeft = TotalW/2;
var Lalign = PosLeft - 235;

//alert(aaa);
DvLayerId.style.width=ClietnWidth+"px";
DvLayerId.style.top=0+"px";
DvLayerId.style.left=0+"px";
DvMessageId.style.left=Lalign + 'px';
DvMessageId.style.display="";
DvMessageId.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 100) / 2) + 'px');

//When scrolling sarts this function will call on onscroll...
window.onscroll = function Scrolling(){
					var arrayPageSize = getPageSize();
					var arrayPageScroll = getPageScroll();
							DvMessageId.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 100) / 2) + 'px');
				}
    } catch(e) { alert(e)}
}


// this is to hide both the div's
function hideDivLayer(popLayer, popCon){
    document.getElementById(popLayer).style.display='none';
    document.getElementById(popCon).style.display='none';
}
