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;
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getScrollTop()
{
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	/*if (document.documentElement && document.documentElement.scrollTop)
		var tmpY	=	document.documentElement.scrollTop;
	else if (document.body)
		var tmpY	=	document.body.scrollTop;*/
	return yScroll;
}

var		tmpLoadingScrID				=	'loadingScreen';
var		tmpLogoutConfirmBoxID		=	'confirmLogoutBox';
var		tmpLoadingImageID			=	'ctl0_loadingImage';
function showLoadingScreen(loadingScrID)
{
	if (!loadingScrID)
	{
		var		loadingScrID	=	tmpLoadingScrID;
	}
	
	var objLoadingImage = document.getElementById(tmpLoadingImageID);

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// center loadingImage if it exists
	if (objLoadingImage) {
		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
		objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
		objLoadingImage.style.display = 'block';
	}

	$(loadingScrID).style.height = (arrayPageSize[1] + 'px');
	$(loadingScrID).style.visibility = "visible";
}

function hideLoadingScreen(loadingScrID)
{
	if (!loadingScrID)
	{
		var		loadingScrID	=	tmpLoadingScrID;
	}
	$(loadingScrID).style.visibility = "hidden";
}

function showScreen(loadingScrID)
{
	if (!loadingScrID)
	{
		var		loadingScrID	=	tmpLoadingScrID;
	}
	var arrayPageSize = getPageSize();
	$(loadingScrID).style.height = (arrayPageSize[1] + 'px');
	$(loadingScrID).style.top = 0;
	$(loadingScrID).style.visibility = "visible";
}

function showBoxScreen(loadingScrID, boxID)
{
	if (!loadingScrID)
	{
		var		loadingScrID	=	tmpLoadingScrID;
	}

	if (!boxID)
	{
		var		boxID	=	tmpLogoutConfirmBoxID;
	}
	
	var objInsideBox = document.getElementById(boxID);
	
	var	tmpWidth	=	objInsideBox.style.width;
	tmpWidth	=	tmpWidth.trim();
	tmpWidth	=	tmpWidth.replace("px","");
	
	var	tmpHeight	=	objInsideBox.style.height;
	tmpHeight	=	tmpHeight.trim();
	tmpHeight	=	tmpHeight.replace("px","");
		
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// center loadingImage if it exists
	if (objInsideBox) {
		objInsideBox.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - tmpHeight) / 2) + 'px');
		objInsideBox.style.left = (((arrayPageSize[0] - 20 - tmpWidth) / 2) + 'px');
		objInsideBox.style.display = 'block';
	}

	$(loadingScrID).style.height = (arrayPageSize[1] + 'px');
	$(loadingScrID).style.visibility = "visible";
}

function hideScreen(loadingScrID)
{
	if (!loadingScrID)
	{
		var		loadingScrID	=	tmpLoadingScrID;
	}
	$(loadingScrID).style.visibility = "hidden";
}

function openImage(vLink, vHeight, vWidth)
{
	if (vLink == '')
	{
		return false;
	}

	var hasScrollBar = "no";
	if (vHeight > 640) {
		vHeight = 640;
		hasScrollBar = "yes";
	}	
	if (vWidth > 900) {
		vWidth = 900;
		hasScrollBar = "yes";
	}

	winDef = 'status=no,resizable=no,scrollbars='+hasScrollBar+',toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	newwin = window.open('', '_blank', winDef);

	newwin.document.writeln('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img src="', vLink, '" alt="', 'close', '" border=0></a>');
	newwin.document.writeln('</body>');
}

function openWindow(vLink, vHeight, vWidth)
{
	if (vLink == '')
	{
		return false;
	}

	var hasScrollBar = "no";
	if (vHeight > 800) {
		vHeight = 800;
		hasScrollBar = "yes";
	}	
	if (vWidth > 800) {
		vWidth = 800;
		hasScrollBar = "yes";
	}
	
	winDef = 'status=no,resizable=no,scrollbars='+hasScrollBar+',toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	newwin = window.open(vLink, '_blank', winDef);
}