﻿function showoverlay( iWidth, iHeight, sSrc, sParams)
{
	var oShim = cm_f_getRefToDiv('cvOvrlyShim');
	var oOL = cm_f_getRefToDiv('cvOvrlyWrapper');
	var oOC = cm_f_getRefToDiv('cvOvrlyContainer');

	if( oShim && oOL && oOC )
	{

		var oTab = cm_f_getRefToDiv('cvOvrlyTable',oOC);
		var oFrame = cm_f_getRefToDiv('cvOvrlyIFrame', oOC);
		
		if( oTab && oFrame )
		{
		
			var W = getDocWidth();
			var H = getDocHeight();
			var SY = getDocScrollY();
			var availW;
			var availH;

			iWidth = Math.max( iWidth, 400);
			iHeight = Math.max( iHeight, 300);

			if(document.all)
			{
				availW = document.body.clientWidth;
				availH = document.body.clientHeight;
			}
			else
			{
				availW = innerWidth;
				availH = innerHeight;
			}

			with(oOL.style)
			{
				display = 'block';
				width = W;
				height = H;
				top = 0;
				left = 0;
				backgroundColor = 'Transparent';
			}	

			with(oShim.style)
			{
				display = 'block';
				width = W;
				height = H;
				top = 0;
				left = 0;
				backgroundColor = '#000000';
				filter= 'alpha(opacity=75)';	/* IE */
				MozOpacity = 0.75;						/* Netscape */
				opacity = 0.75;								/* Firefox, Safari & Opera */
				khtmlopacity = 0.75;					/* Konqueror & Safari v1.n */
				
			}	

			oFrame.width = iWidth;
			oFrame.height = iHeight;
			
			if(sSrc)
			{
			  var sCacheBusta = new Date();

				sSrc += '?cb=' +  sCacheBusta.valueOf();
				
				if(sParams)
					sSrc += '&' +  sParams;
	
				//alert(sSrc);			
				oFrame.src = sSrc;
			}

			var my = Math.min(Math.max((availH - (iHeight+81))/2,0),150);
			var mx = Math.max((availW - (iWidth+130))/2,0);

			with(oOC.style)
			{
				top = my+SY;
				left = mx;
				width = iWidth+130;
				height = iHeight+81;
			}	
			with(oTab.style)
			{
				width = iWidth+130;
				height = iHeight+81;
			}
		}
		
	}
}

function hideoverlay()
{
	var oOL = cm_f_getRefToDiv('cvOvrlyWrapper');
	var oShim = cm_f_getRefToDiv('cvOvrlyShim');

	if( oShim && oOL )
	{
		oOL.style.display = 'none';
		oShim.style.display = 'none';
	}
}

function getDocHeight()
{
    var D = document;
    return Math.max
    (
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}
function getDocWidth()
{
    var D = document;
    return Math.max
    (
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}
function getDocScrollY()
{
    var D = document;
    return Math.max(D.body.scrollTop, D.documentElement.scrollTop);
}

