/*********************************************************************************************
** 公司名称:福州弘扬信息软件开发有限公司
** 产品名称:医院信息系统(高端企业版)
** 文件名称:pubfunpro.js
** 功能摘要:系统常用的一些公共方法。
**          1、
**          2、
**          3、
**          4、
**          5、
**          6、
**          7、
**          8、
**          9、
**          10、
**          11、
**          12、
**          13、
**          14、
**          15、
** 版 本 号:V1.00
** 创 建 人:黄水泉
** 创建日期:2005.04.05
** 修 改 人:
** 修改日期:
*********************************************************************************************/


///////////////////////////////
//<!--//屏蔽ctrl+n及鼠标右键功能
///////////////////////////////
  //document.write(unescape("%3Cscript%20language%3D%22JavaScript%22%3E%20%0D%0A//%u52A0%u5165%u9875%u9762%u4FDD%u62A4%0D%0A%20%20%20%20function%20rf%28%29%0D%0A%20%20%20%20%20%20%7Breturn%20false%3B%20%7D%0D%0A%20%20%20%20document.oncontextmenu%20%3D%20rf%0D%0A%20%20%20%20function%20keydown%28%29%0D%0A%20%20%20%20%20%20%7Bif%28event.ctrlKey%20%3D%3Dtrue%20%7C%7C%20event.keyCode%20%3D%3D93%20%7C%7C%20event.shiftKey%20%3D%3Dtrue%29%7Breturn%20false%3B%7D%20%7D%0D%0A%20%20%20%20%20%20document.onkeydown%20%3Dkeydown%0D%0A%20%20%20%20function%20drag%28%29%0D%0A%20%20%20%20%20%20%7Breturn%20false%3B%7D%0D%0A%20%20%20%20document.ondragstart%3Ddrag%20%0D%0Afunction%20stopmouse%28e%29%20%7B%20%0D%0A%09%09if%20%28navigator.appName%20%3D%3D%20%27Netscape%27%20%26%26%20%28e.which%20%3D%3D%203%20%7C%7C%20e.which%20%3D%3D%202%29%29%20%20%0D%0A%20%09%09return%20false%3B%20%0D%0A%20%20%20%20%20%20else%20if%20%20%0D%0A%20%20%20%20%20%20%28navigator.appName%20%3D%3D%20%27Microsoft%20Internet%20Explorer%27%20%26%26%20%28event.button%20%3D%3D%202%20%7C%7C%20event.button%20%3D%3D%203%29%29%20%7B%20%20%0D%0A%20%09%09//alert%28%22%u5F18%u626C%u8F6F%u4EF6%u63D0%u9192%u60A8%uFF1A%u8BF7%u5C0A%u91CD%u6211%u4EEC%u7684%u7248%u6743%21%22%29%3B%0D%0A%09%09return%20false%3B%20%20%0D%0A%20%09%09%7D%0D%0A%09%09return%20true%3B%20%0D%0A%20%20%20%20%20%20%7D%20%0D%0A%20%20%20%20%20%20document.onmousedown%3Dstopmouse%3B%20%20%0D%0A%20%20%20%20%20%20if%20%28document.layers%29%20%0D%0A%20%20%20%20%20%20window.captureEvents%28Event.MOUSEDOWN%29%3B%20%0D%0A%20%20%20%20%20%20%20window.onmousedown%3Dstopmouse%3B%20%20%0D%0A%0D%0A%3C/script%3E"));
//-->
//禁止后退。。。
window.history.forward(1);
//-->


///////////////////////////////
//<!-- Begin 打开窗体---
///////////////////////////////
/*
测试用例a.htm
<SCRIPT language=JavaScript src="pubfunpro.js"></SCRIPT>
<a href="a.htm" target="_blank" onclick="javascript:return OpenForm(2, this.href, 300, 50);">
<font size="2" color="#407CD0">测试</font></a>
*/

//窗体最大化
function MaxForm(frm)
{
  //窗体自动最大化     需要拷入到各窗体，调用此不会自动执行
  newwidth=screen.width;
  newheight=screen.height;
  frm.window.moveTo(-4,-4);
  frm.window.resizeTo(newwidth+8,newheight-28+8);
}

//打开新窗体
function OpenForm(bz, url,width, height)
{
	var prileft = (screen.width - width)/2;
	var pritop = (screen.height - height - 50)/2;
	if (bz==0)
	{//全屏
		window.open(url,'TsUrl','fullscreen')
	}
	else if (bz==1)
	{//无菜单，地址栏等
		var Win = window.open(url, "弘扬软件", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + width + ', height=' + height + ',left=' + prileft + ',top=' + pritop);
	}
	else if (bz==2)
	{//有菜单
		var Win = window.open(url, "弘扬软件", 'width=' + width + ', height=' + height + ', resizable=yes, scrollbars=yes, menubar=yes, status=yes');
	}
	else if (bz==3)
	{//无菜单，地址栏，有滚动条等
		var Win = window.open(url, "弘扬软件", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=' + width + ', height=' + height + ',left=' + prileft + ',top=' + pritop);
	}
	else if (bz==4)
	{//无菜单，地址栏，有滚动条等
		var para = "help: no;status: no;dialogWidth: " + width + ";dialogHeight: " + height;
		window.showModalDialog(url,"",para);
	}
	else if (bz==5)
	{//无菜单，无地址栏，有滚动条，状态栏等
		var Win = window.open(url, "弘扬软件", 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ', height=' + height + ',left=' + prileft + ',top=' + pritop);
	}
}

///////////////////////////////
//<!--键盘定位 asp.net构件不能定位，只有html构件可定位
///////////////////////////////
function keytofocus(numbz,itemname1,itemname2,FrmName) //键盘定位，按回车置下一个位置按/回上一个因为38及一些按钮不响应所以用/向上
{
	var focuscontrol1,focuscontrol2,numbz;
	
	//都为空时不作处理可传入true来判断是否为数字
    //        alert(event.keyCode);//测试键值
			
	if (((event.keyCode==13) || (event.keyCode==40)) && (itemname1!==""))
	{
		focuscontrol1=eval("window." + FrmName + "." + itemname1);
		focuscontrol1.focus();
		
		window.event.keyCode=0; 
		event.returnValue=false;
	}
	else 
	{
		if ((event.keyCode==38) && (itemname2!=="")) 
		{
			focuscontrol2=eval("window." + FrmName + "." + itemname2);
			focuscontrol2.focus();
		}
	}
	
	if (numbz=="true")
	{
		chars= "0123456789."; 
		if (chars.indexOf(String.fromCharCode(event.keyCode))==-1) 
		{
  			window.event.keyCode=0;
		}
	}
}

////////////////////////////////////////////
///	键盘定位
///	itemname1 -- 下一个控件的名称
///	itemname2 -- 上一个控件的名称
///	FrmName -- Form名称
///////////////////////////////////////////
function KJkeydown(itemname1,itemname2,FrmName)
{
	var focuscontrol1,focuscontrol2;
	
	//都为空时不作处理可传入true来判断是否为数字
    //        alert(event.keyCode);//测试键值
			
//	if (((event.keyCode==13)) && (itemname1!==""))
//	{
//		focuscontrol1=eval("document.all." + itemname1);
//		focuscontrol1.focus();
//		
//		window.event.keyCode=0; 
//		event.returnValue=false;
//	}
    if (((event.keyCode==13) || (event.keyCode==40)) && (itemname1!==""))
	{
		focuscontrol1=eval("document." + FrmName + "." + itemname1);
		focuscontrol1.focus();
		
		window.event.keyCode=0; 
		event.returnValue=false;
	}
	else 
	{
		if ((event.keyCode==38) && (itemname2!=="")) 
		{
			focuscontrol2=eval("document." + FrmName + "." + itemname2);
			focuscontrol2.focus();
		}
	}
}


////////////////////////////////////////////////
///	键盘定位
///	itemname1 -- 为回车到下一构件
///	itemname2 -- 为向上到前面构件
///	itemname3 -- 为回车到下一构件 当下一构件可能为灰度时
///	itemname4 -- 为回车到前面构件 当上一构件可能为灰度时
///	FrmName -- 窗体名称
////////////////////////////////////////////////
function KJkeydown_dis(itemname1,itemname2,itemname3,itemname4,FrmName)
{
	var focuscontrol1,focuscontrol2,focuscontrol3,focuscontrol4;
	
	//都为空时不作处理可传入true来判断是否为数字
	//alert(event.keyCode);//测试键值			
	if ((event.keyCode==13) || (event.keyCode==40)) 
	{
		if ("" != itemname1)
		{
			focuscontrol1=eval("window." + FrmName + "."+itemname1);
			if (false == focuscontrol1.disabled)
			{
				focuscontrol1.focus();
				
				window.event.keyCode=0; 
				event.returnValue=false;
			}
			else if ("" != itemname3)
 			{
				focuscontrol3=eval("window." + FrmName + "."+itemname3);
				focuscontrol3.focus();
				
				window.event.keyCode=0; 
				event.returnValue=false;
			} 
		}
		else if ("" != itemname3)
 		{
			focuscontrol3 = eval("window." + FrmName + "." + itemname3);
			focuscontrol3.focus();
			
			window.event.keyCode=0; 
			event.returnValue=false;
		} 
	}
	else 
	{
		if (event.keyCode==38)
		{
			if ("" != itemname2)
			{
				focuscontrol2 = eval("window." + FrmName + "." + itemname2);
				if (false == focuscontrol2.disabled)
				{
					focuscontrol2.focus();
					
					window.event.keyCode=0; 
					event.returnValue=false;
				}
				else if ("" != itemname4)
				{
					focuscontrol4=eval("window." + FrmName + "." + itemname4);
					focuscontrol4.focus();
					
					window.event.keyCode=0; 
					event.returnValue=false;
				} 
			}
			else if ("" != itemname4)
			{
				focuscontrol4 = eval("window." + FrmName + "." + itemname4);
				focuscontrol4.focus();
				
				window.event.keyCode=0;
				event.returnValue=false;
			}
		}
	}
}


////////////////////////////////////////////////
//numbz为是否判断当前输入框是否为数字及点 "true"表判断 非"true"则不判断
//itemname1为回车到下一构件
//itemname2为向上到前面构件
//itemname3为回车到下一构件 当下一构件可能为灰度时
//itemname4为回车到前面构件 当上一构件可能为灰度时
//FrmName 窗体名称
////////////////////////////////////////////////
function keytofocus_dis(numbz,itemname1,itemname2,itemname3,itemname4,FrmName) //键盘定位，按回车置下一个位置按/回上一个因为38及一些按钮不响应所以用/向上
{
	var focuscontrol1,focuscontrol2,focuscontrol3,focuscontrol4,numbz;
	
	//都为空时不作处理可传入true来判断是否为数字
	//alert(event.keyCode);//测试键值
			
	if ((event.keyCode==13) || (event.keyCode==40)) 
	{
		if ("" != itemname1)
		{
			focuscontrol1=eval("window." + FrmName + "."+itemname1);
			if (false == focuscontrol1.disabled)
			{
				focuscontrol1.focus();
				
				window.event.keyCode=0; 
				event.returnValue=false;
			}
			else if ("" != itemname3)
 			{
				focuscontrol3=eval("window." + FrmName + "."+itemname3);
				focuscontrol3.focus();
				
				window.event.keyCode=0; 
				event.returnValue=false;
			} 
		}
		else if ("" != itemname3)
 		{
			focuscontrol3 = eval("window." + FrmName + "." + itemname3);
			focuscontrol3.focus();
			
			window.event.keyCode=0; 
			event.returnValue=false;
		} 
	}
	else 
	{
		if (event.keyCode==38)
		{
			if ("" != itemname2)
			{
				focuscontrol2 = eval("window." + FrmName + "." + itemname2);
				if (false == focuscontrol2.disabled)
				{
					focuscontrol2.focus();
					
					window.event.keyCode=0; 
					event.returnValue=false;
				}
				else if ("" != itemname4)
				{
					focuscontrol4=eval("window." + FrmName + "." + itemname4);
					focuscontrol4.focus();
					
					window.event.keyCode=0; 
					event.returnValue=false;
				} 
			}
			else if ("" != itemname4)
			{
				focuscontrol4 = eval("window." + FrmName + "." + itemname4);
				focuscontrol4.focus();
				
				window.event.keyCode=0;
				event.returnValue=false;
			}
		}
	}
	
	if (numbz=="true")
	{
		chars= "0123456789."; 
		if (chars.indexOf(String.fromCharCode(event.keyCode))==-1) 
		{
  			window.event.keyCode=0; 
		}
	}
}
			

///////////////////////////////
//<!--Begin 图片渐变效果---
///////////////////////////////
function fade_in(which)
{
    theobject=which
    highlighting=setInterval("highlightit(theobject)",50)
}

function fade_out(which)
{
    clearInterval(highlighting)
    which.filters.alpha.opacity=40
}

function highlightit(cur)
{
    if (cur.filters.alpha.opacity<100)
        cur.filters.alpha.opacity+=20
    else if (window.highlighting)
        clearInterval(highlighting)
}
// -- End 图片渐变效果 -->


///////////////////////////////////////////////////
//	弹出划卡窗体
//	FrmName -- From名称
//	GJName1 -- 如果GJName1为空则弹出划卡窗体
//	GJName2 -- 如果GJName2不为空，不弹出划卡窗体时，就定位到GJName2构件上
//  GJName3 -- 划卡后返回的信息存放的地方
//	HrefStr -- “退出”时重定向到的页面
//	HuaUrl  -- 划卡框的地址
//	DuKaLeiXing --	医保读卡的类型，
//					1 -- 挂号请求
//					2 -- 门诊收费请求
//	XianShiMoShi -- 划卡窗显示类型
//					1 -- 显示全部
//					2 -- 不显示“划卡”
//					3 -- 不显示“输入”
//					4 -- 不显示“读医保卡”
//					5 -- 只显示“划卡”
//					6 -- 只显示“输入”
//					7 -- 只显示“读医保卡”
// isSubmit --  是否提交窗体,默认是   
// returnURL -- 刷卡后窗体转向页面
// isBack　-- 是否启用返回页面
///////////////////////////////////////////////////
function HkPro(FrmName,GJName1,GJName2,GJName3,HrefStr,HuaUrl,DuKaLeiXing,XianShiMoShi,isSubmit,returnURL,isBack)
{
	var priID = eval("window." + FrmName + "." + GJName1).value;
	priID = priID.replace(" ","");
	priID = priID.substr(0,1);
	if (("" == priID) || ("X" == priID))
	{
		var textStr1 = new Array();
		textStr1[0] = "请划卡：";
		////读卡类型///
		if (null != DuKaLeiXing)
		{
			textStr1[1] = DuKaLeiXing;
		}
		///////////////
		
		///划卡窗显示模式////
		if (null != XianShiMoShi)
		{
			textStr1[2] = XianShiMoShi;
		}
		/////////////////////
		var khmess = window.showModalDialog(HuaUrl,textStr1,"help: no;status: no;dialogWidth: 26;dialogHeight: 7"); 
			
				
		if (null != khmess && null != khmess[0] && "undefined" != khmess[0] && "" != khmess[0])
		{
		    if(khmess[0] == "LCZL")
		    {
		        location.href = location.href;
		        return;
		    }
			var txtValue = "";
			if  ("3" == khmess[1])
			{
				khmess[0] = "JieGuo=" + khmess[0];
				khmess[1] = "HuaKaLeiXing=" + khmess[1];
				for (var i = 0; i < khmess.length; i++)
				{
					txtValue += khmess[i] + "^_^";
				}
			}
			else if ("1" == khmess[1] || "2" == khmess[1] || "4" == khmess[1])
			{
				txtValue = "ShuRuZhi=" + khmess[0] + "^_^HuaKaLeiXing=" + khmess[1] + "^_^";
			}
			eval("window." + FrmName + "." + GJName3).value = txtValue;

            if (typeof(returnURL) == "undefined")//划卡后的跳转页面
			{
			    if(null==isSubmit || typeof(isSubmit)=="undefined" )
			    isSubmit = true;
			    
			    if(isSubmit)
			        eval("window." + FrmName).submit();
			}
			else
			{
			    location.href = returnURL+"?HInfos="+txtValue;
			}
		}
		else
		{
		    
			window.close();
			if (typeof(returnURL) != "undefined" && typeof(isBack) != "undefined")
		    {
		        
		    }
		    else
		    {
		        //HrefStr += "?HInfos="+txtValue;
		        if(null!=HrefStr && typeof(HrefStr)!="undefined" && ""!=HrefStr) 
		            location.href=HrefStr;
		    }
		}
	}
	else
	{
		if ("" != GJName2)
		{
			var focusControl = eval("window." + FrmName + "." + GJName2);
			focusControl.focus();
		}
	}
}


///////////////////////////////////
///窗体定位
///FrmName -- 窗体名称
///itemname --要定位的构件的名称
///////////////////////////////////
function LoadFocus(FrmName,itemname) //按回车置下一个位置
{
	var focusControl = eval("window." + FrmName + "." + itemname);
	focusControl.focus();
}

////////////////////////////////////
///根据年龄计算出生年月
///FrmName  -- 窗体名称
///NLitem   -- 年龄构件
///CSNYitem -- 出生年月的构件
////////////////////////////////////
function countdate(FrmName,NLitem,CSNYitem)
{
	var nl = eval("window." + FrmName + "." + NLitem).value;
	if ((null != nl) && ("" != nl))
	{
		today=new Date();    
		var Year=today.getYear();

		Year = Year - nl;
		eval("window." + FrmName + "." + CSNYitem).value = Year.toString() + "-01-01";
	}
}


//*******************************************************************************************//
//************************************以下为键盘输入控制*************************************//
//*******************************************************************************************//
/// <summary>
///键盘长整型数字输入控制
/// </summary>
function longkeypress(nextobj,priorObj,FrmName) 
{
	if (((event.keyCode==13) || (event.keyCode==40)) && (nextobj!==""))
	{
		focuscontrol1=eval("window." + FrmName + "." + nextobj);
		focuscontrol1.focus();
		
		window.event.keyCode=0;
		event.returnValue=false;
	}
	else 
	{
		if (((event.keyCode==38) || (event.keyCode==47)) && (priorObj!=="")) 
		{
			focuscontrol2=eval("window." + FrmName + "." + priorObj);
			focuscontrol2.focus();
		}
	}
	
	if ((event.keyCode<48 || event.keyCode>57))
	{
		if (event.keyCode == 45)
		{
			if (event.srcElement.value.indexOf("-")==0)
				event.srcElement.value = event.srcElement.value.substring(1);
			else
				event.srcElement.value = "-" + event.srcElement.value;
		}
		window.event.keyCode=0;
		event.returnValue=false;
	}
}

//验证只能输入浮点数字
function floatKeyPress()
{
    
   if(event.keyCode>=48 && event.keyCode<=57 || event.keyCode==46 || event.keyCode==13 || event.keyCode==18)
   {
      if(event.keyCode==46)
      {
         if(event.srcElement.value.indexOf(".")!=-1)
         {
            event.keyCode=0;
         }
      }
   }
   else
   {
       event.keyCode=0;
   }
}

//验证只能输入整型数字
function intKeyPress()
{
   if(event.keyCode>=48 && event.keyCode<=57 )
   {

   }
   else
   {
       event.keyCode=0;
   }
}

/// <summary>
///	键盘数字输入控制
/// </summary>
function numberkeypress() 
{
	if ((event.keyCode<48 || event.keyCode>57))
	{
		event.keyCode = 0;
	}
}
/// <summary>
///	数字键盘输入控制
/// </summary>
function NuMkeypress() 
{
	if ((event.keyCode<46 || event.keyCode>57 || event.keyCode==47))
	{
		event.keyCode = 0;
	}
}

/// <summary>
///	键盘数字及字母输入控制
/// </summary>
function NumberAndLetterKeyPress() 
{
	if (!((event.keyCode>=48 && event.keyCode<=57) || (event.keyCode>=65 && event.keyCode<=90) || (event.keyCode>=97 && event.keyCode<=122)))
	{
		event.keyCode = 0;
	}
}


/// <summary>
///	键盘长整型数字输入控制
///	nextobj1为回车到下一构件
///	priorObj1为向上到前面构件
///	nextobj2为回车到下一构件 当下一构件可能为灰度时
///	priorObj2为回车到前面构件 当上一构件可能为灰度时
///	FrmName 窗体名称
/// </summary>
function longkeypress_dis(nextobj1,priorObj1,nextobj2,priorObj2,FrmName) {
	var focuscontrol1,focuscontrol2,focuscontrol3,focuscontrol4,numbz;
	
	if ((event.keyCode==13) || (event.keyCode==40)) 
	{
		if ("" != nextobj1)
		{
			focuscontrol1=eval("window." + FrmName + "." + nextobj1);
			if (false == focuscontrol1.disabled)
			{
				focuscontrol1.focus();
				
				window.event.keyCode=0;
				event.returnValue=false;
			}
			else if ("" != nextobj2)
 			{
				focuscontrol3=eval("window." + FrmName + "." + nextobj2);
				focuscontrol3.focus();
				
				window.event.keyCode=0;
				event.returnValue=false;
			} 
		}
		else if ("" != nextobj2)
 		{
			focuscontrol3 = eval("window." + FrmName + "." + nextobj2);
			focuscontrol3.focus();
			
			window.event.keyCode=0;
			event.returnValue=false;
		} 
	}
	else 
	{
		if ((event.keyCode==38) || (event.keyCode==47)) 
		{
			if ("" != priorObj1)
			{
				focuscontrol2 = eval("window." + FrmName + "." + priorObj1);
				if (false == focuscontrol2.disabled)
				{
					focuscontrol2.focus();
					
					window.event.keyCode=0;
					event.returnValue=false;
				}
				else if ("" != priorObj2)
				{
					focuscontrol4=eval("window." + FrmName + "." + priorObj2);
					focuscontrol4.focus();
					
					window.event.keyCode=0;
					event.returnValue=false;
				} 
			}
			else if ("" != priorObj2)
			{
				focuscontrol4 = eval("window." + FrmName + "." + priorObj2);
				focuscontrol4.focus();
				
				window.event.keyCode=0;
				event.returnValue=false;
			}
		}
	}
	
	if ((event.keyCode<48 || event.keyCode>57))
	{
		if (event.keyCode == 45)
		{
			if (event.srcElement.value.indexOf("-")==0)
				event.srcElement.value = event.srcElement.value.substring(1);
			else
				event.srcElement.value = "-" + event.srcElement.value;
		}
		event.keyCode = 0;
	}
}


/// <summary>
///键盘浮点型数字输入控制
/// </summary>
function doublekeypress() 
{
	if ((event.keyCode<48 || event.keyCode>57))
	{
	    if((event.keyCode>=96 && event.keyCode<=105)) return;
	    if((event.keyCode== 13|| event.keyCode==38|| event.keyCode==40 || event.keyCode==37 || event.keyCode==39 || event.keyCode==8 || event.keyCode==144)) return;
		if (event.keyCode == 45)
		{
			if (event.srcElement.value.indexOf("-")==0)
				event.srcElement.value = event.srcElement.value.substring(1);
			else
				event.srcElement.value = "-" + event.srcElement.value;
		}
		if(( event.keyCode==110 || event.keyCode==190)&&(event.srcElement.value.indexOf(".")<0))
		{
		    if(event.srcElement.value != "")
		    {
		        return;
		    }
		}
		if (event.keyCode != 46 || event.srcElement.value.indexOf(".")>=0)
		{
			event.keyCode = 0;
			event.returnValue=false
		}
	}
}

/// <summary>
///	键盘货币输入控制
///	XiaoShuWeiShu — 保留小数位数
///	FuHaoBZ	— 是否允许输入负号
/// </summary>
function moneykeypress(XiaoShuWeiShu,FuHaoBZ) 
{
	if ((null == XiaoShuWeiShu) || ("" == XiaoShuWeiShu))
	{
		XiaoShuWeiShu = 2;
	}
	
	if ((event.keyCode<48 || event.keyCode>57))
	{
		if ((null == FuHaoBZ) || ("" == FuHaoBZ))
		{
			FuHaoBZ = "true";
		}
		
		if ("true" == FuHaoBZ)
		{
			if (event.keyCode == 45)
			{
				if (event.srcElement.value.indexOf("-")==0)
					event.srcElement.value = event.srcElement.value.substring(1);
				else
					event.srcElement.value = "-" + event.srcElement.value;
			}
		}
		
		if (event.keyCode != 46 || event.srcElement.value.indexOf(".")>=0)
		{
			if (event.keyCode != 44) event.keyCode = 0;
		}
	}
	else
	{
		if (event.srcElement.value.indexOf(".")>=0)
		{
			if (event.srcElement.value.substring(event.srcElement.value.indexOf(".")+1).length>=XiaoShuWeiShu)
				event.keyCode = 0;
		}
	}
}



/// <summary>
/// 键盘输入控制通用方法
/// </summary>
/// <param name="Number">Number为'True'时可以输入数字。</param>
/// <param name="Upper">Upper为'True'时将输入字符自动转为大写字母。</param>
/// <param name="Lower">Lower为'True'时将输入字符自动转为小写字母。</param>
/// <param name="Special">Special：当前面参数都为空时该参数启用，该参数定义只能输入的键值。</param>
/// <returns>无</returns>
function codekeypress(Number,Upper,Lower,Special) 
{
	var mbln = false;

	if (Number == "True" && event.keyCode>=48 && event.keyCode<=57)
		mbln = true;
	else if (Upper == "True" && event.keyCode>=65 && event.keyCode<=90)
		mbln = true;
	else if (Upper == "True" && event.keyCode>=97 && event.keyCode<=122)
	{
		event.keyCode = event.keyCode - 32;
		mbln = true;
	}
	else if (Lower == "True" && event.keyCode>=97 && event.keyCode<=122)
		mbln = true;
	else if (Lower == "True" && event.keyCode>=65 && event.keyCode<=90)
	{
		event.keyCode = event.keyCode + 32;
		mbln = true;
	}
	else 
	{
		var mstr = String.fromCharCode(event.keyCode);
		if (Special.indexOf(mstr)>=0) mbln = true;
	}

	if (!mbln) event.keyCode = 0;		
}


function PdMax(ingjName,FrmName,innum) 
{
	var prinum;
	var congj;
	congj = eval("window." + FrmName + "." + ingjName);
	prinum=parseFloat(congj.value);
	//alert(prinum);
	if (isNaN(prinum)) 
	{
		//alert("\输入数据有误,只能为阿拉伯数字.请核对！");
		//默认值为1
		congj.value="1";
		congj.focus();
		return false;
	}
	if (parseFloat(prinum) > parseFloat(innum))
	{
		//alert("\输入数据超出范围"+parseFloat(innum)+".请核对！");
		congj.value="1";//不清除，保存时可判断为空时再定位
		congj.focus();
		return false;
	}
	return true;
}	
//*******************************************************************************************//
//************************************以上为键盘输入控制*************************************//
//*******************************************************************************************//

//*******************************************************************************************//
//************************************以下为身份证的验证*************************************//
//*******************************************************************************************//
//	身份证的验证
//	inId —— 身份证号
//	ShenFenZhengGJ —— 身份证号控件
//	ChuShengRiQiGJ —— 年龄控件
//	XingBieGJ —— 性别控件
//	JiGuanGj —— 籍贯控件
//	JiGuanIDGj —— 籍贯ID控件
//	YouBianGj —— 邮编控件
//*********************//
function IsIDCardInforma(ShenFenZhengGJ,ChuShengRiQiGJ,XingBieGJ,memberName,inDictionaryName,inNodeName,JiGuanGj,JiGuanIDGj,YouBianGj)
{
	var iSum=0
	var info=""
	inId = ShenFenZhengGJ.value;
	//********对身份证号进行位数及有效性判断******//
	if ((!/^\d{17}(\d|x)$/i.test(inId)) && (!/^\d{15}$/i.test(inId)))
	{

	  if(ShenFenZhengGJ.value!="")
	  {
	   ShenFenZhengGJ.select();
	   ShenFenZhengGJ.focus();
	   window.open("../../../ZhuChengXu/TiShiXinXiForm.aspx?tsxx=身份证号输入有误！&tssj=1","请注意以下提示信息", "alwaysRaised=yes;z-look=yes;alwaysLowered=no;toolbar=no,location=no,directories=no,status:no;dialogHeight:100px;dialogWidth:400px;,menubar=no,scrollbars=no,resizable=no,copyhistory=no,left=350px,top=300px,width=300px,height=52px");    
	  }
	  return false;
	}
	inId=inId.replace(/x$/i,"a");
	//**********************************//
	
	//********对身份证号的出生日期******// 
	var len = inId.length;
	if (15 == len)
	{
	  var sBirthday = "19" + inId.substr(6,2) + "-" + Number(inId.substr(8,2)) + "-" + Number(inId.substr(10,2));
	  var lsDay = "19" + inId.substr(6,2) + "-" + inId.substr(8,2) + "-" + inId.substr(10,2);
	}
	else if (18 == len)
	{
	  var sBirthday = inId.substr(6,4)+"-"+Number(inId.substr(10,2))+"-"+Number(inId.substr(12,2));
	  var lsDay = inId.substr(6,4) + "-" + inId.substr(10,2) + "-" + inId.substr(12,2);
	}
	else
	{
	    
		alert("身份证号输入有误！");
		ClearGJ(ChuShengRiQiGJ,XingBieGJ,JiGuanGj,JiGuanIDGj);
		ShenFenZhengGJ.focus();
//		window.open("../../../ZhuChengXu/TiShiXinXiForm.aspx?tsxx=身份证号输入有误！&tssj=1","请注意以下提示信息", "alwaysRaised=yes;z-look=yes;alwaysLowered=no;toolbar=no,location=no,directories=no,status:no;dialogHeight:100px;dialogWidth:400px;,menubar=no,scrollbars=no,resizable=no,copyhistory=no,left=350px,top=300px,width=300px,height=52px");    
		return false;
	}
	
	var d=new Date(sBirthday.replace(/-/g,"/"))
	if(sBirthday!=(d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate()))
	{  
	  
	  alert("身份证号输入有误！");
	  //alert("非法生日！");
	  ClearGJ(ChuShengRiQiGJ,XingBieGJ,JiGuanGj,JiGuanIDGj);
	  ShenFenZhengGJ.focus();
//	  window.open("../../../ZhuChengXu/TiShiXinXiForm.aspx?tsxx=身份证号输入有误！&tssj=1","请注意以下提示信息", "alwaysRaised=yes;z-look=yes;alwaysLowered=no;toolbar=no,location=no,directories=no,status:no;dialogHeight:100px;dialogWidth:400px;,menubar=no,scrollbars=no,resizable=no,copyhistory=no,left=350px,top=300px,width=300px,height=52px");    
	  return false;
	}
	//**********************************//
	
	//********对身份证号的有效性进行验证******//
	if (18 == len)
	{
		for(var i = 17;i>=0;i --)
		iSum += (Math.pow(2,i) % 11) * parseInt(inId.charAt(17 - i),11);
		if(iSum%11!=1)
		{
		    
			alert("非法证号！");
			ClearGJ(ChuShengRiQiGJ,XingBieGJ,JiGuanGj,JiGuanIDGj);
			ShenFenZhengGJ.focus();
//			window.open("../../../ZhuChengXu/TiShiXinXiForm.aspx?tsxx=非法证号！&tssj=1","请注意以下提示信息", "alwaysRaised=yes;z-look=yes;alwaysLowered=no;toolbar=no,location=no,directories=no,status:no;dialogHeight:100px;dialogWidth:400px;,menubar=no,scrollbars=no,resizable=no,copyhistory=no,left=350px,top=300px,width=300px,height=52px");    
			return false;
		}
	}
	//**********************************//
	
	//************根据身份证号计算籍贯、邮编***********//
	rootMember = memberName.XMLDocument.documentElement;
	if (null == rootMember)
	{
		rootMember = LoadXml(DictionaryFramInfo,memberName,inDictionaryName)
	}
	//rootMember = memberName.XMLDocument.documentElement;
	nodesMember = rootMember.selectNodes("//"+inNodeName);
	if (null != nodesMember)
	{
		for(var i = 0; i < nodesMember.length; i++)				//搜索匹配记录
		{			
			if (nodesMember.item(i).getAttribute("jiguanid") == inId.substr(0,6))
			{
				if (null != JiGuanGj)
				{
					JiGuanGj.value = nodesMember.item(i).getAttribute("jiguanming");
				}
				if (null != JiGuanIDGj)
				{
					JiGuanIDGj.value = nodesMember.item(i).getAttribute("jiguanid");
				}
				if (null != YouBianGj)
				{
					YouBianGj.value = nodesMember.item(i).getAttribute("youbian");
				}
				break;
			}						
		}
	}
	//************************************//
	
	//********根据身份证号计算性别******//
	if (18 == len)
	{
		var sex = (inId.substr(16,1)%2?"1":"2")
	}
	else if (15 == len)
	{
		var sex = (inId.substr(14,1)%2?"1":"2")
	}
	//********************************//
	
	if (null != ChuShengRiQiGJ)
	{
		ChuShengRiQiGJ.value = lsDay;
	}
	if (null != XingBieGJ)
	{
		XingBieGJ.value = sex;
	}
}
//*******************************************************************************************//
//************************************以上为身份证的验证*************************************//
//*******************************************************************************************//

function ClearGJ(ChuShengRiQiGJ,XingBieGJ,JiGuanGj,JiGuanIDGj)
{
	ChuShengRiQiGJ.value = "";
	XingBieGJ.value = "1";
	JiGuanGj.value = "";
	JiGuanIDGj.value = "";
}


///////光标停在文本框文字的最后
function DotAtEnd()
{
　　var e = event.srcElement;
　　var r =e.createTextRange();
　　r.moveStart("character",e.value.length);
　　r.collapse(true);
　　r.select();
}


/////////////////////////////////////////////////////
////字典调用XML文档。
////用法：
////   <xml id='memberInfo' ></xml>
////   <xml id='DictionaryFramInfo' src="../../javascript/DictionaryFrame.xml"></xml>此xml文档声明了上面xml文档的路径。
////   <script src="../../javascript/DictionaryControl.js"></script>
////   onfocus='readXml(DictionaryFramInfo,memberInfo,"JIGUAN")'
//////////////////////////////////////////////////////
function LoadXml(FramXmlId,XmlId,FramXmlNode)//读取XML文档的内容，并载入另一个xml文档。
{
	var xmlTable = FramXmlId.XMLDocument.documentElement;
	var xmlRoot = xmlTable.selectNodes("//"+FramXmlNode);
	var xmlRootValue  = xmlRoot.item(0).getAttribute("useXMLFileScr");
	//找到xml的url
	XmlId.async = false;
	XmlId.load(xmlRootValue);
	return XmlId;
}


///////////////////////////
//	状态栏中显示提示信息
//	Vmessage — 提示信息的内容
//////////////////////////
function StatusMessage(Vmessage)
{
	window.status  = Vmessage
}

function newAlert(Args){
	window.showModalDialog("../../Confirm.htm",Args,"status:0;dialogWidth:200px;dialogHeight:23px;");
}
//打开高级网页内容编辑器
function htmlEdit(obj)
{
  var width=800;
  var height=700;
  loc_x=(screen.availWidth-width)/2;
  loc_y=(screen.availHeight-height-30)/2;
	//var htmls=window.showModalDialog(location.href.split('modules')[0]+"/modules/lingchuang/HyWebHtmlEditor.aspx",obj,"dialogHeight: 600px; dialogWidth: 800px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
	window.open(location.href.split('modules')[0]+"/modules/lingchuang/HyWebHtmlEditor.aspx?obj="+obj.id,"htmlEdit","width="+width+"; height="+height+"; left="+loc_x+";Top="+loc_y+"; resizable=yes; menubar=yes; status=yes; center=Yes; help=Yes; status=Yes;");
  //return "1";
//	if (typeof(htmls)!="undefined"){
//		obj.innerHTML=htmls
//	}
}
///////////////////////
		
//界面换肤技术
//Cookie操作
function SetCookie(name,value){
     var argv=SetCookie.arguments;
     var argc=SetCookie.arguments.length;
     var expires=(2<argc)?argv[2]:null;
     var path=(3<argc)?argv[3]:null;
     var domain=(4<argc)?argv[4]:null;
     var secure=(5<argc)?argv[5]:false;
     document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}

function GetCookie(Name) {
     var search = Name + "=";
     var returnvalue = "";
     if (document.cookie.length > 0) {
           offset = document.cookie.indexOf(search);
           if (offset != -1) {      
                 offset += search.length;
                 end = document.cookie.indexOf(";", offset);                        
                 if (end == -1)
                       end = document.cookie.length;
                 returnvalue=unescape(document.cookie.substring(offset,end));
           }
     }
     return returnvalue;
}

//动态加载CSS文件
function changecss(url)
{
    if(url!="")
    {
    skin.href=url;
    var expdate=new Date();
    expdate.setTime(expdate.getTime()+(24*60*60*1000*30));
    SetCookie("nowskin",url,expdate,"/",null,false);
    }
}

/*
var thisskin;
thisskin=GetCookie("nowskin");
if(thisskin!="")
{
    if (null != skin)
    {
	    skin.href= location.href.split("/modules/")[0] + "/css/" + thisskin;
	}
}
else
{
    if (null != skin)
    {
        skin.href= location.href.split("/modules/")[0] + "/css/" + "css1.css";
    }
}
*/
//end 界面换肤技术


//added by 陈振泉 2005-10-11(total 2)
//added start
//No.1
//比较字符串长度,长度不足时右补指定的字符
function PadRight(val1,len,paddchar){
	valLength = getStringLength(val1);
	if(valLength>=len)
		return val1;
	else
	{
		charnumber = len - valLength;
		for(cNum=0;cNum<charnumber;cNum++)
			val1 +=paddchar;
		return val1;
	}				
}

//No.2
//计算字符串长度
function  getStringLength(string)
{
	reg = /[\u4e00-\u9fa5]+/gi;
	reg2= /\w+/gi;
	chineseLength = 0;
	otherLength   = 0;
	chinese = string.match(reg);
	other   = string.match(reg2);	
	if(chinese != null)
		chineseLength = chinese.toString().length;
	if(other != null)
		otherLength = other.toString().length;	
	return parseInt(parseInt(chineseLength)*2 + parseInt(otherLength));	
}

//added end

//added by 陈振泉 2005-11-08(total 2)
//No.1
function CheckDate(value){
	var reg = /^((1|2)(\d{3})-((0[1-9])|(1[0-2]))-((0[1-9])|([1-2]\d)|(3[0-1])))$/gi;
	return reg.test(value);
}

function CheckNumber(value){
	var reg=/^([-]{0,1}[0-9]{1,})$/gi;
	return reg.test(value);
}

function CheckFloat(value){
    var reg=/^([-]{0,1}[0-9]{1,}([.][0-9]{1,}){0,1})$/gi;
	return reg.test(value);
}

function CheckInt(value){
    var reg=/^([-]{0,1}[0-9]{1,})$/gi;
	return reg.test(value);
}

function CheckMoney(value){
    var reg=/^([-]{0,1}[0-9]{1,}([.][0-9]{1,}){0,1})$/gi;
    return reg.test(value);
}
//adden end

//键盘检测事件 by chenjf 2005-11-28
//调用方法：document.onkeydown(){defaultKeyDown()}
function AdditionKeyDownCheck(){
	document.onkeydown = function(){
	try{
		var currObj = window.event.srcElement;
		if(currObj.type != 'button' && currObj.type != 'textarea' && (event.keyCode == 13 || event.keyCode == 40)){
		    event.keyCode = 9;
	    }
	    if (currObj.tagName == "INPUT" && currObj.type == "text" && event.keyCode == 38){
			var inputs = document.all.tags("INPUT");
			for (var i= inputs.length-1; i >=0 ; i--){
				if (inputs[i].type == "text" && inputs[i].sourceIndex < currObj.sourceIndex) break;
			}
			inputs[i].focus();
		}
	}
	catch(e){}
	}
}
//end 键盘输入事件

//设置控件的值 by chenjf 2005-11-18
function setRadioValue(obj,Value){
	for (var i=0;i<obj.length;i++){
		if (obj[i].value==Value) obj[i].checked;
	}
}

function setSelectValue(obj,Value){
	for(var i=0;i<obj.length;i++){
		if (obj[i].value==Value) obj[i].selected = true;
	}
}
//end 设置控件的值

//added by 陈振泉 2005-11-22(total 1)
//No.1
//四舍五入,保留两位小数
function MoneyFormat(value){
	return Math.round((parseFloat(value) + 0.004)*100)/100;
}
//adden end
function findTextByValue(objid,value){
	var obj = document.getElementById(objid);
	for(i=0;i<obj.options.length;i++)
	{
		if(obj.options(i).value == value)
			return obj.options(i).text;		
	}
	return value;
}
//added by zw 2006-10-06
//保留几位小数,四舍五入 默认两位小数
//value--要处理的数
//weishu--保留的小数点后位数
function floatFormat(value,weishu){
    
	weishu = parseInt(weishu,10);
	if(isNaN(weishu))
	{
	    weishu=2;
	}
	
	if(isNaN(value))
	{
	    value=0;
	}
	
	var baoLiuWeiShu = Math.pow(10,weishu);
	var returnValue ="" + Math.round((parseFloat(value))*baoLiuWeiShu )/baoLiuWeiShu ;
	var xiaoShuWei=0;
    
	if(returnValue.indexOf(".")>0)//不足的补0
	{
	    xiaoShuWei=returnValue.split(".")[1].length;  
	}
	else
	{
		returnValue +=".";
    }	
		
	for(var i=xiaoShuWei;i<weishu;i++)
    {
        returnValue +="0";
    }
	return returnValue;
}

function findValueByText(objid,text){
	var obj = document.getElementById(objid);
	for(x=0;x<obj.options.length;x++)
	{
		if(obj.options(x).innerText == text)
			return obj.options(x).value;		
	}
	return text;
}
function ValidatePage()
{
    var objs = document.getElementsByTagName("input");
    for(var i=0;i<objs.length;i++)
    {
        if(objs[i].type == "text")
        {
            if(objs[i].AllowNull == "false" && objs[i].value == "")
            {
                if(objs[i].ErrorText != null)
                   alert(objs[i].ErrorText);
                else
                    yanshitishi("还有未填写的内容,请填写","1.5");
                objs[i].select();
                objs[i].focus();
                return false;
            }
            if(objs[i].value != ""){
                switch(objs[i].ValidateMode)
                {
                    case "Number":
                        if(!CheckNumber(objs[i].value))
                        {
                            if(objs[i].ErrorText != null)
                                alert(objs[i].ErrorText);
                            else
                                yanshitishi("只允许输入数字,请重新输入","1.5");
                            objs[i].select();
                            objs[i].focus();
                            return false;
                        }
                        break;
                    case "Date":
                        if(!CheckDate(objs[i].value))
                        {
                            if(objs[i].ErrorText != null)
                                alert(objs[i].ErrorText);
                            else
                                yanshitishi("只允许输入日期,请重新输入","1.5");
                            objs[i].select();
                            objs[i].focus();
                            return false;
                        }
                        break;
                    case "Money":
                        if(!CheckMoney(objs[i].value))
                        {
                            if(objs[i].ErrorText != null)
                                alert(objs[i].ErrorText);
                            else
                                yanshitishi("金额只允许为数字，请重新输入!","1.5");
                            objs[i].select();
                            objs[i].focus();
                            return false;
                        }
                        break;
                } 
            }          
        }
    }
    return true;    

}
//end 界面换肤技术

//=======================延时提示================================
//参数:
//      message 消息
//      outTime 延时时间,单位秒
//var tishiwin;
//var timeid;
function yanshitishi(message,outTime)
{ 
    if(null==message || typeof(message)=="undefined" || ""==message)
        return false;
        
    var width = message.length *30; 
	var height = 180;
	if(null==message)
	{
	    message="弘扬软件提醒您...";
	}
    if(width > 800)
    {
        width=800;
    }
    else if(width<200)
    {
        width=200;
    }
    if(null==outTime || typeof(outTime)=="undefined")
        outTime = 1; //  杨磊
    try
    {
        outTime=parseFloat(outTime);
    }
    catch(e)
    {
        outTime = 1; //  杨磊
    }
    var left=(screen.availWidth-width)/2;
    var host=window.location.host;
    var url="http://"+host+"/crds3/modules/ZhuChengXu/TiShiXinXiForm.aspx";
    
//    if(null!=tishiwin && typeof(tishiwin)=="object")
//    {
//        tishiwin.close();
//        clearTimeout(timeid);
//        
//    }
    
    var args=message+"|"+outTime;
    
    window.showModalDialog(url,args,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;toolbar:no;menubar:no;location:no;scrollbars:no;resizable:no;help:no;center:yes;status:no;");
//    window.showModelessDialog(url,args,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;status:no;toolbar:no;menubar:no;location:no;scrollbars:yes;resizable:no;help:no;");
//	var host=window.location.host;
//	var innerHTML="";
//	innerHTML+="<HTML>";
//	innerHTML+="<HEAD>";
//	innerHTML+="<title>弘扬软件提醒您:</title>";
//	innerHTML+="<\/HEAD>";
//	innerHTML+='<body bgColor="#ffffcc" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" >';
//	innerHTML+='<TABLE id="Table1" width="100%" height="100%" cellSpacing="0" cellPadding="0" border="0">';
//	innerHTML+='<TR align="center" valign="middle">';
//	innerHTML+='<TD><IMG alt="" src="http://'+host+'/crds3/images/tips.gif" border="0">';
//	innerHTML+='<span style="font-size:14pt; font-weight:bold; color:Red; ">'
//	innerHTML+=message;
//	innerHTML+='<\/span>';
//	innerHTML+='<\/TD>';
//	innerHTML+='<\/TR>';
//	innerHTML+='<\/TABLE>';
//	innerHTML+='<\/body>';
//	innerHTML+='<\/HTML>';
//	
//	tishiwin.document.write(innerHTML);
//	outTime=outTime*1000;
//    timeid=setTimeout("tishiwin.close()",outTime);	
}
//当调用窗口关闭时关闭提示框
//window.onunload=tishiwinClose;
//function tishiwinClose()
//{
//    clearTimeout(timeid);
//    if(null!=tishiwin)
//        tishiwin.close();
//}

//added by 钟耸旻 2006-7-1(total 2)
function yizhuyanshitishi(message)
{ 
    window.open("../../ZhuChengXu/TiShiXinXiForm.aspx?tsxx="+message+ "&tssj=1","请注意以下提示信息", "alwaysRaised=yes;z-look=yes;alwaysLowered=no;toolbar=no,location=no,directories=no,status:no;dialogHeight:100px;dialogWidth:400px;,menubar=no,scrollbars=no,resizable=no,copyhistory=no,left=350px,top=300px,width=300px,height=52px");
  
}

//屏蔽F5键，避免F5键刷新页面
function document.onkeydown()
{
	if(window.event.keyCode == 116)
    {
          event.keyCode = 0;
          event.returnValue = false;
    }
}
//OPEN一个窗口
function LoadWindow(URL,title,width,height)
{
  if(width==null)
    width=800;
  if(height==null)
    height=600;
  loc_x=(screen.availWidth-width)/2;
  loc_y=(screen.availHeight-height-30)/2;
  return window.open(URL,title,"height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,top="+loc_y+",left="+loc_x+",resizable=no"); 
}

//打开模式网页对话框
function OpenModelWindow(URL,width,height)
{
  if(width==null)
    width=800;
  if(height==null)
    height=600;

  var result = window.showModalDialog(URL,window,"DialogWidth:"+width+"px;DialogHeight:"+height+"px;status:no;toolbar:no;menubar:no;location:no;scrollbars:yes;resizable:no;help:no;");
  return result;
}

//修改注册表上下左右边距,清空页眉,清空页脚
function PageSetup_Null(mtop,mbottom,mleft,mright) 
{

    mtop=""+parseFloat(mtop)/2.54;
    mbottom=""+parseFloat(mbottom)/2.54;
    mleft=""+parseFloat(mleft)/2.54;
    mright=""+parseFloat(mright)/2.54;

    if(null==mtop || ""==mtop || "NaN"==mtop)
        mtop = (0.505/2.54);
    if(null==mbottom || ""==mbottom || "NaN"==mbottom)
        mbottom = (0.505/2.54);
    if(mleft==null || ""==mleft || "NaN"==mleft)
        mleft = (1.905/2.54);
    if(null==mright || ""== mright || "NaN"==mright)
        mright = (1.905/2.54);
    
    var HKEY_Root,HKEY_Path,HKEY_Key; 
    HKEY_Root="HKEY_CURRENT_USER"; 
    HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";  
    try 
    { 

	    var RegWsh=new ActiveXObject("WScript.Shell"); 
	
	    HKEY_Key="\margin_left" ;
        RegWsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,mleft);  //键值设定--左边边界

        HKEY_Key="\margin_right" ;
        RegWsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,mright); //键值设定--右边边界


	    HKEY_Key="\margin_top" ;
        RegWsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,mtop);//键值设定--上边边界

        HKEY_Key="\margin_bottom" ;
        RegWsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,mbottom); //键值设定--下边边界
        
        HKEY_Key="header"; 
        RegWsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); //清空页眉
        
        HKEY_Key="footer"; 
        RegWsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");//清空页脚
    } 
    catch(e){} 
} 
/// <summary>
///身份证号码
///object－－－要判断的控件
///如果条件成立，返回一个true，否则为false
/// <summary>

function ShengFenZhengYanZheng(value)
{
  if(value !="")
  {
     var reg=/^(\d{17}[\d|X]|\d{15})$/gi;
     if(reg.test(value))
     {
       return true;
     }
     else
     {
      return false;
     }
  }
  else
  {
    return false;
  }
}

//根据模块ID,客户机IP取得所设置打印机
function getDaYinJi(menuID,ipAddress)
{
    var xmlDocDaYin = new ActiveXObject("Microsoft.XMLDOM");
    xmlDocDaYin.async="false" ;
    xmlDocDaYin.setProperty("SelectionLanguage", "XPath");
    xmlDocDaYin.loadXML("<root/>");
    
    var xmlDocChild = new ActiveXObject("Microsoft.XMLDOM");
    xmlDocChild.async = "false";
	xmlDocChild.load("../../../../PrintTemp/DaYinConfig.xml");
	if (xmlDocChild.parseError.errorCode!=0) 
	{
	    yanshitishi("加载有误！"); 
	    return false;
	}
	else 
	    xmlDocDaYin.documentElement.appendChild(xmlDocChild.documentElement);
	var nodeArrs = xmlDocDaYin.documentElement.selectNodes("//dayinconfig");
	for (var i=0;i<nodeArrs.length;i++)
	{
	    var node = nodeArrs[i].text;
	    if (node == 0)
	    {
            if(nodeArrs(i).getAttribute("gongguid")==menuID&&nodeArrs(i).getAttribute("ipaddress")==ipAddress)
            {
                //alert(nodeArrs(i).getAttribute("dayinji"));
                setDaYinJi(nodeArrs(i).getAttribute("dayinji"));
            }
	    }
    }
}
//设置默认打印机
 function setDaYinJi(zhi)
{
    var HKEY_Root,HKEY_Path,HKEY_Key; 
    HKEY_Root="HKEY_CURRENT_USER"; 
    HKEY_Path="\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\";  
    try 
    { 

        var RegWsh=new ActiveXObject("WScript.Shell"); 
        var daYinZhi = zhi;
        HKEY_Key="\Device" ;
        var oldZhi = RegWsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key);
        RegWsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,daYinZhi);  //设置默认打印机
        return oldZhi;
    } 
    catch(e){} 
}
