var bTimed_Show
var bTimed_Hide

var igWidth = 0
var igHeight = 0
var sDivSrc = ''

function centerObject(oObject)
{
	var iCenterLeft = 0
	var iCenterTop = 0

	var screenX = 0
	var screenY = 0

	var iLeft = 0
	var iTop = 0

	var iWidth = parseInt(oObject.style.width)
	var iHeight = parseInt(oObject.style.height)

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		
		var ieversion=parseFloat(navigator.appVersion)
		screenX = document.body.offsetWidth
		screenY = document.body.offsetHeight
		iLeft = (screenX - iWidth) / 2
		iTop = ((screenY - iHeight) / 2) + document.body.scrollTop
		if(ieversion == 4) {iTop = 100}
		iCenterLeft = iLeft
		iCenterTop = iTop
	}
	else
	{
		screenX = window.innerWidth
		screenY = window.innerHeight
		iLeft = (screenX - iWidth) / 2
		//iTop = (screenY - iHeight) / 2
		iTop = ((screenY - iHeight) / 2) + document.body.scrollTop
		iCenterLeft = iLeft - pageXOffset
		//iCenterTop = iTop - pageYOffset
		iCenterTop = iTop
	}

	oObject.style.left = iCenterLeft
	oObject.style.top = iCenterTop
}

function divAni(ifWidth, ifHeight, sUrl)
{
	var oOuterDiv = document.getElementById('outerDiv');
	var oInnerDiv = document.getElementById('innerDiv');

	igWidth = ifWidth
	igHeight = ifHeight
	sDivSrc = sUrl

	if (oOuterDiv.style.display == 'none') {showDivAni()} else {hideDivAni()}
}

function showDivAni()
{
	clearTimeout(bTimed_Hide);

	overlayOpen()

	var oOuterDiv = document.getElementById('outerDiv');
	var oInnerDiv = document.getElementById('innerDiv');

	var iWidth = parseInt(oOuterDiv.style.width);
	var iHeight = parseInt(oOuterDiv.style.height);
	var iTop = parseInt(oOuterDiv.style.top);
	var iLeft = parseInt(oOuterDiv.style.left);

	if (oInnerDiv.style.display == 'none')
	{
		oInnerDiv.style.display = 'block'
		oInnerDiv.innerHTML = '<BR><BR><BR><BR><IMG STYLE="width: 235px; height: 235px" SRC="/images/loading.gif"><BR><BR><BR><B STYLE="font-family: verdana; color: gray; font-size: 30px">Loading . . . </B>'
	}

	if (iWidth < igWidth || iHeight < igHeight)
	{
		oOuterDiv.style.display = 'block'
		if (iWidth < igWidth) {oOuterDiv.style.width = iWidth + 25}
		if (iHeight < igHeight) {oOuterDiv.style.height = iHeight + 25}
		centerObject(oOuterDiv)
		bTimed_Show = setTimeout('showDivAni()', 10)
	}
	else
	{
		oInnerDiv.innerHTML = "<IFRAME STYLE='width: 100%; height: 100%' FRAMEBORDER=0 SCROLLING=no SRC='" + sDivSrc + "'></IFRAME>"
	}
}

function hideDivAni()
{
	clearTimeout(bTimed_Show);

	var oOuterDiv = document.getElementById('outerDiv');
	var oInnerDiv = document.getElementById('innerDiv');

	var iWidth = parseInt(oOuterDiv.style.width);
	var iHeight = parseInt(oOuterDiv.style.height);
	var iTop = parseInt(oOuterDiv.style.top);
	var iLeft = parseInt(oOuterDiv.style.left);

	if (iWidth > 50)
	{
		oOuterDiv.style.width = iWidth - 25;
		oOuterDiv.style.height = iHeight - 25;
		centerObject(oOuterDiv)
		bTimed_Hide = setTimeout('hideDivAni()', 10);
	}
	else
	{
		oOuterDiv.style.display = 'none';
		oInnerDiv.style.display = 'none'
		oOuterDiv.style.width = 50
		oOuterDiv.style.height = 50
		overlayClose()
	}
}

function overlayOpen()
{
	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;
	}
	document.getElementById("overlay").style.height = yScroll
	document.getElementById("overlay").style.width = xScroll
}

function overlayClose()
{
	document.getElementById("overlay").style.height = 0
	document.getElementById("overlay").style.width = 0
}

