/*
嵌入JS脚本
<script LANGUAGE="JavaScript" src="LockScreen1.js"></script>

需要一个半透明的义图
overlay_dark.png  因为fireFox不能用filter样式


创建DIV并设置style
如:
<div id="Message" style="width:300px;height:200px;display:none;">
   <table width="300" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC" ID="Table1">
     <tr>
       <td height="28" align="right" bgcolor="#F2F2F2"><span style="cursor:pointer;" onclick="javascript:ClsLockScreen.UnLockScreen();">关闭</span>   </td>
     </tr>
     <tr>
       <td height="150" align="center" bgcolor="#F2F2F2">已经锁屏Message ..... </td>
     </tr>
   </table>
</div>

调用方法 
ClsLockScreen.DivMsgID='Message'; //确定显示哪个Div
ClsLockScreen.LockScreen();       //锁屏
ClsLockScreen.UnLockScreen();     //解屏
<span style="cursor:pointer;" onclick="javascript:ClsLockScreen.DivMsgID='Message';ClsLockScreen.LockScreen();">锁屏Message</span>
*/

var ClsLockScreen=
{
	//内容Div的ID号
	"DivMsgID":'Message',
	"UrlPath":'../../',
	// 获取宽度
	"getWidth":function()
	{
		var strWidth,clientWidth,bodyWidth;
		clientWidth = document.documentElement.clientWidth;
		bodyWidth = document.body.clientWidth;
		if(bodyWidth > clientWidth){
			strWidth = bodyWidth ;
		} else {
			strWidth = clientWidth;
		}
		return strWidth;
	},
	//获取高度
	"getHeight":function()
	{
		var strHeight,clientHeight,bodyHeight;
		clientHeight = document.documentElement.clientHeight;
		bodyHeight = document.body.clientHeight;
		if(bodyHeight > clientHeight){
			strHeight = bodyHeight +20;
		} else {
			strHeight = clientHeight;
		}
		return strHeight;
	},
	// 锁屏
	"LockScreen":function()
	{
		if(AJS.isIe())
		{
			AJS.map(AJS.$bytc("select"), function(elm) {elm.style.visibility = "hidden"});
		}
		
		AJS.map(AJS.$bytc("object"), function(elm) {elm.style.visibility = "hidden"});
		AJS.map(AJS.$bytc("INPUT"), function(elm) {elm.disabled = true;});
		AJS.map(AJS.$bytc("A"), function(elm) {elm.disabled = true;});
		//AJS.map(AJS.$bytc("text"), function(elm) {elm.style.disabled = false;});
		var Elements=null;
		if(AJS.isIe())
		{
			Elements = document.createElement("<div id='divScreen' style='filter:alpha(opacity=20);width:0px;background:#000000;'>");
			document.body.appendChild(Elements);
		}
		else
		{
			Elements = document.createElement("div");
			document.body.appendChild(Elements);
		}
		//var Elements=document.getElementById("divScreen");
		Elements.id = 'divScreen';

		if(AJS.isIe())
		{
			with(Elements.style){  
					//backgroundColor = "#000000";
					//backgroundColor = "transparent";
					position='absolute';
					zIndex='9998';
					top= '0px';
					left= '0px';
					width=ClsLockScreen.getWidth()+'px';
					height=ClsLockScreen.getHeight()+'px';
					display='block';
					//backgroundImage='url('+ClsLockScreen.UrlPath+'JS/LockScreen/blank.gif)';	
				}
				//Elements.style="";
			//Elements.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+ClsLockScreen.UrlPath+"JS/LockScreen/overlay_dark.png,sizingMethod='scale')";
			
		}
		else 
		{
			with(Elements.style){  
				position='absolute';
				zIndex='9998';
				top= '0px';
				left= '0px';
				width=ClsLockScreen.getWidth()+'px';
				height=ClsLockScreen.getHeight()+'px';
				display='block';
				backgroundImage='url('+ClsLockScreen.UrlPath+'JS/LockScreen/overlay_dark.png)';			
			}
		}
		var Element = document.getElementById(ClsLockScreen.DivMsgID);
		//alert(Element.all.length);
		AJS.ShowDivElement(Element);
		
		with(Element.style){  
			position='absolute';
			zIndex='9999';
			display='block';
		}
		
		var w=Element.style.width;
		
		if(w!='')
		{
			w=parseInt(w.indexOf('px')>0?w.substring(0,w.length-2):w);
			Element.style.left=parseInt( (document.body.offsetWidth-w)/2 )+'px';
			//Element.style.top=Element.style.height;
			var h=Element.style.height;
			h=parseInt(h.indexOf('px')>0?h.substring(0,h.length-2):h);
			var pTop= h + document.documentElement.scrollTop +'px';
			Element.style.top=pTop;
	
			ClsLockScreen.onscroll();			
			
		}
		else
		{
			alert("必须设置div Message的样式如:style='position: absolute;z-index: 9999;width:300px;height:200px;visibility:hidden;'");
		}
	},
	
	// 锁屏 必须在onload事件中
	"LockScreen1":function()
	{		
		if(AJS.isIe())
		{
			AJS.map(AJS.$bytc("select"), function(elm) {elm.style.visibility = "hidden"});
		}
		AJS.map(AJS.$bytc("object"), function(elm) {elm.style.visibility = "hidden"});
		AJS.map(AJS.$bytc("INPUT"), function(elm) {elm.disabled = true;});
		AJS.map(AJS.$bytc("A"), function(elm) {elm.disabled = true;});
		//AJS.map(AJS.$bytc("text"), function(elm) {elm.style.disabled = false;});
		
		var Elements=null;
		if(AJS.isIe())
		{
			Elements = document.createElement("<div id='divScreen' style='filter:alpha(opacity=20);width:0px;background:#000000;'>");
			document.body.appendChild(Elements);
		}
		else
		{
			Elements = document.createElement("div");
			Elements.id = 'divScreen';
			document.body.appendChild(Elements);
		}
		
		if(AJS.isIe())
		{
			with(Elements.style){  
					//backgroundColor = "#000000";
					//backgroundColor = "transparent";
					position='absolute';
					zIndex='9998';
					top= '0px';
					left= '0px';
					width=ClsLockScreen.getWidth()+'px';
					height=ClsLockScreen.getHeight()+'px';
					display='block';
					//backgroundImage='url('+ClsLockScreen.UrlPath+'JS/LockScreen/blank.gif)';	
				}
				//Elements.style="";
			//Elements.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+ClsLockScreen.UrlPath+"JS/LockScreen/overlay_dark.png,sizingMethod='scale')";
			
		}
		else 
		{
			with(Elements.style){  
				position='absolute';
				zIndex='9998';
				top= '0px';
				left= '0px';
				width=ClsLockScreen.getWidth()+'px';
				height=ClsLockScreen.getHeight()+'px';
				display='block';
				backgroundImage='url('+ClsLockScreen.UrlPath+'JS/LockScreen/overlay_dark.png)';			
			}
		}

		var Element = document.getElementById(ClsLockScreen.DivMsgID);
		
		with(Element.style){  
			position='absolute';
			zIndex='9999';			
			display='block';
			width=ClsLockScreen.getWidth()+'px';
			height=ClsLockScreen.getHeight()+'px';
		}
		Element.style.left='0px';
		Element.style.top='0px';
/*
		var w=Element.style.width;
		if(w!='')
		{
			w=parseInt(w.indexOf('px')>0?w.substring(0,w.length-2):w);
			Element.style.left=parseInt( (document.body.offsetWidth-w)/2 )+'px';
			//Element.style.top=Element.style.height;
			var h=Element.style.height;
			h=parseInt(h.indexOf('px')>0?h.substring(0,h.length-2):h);
			var pTop= h + document.documentElement.scrollTop +'px';
			Element.style.top=pTop;

			//ClsLockScreen.onscroll();
		}
		else
		{
			alert("必须设置div Message的样式如:style='position: absolute;z-index: 9999;width:300px;height:200px;visibility:hidden;'");
		}*/
	},
	//解屏
	"UnLockScreen":function()
	{
		if(AJS.isIe()) 
			AJS.map(AJS.$bytc("select"), function(elm) {elm.style.visibility = "visible"});

		AJS.map(AJS.$bytc("object"), function(elm) {elm.style.visibility = "visible"});
		AJS.map(AJS.$bytc("INPUT"), function(elm) {elm.disabled = false;});
		AJS.map(AJS.$bytc("A"), function(elm) {elm.disabled = false;});
  
		var Element =  document.getElementById(ClsLockScreen.DivMsgID);
		var Elements = document.getElementById('divScreen');
		Element.style.display='none';
		Elements.style.display='none';
		document.body.removeChild(Elements);
	}
}


