
//==========================================================
//==打开 Lightbox 
//==========================================================
function LightboxOn(iFrame)
{
	//------------------------------------
	//--页面背静遮罩和 Lightbox 显示
	//------------------------------------
	var oLightboxOverlay=document.getElementById("lightboxOverlay");
	var oLightbox=document.getElementById("lightbox");	
	
	//------------------------------------
	//--首先重新定位（定位到当前工作位置）
	//------------------------------------	
	//var OffsetY=0;
	//var OffsetX=0;
	
	//---------------
	//--IE6特殊处理
	//---------------
	//if (/msie|MSIE 6/.test(navigator.userAgent))
	//if (typeof(document.addEventListener)!= 'function')
	//{
	//	OffsetY=document.body.scrollTop;
	//	OffsetX=document.body.scrollLeft;
	//}
	
	//oLightbox.style.top= OffsetY + (ViewPortHeight()-oLightbox.style.height.replace("px",""))/2 + "px" ;
	//oLightbox.style.left= OffsetX + (ViewPortWidth()-oLightbox.style.width.replace("px",""))/2 + "px" ;
	//oLightboxOverlay.style.top=OffsetY + "px";
	//oLightboxOverlay.style.left=OffsetX + "px";

	oLightbox.style.top= (ViewPortHeight()-oLightbox.style.height.replace("px",""))/2 + "px" ;
	oLightbox.style.left= (ViewPortWidth()-oLightbox.style.width.replace("px",""))/2 + "px" ;

	oLightboxOverlay.style.top= "0px";
	oLightboxOverlay.style.left= "0px";
	//oLightboxOverlay.style.height="100%";
	//oLightboxOverlay.style.width="100%";
	
	//------------------------------------
	//--首先设置 lightbox 100% 透明
	//------------------------------------
	setTimeout("LightboxSetOpacity(0)",50);	

	//------------------------------------
	//--根据 iFrame 参数决定是 lightboxMessage 还是 lightboxiFrame 打开
	//------------------------------------
	if (iFrame==true)
	{
		document.getElementById("lightboxMessage").style.display="none";
		document.getElementById("lightboxiFrame").style.display="block";
	}
	else
	{
		document.getElementById("lightboxMessage").style.display="block";
		document.getElementById("lightboxiFrame").style.display="none";
	}

	//------------------------------------
	//--渐入
	//------------------------------------
	for (var i=1; i<=10; i++)
	{
		setTimeout("LightboxSetOpacity(" + i + ")",(50 + 50 * i));
	}	
}

//==========================================================
//==关闭 Lightbox
//==========================================================
function LightboxOff()
{
	//------------------------------------
	//--渐出
	//------------------------------------
	for (var i=1; i<=10; i++)
	{
		setTimeout("LightboxSetOpacity(" + (10-i) + ")",50 * i);
	}		
}

//==========================================================
//==设置 Lightbox 透明度（以便渐入渐出）
//==========================================================
function LightboxSetOpacity(OpacityValue)
{
	//------------------------------------
	//--页面背静遮罩和 Lightbox 显示
	//------------------------------------
	var oLightboxOverlay=document.getElementById("lightboxOverlay");
	var oLightbox=document.getElementById("lightbox");	

	//-------------------------------
	//--为给定对象设置 opacity css  属性
	//-------------------------------
	if (oLightbox!=null)
	{
		oLightbox.style.opacity = OpacityValue/10;
		oLightbox.style.filter = "alpha(opacity=" + OpacityValue * 10 + ")";
	}
	
	//-------------------------------
	//--如果 OpacityValue>0 则设置 lightbox 显示为 block，否则设置为 none
	//-------------------------------
	if (OpacityValue>0)
	{
		if (oLightboxOverlay!=null && oLightboxOverlay.style.display!="block"){oLightboxOverlay.style.display="block";}
		if (oLightbox!=null && oLightbox.style.display!="block"){oLightbox.style.display="block";}
	}
	else
	{
		if (oLightboxOverlay!=null && oLightboxOverlay.style.display!="none"){oLightboxOverlay.style.display="none";}
		if (oLightbox!=null && oLightbox.style.display!="none"){oLightbox.style.display="none";}
	}
}

//==========================================================
//==获取当前浏览器窗口工作区的宽度（以便水平居中 lightbox）
//==========================================================
function ViewPortWidth()
{
	//------------------------------------
	//--结果变量
	//------------------------------------
	var ReturnValue;

	//------------------------------------
	//--the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	//------------------------------------
	if (typeof window.innerWidth != 'undefined')
	{
		ReturnValue = window.innerWidth;
	}
 
	//------------------------------------
	//--IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	//------------------------------------
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	{
		ReturnValue = document.documentElement.clientWidth;
	}
 
	//------------------------------------
	//--older versions of IE
	//------------------------------------
	else
	{
		ReturnValue = document.getElementsByTagName('body')[0].clientWidth;
	}
	
	//------------------------------------
	//--输出结果
	//------------------------------------
	return ReturnValue;
}

//==========================================================
//==获取当前浏览器窗口工作区的高度（以便垂直居中 lightbox）
//==========================================================
function ViewPortHeight()
{
	//------------------------------------
	//--结果变量
	//------------------------------------
	var ReturnValue;

	//------------------------------------
	//--the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	//------------------------------------
	if (typeof window.innerHeight != 'undefined')
	{
		ReturnValue = window.innerHeight;
	}
 
	//------------------------------------
	//--IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	//------------------------------------
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight != 'undefined' && document.documentElement.clientHeight != 0)
	{
		ReturnValue = document.documentElement.clientHeight;
	}
 
	//------------------------------------
	//--older versions of IE
	//------------------------------------
	else
	{
		ReturnValue = document.getElementsByTagName('body')[0].clientHeight;
	}
	
	//------------------------------------
	//--输出结果
	//------------------------------------
	return ReturnValue;
}
