//打印参数设置
function PageSetup_Null(bottom,left,right,top){ 
	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="header" 
	   RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") 
	   hkey_key="footer" 
	   RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") //去掉了&u 因为我不想显示当前打印页的网址 
	   hkey_key="margin_bottom"; 
	   RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,bottom); 
	   hkey_key="margin_left"; 
	   RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,left); 
	   hkey_key="margin_right"; 
	   RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,right); 
	   hkey_key="margin_top"; 
	   RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,top); 
	 }catch(e){
	   alert("请将您浏览器Internet选项中的“对没有标记为安全的ActiveX控件进行初始化和脚本运行”设置为“启用”！\n\n然后刷新本页登陆！"); 
	 } 
} 

function copy(objs,objt){	
	document.getElementById(objt).value = document.getElementById(objs).value;		
}
function alertmsg(errmsg){
	if(errmsg != ""){
		alert(errmsg);
	}
}
function getCheckbox(obj){
	var vals = "";
	for(var i= 0;i <obj.length;i++){
		   if(obj[i].checked){
				if(vals=="")
					vals += obj[i].value;
				else
					vals += ","+ obj[i].value;
			}
	}
	return vals;
}
function fPopUpComDlg(page,id){
	var url = page+'?id='+id;
	frmWidth = 500;
	frmHeight = 300;
	popuWinObj = OpenWindow(url,frmWidth,frmHeight);
	return;
}
function  strDateTime(str){   
	var reg   =   /^(\d{4})(年)(\d{1,2})(月)(\d{1,2})(日)$/;     
	var reg1   =   /^(\d{4})(\/)(\d{1,2})(\/)(\d{1,2})$/;     
	var reg2   =   /^(\d{4})(\d{2})(\d{2})$/;     
	var   r   =   str.match(reg);     
	var   r1   =   str.match(reg1);  
	var   r2   =   str.match(reg2);  

	if(r==null && r1==null && r2==null){
		return   false;
	}
	if(r!=null){
		var   d=   new   Date(r[1],r[3]-1,r[5]);     
	}else if(r1!=null){
		var   d=   new   Date(r1[1],r1[3]-1,r1[5]);     
	}else if(r2!=null){
	   var   d=   new   Date(r2[1],r2[2]-1,r2[3]);     
	}
	
	var month = "";
	var day = "";
	if(d.getMonth()+1 < 10){
		if(r!=null && r[3].length == 1){
			month = d.getMonth()+1;
		}else if(r1!=null && r1[3].length == 1){
			month = d.getMonth()+1;
		}else{
			month = "0" + (d.getMonth()+1);
		}
	}else{
		month = d.getMonth()+1;
	}
	if(d.getDate() < 10){
		if(r!=null && r[5].length == 1){
			day = d.getDate();
	   }else if(r1!=null && r1[5].length == 1){
			day = d.getDate();
	   }else{
		day = "0" + d.getDate();
	   }
	}else{
		day = d.getDate();
	}
	if(r!=null){
		var   newStr=d.getFullYear()+r[2]+month+r[4]+day+r[6];
	}else if(r1!=null){
		var   newStr=d.getFullYear()+r1[2]+month+r1[4]+day;
	}else if(r2!=null){
	   var   newStr=d.getFullYear()+""+month+""+day;
	}

	return   newStr==str   ;
}   
function   formate_DateTime(str){   
	var   reg   =   /^(\d{4})(年)(\d{1,2})(月)(\d{1,2})(日)$/;     
	var   reg1   =   /^(\d{4})(\/)(\d{1,2})(\/)(\d{1,2})$/;     
	var   reg2   =   /^(\d{4})(\d{2})(\d{2})$/;     
	var   r   =   str.match(reg);     
	var   r1   =   str.match(reg1);  
	var   r2   =   str.match(reg2);
	var   newStr = "";
	if(r!=null){
		if(r[3].length == 1){
			r[3] = "0" + r[3];
		}
		if(r[5].length == 1){
			r[5] = "0" + r[5];
		}
		var newStr=r[1]+"/"+r[3]+"/"+r[5]+"";
	}else if(r1!=null){
		if(r1[3].length == 1){
			r1[3] = "0" + r1[3];
		}
		if(r1[5].length == 1){
			r1[5] = "0" + r1[5];
		}
		newStr=r1[1]+"/"+r1[3]+"/"+r1[5]+"";
	}else if(r2!=null){
		newStr=r2[1]+"/"+r2[2]+"/"+r2[3]+"";
	}
	return   newStr;
}
function   formate_DateTime2(str){   
	var   reg   =   /^(\d{4})(年)(\d{1,2})(月)(\d{1,2})(日)$/;     
	var   reg1   =   /^(\d{4})(\/)(\d{1,2})(\/)(\d{1,2})$/;     
	var   reg2   =   /^(\d{4})(\d{2})(\d{2})$/;     
	var   r   =   str.match(reg);     
	var   r1   =   str.match(reg1);  
	var   r2   =   str.match(reg2);
	var   newStr = "";
	if(r!=null){
		if(r[3].length == 1){
			r[3] = "0" + r[3];
		}
		if(r[5].length == 1){
			r[5] = "0" + r[5];
		}
		var newStr=r[1]+"年"+r[3]+"月"+r[5]+"日";
	}else if(r1!=null){
		if(r1[3].length == 1){
			r1[3] = "0" + r1[3];
		}
		if(r1[5].length == 1){
			r1[5] = "0" + r1[5];
		}
		newStr=r1[1]+"年"+r1[3]+"月"+r1[5]+"日";
	}else if(r2!=null){
		newStr=r2[1]+"年"+r2[2]+"月"+r2[3]+"日";
	}
	return   newStr;
}
//null check
function Null_Check(n1){
	if(n1 == null) {
		return true;
	}
	if(n1.length == 0) {
		return true;
	}
	return false;
}

//number check
function Number_Check(nm1) {
	if ( nm1 == "" ) return false;
	if ( nm1.match( /[0-9.]*/i ) != nm1 ) {
		return true;
	}
	if ( Number(nm1) != nm1 ){
		return true;
	}
	return false;
}

//判断多少位数字
function Number_PosCheck(nm1){
	for(var i=0;i<nm1.length;i++)
	 {
		var num =nm1.charAt(i);
		if(isNaN(parseInt(num)))
		  {
			 return true;
		  }
	 }
	 return false;
}

//判断邮件地址里面是否@符号
function Email_Check(email){
	var regInvalid=/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;   
	var regValid=/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;   
	return !(!regInvalid.test(email) && regValid.test(email)); 
}
//弹出画面 ST Open 
function OpenWindow(href,windowwidth,windowheight) {
	var oppW = window.open(href,'_blank','scrollbars=yes, menubar=no,resizable=no,location=no,status=no,toolbar=no,height='+windowheight+',width='+windowwidth+',left='+(window.screen.availWidth-windowwidth)/2+',top='+(window.screen.availHeight-windowheight)/2);
	showBg();
	return oppW;
}	
var popuWinObj = null;
function setOnFocus(window){

	window.onfocus=function (){
		if(popuWinObj){
			if(!popuWinObj.closed)
				popuWinObj.focus();
			else
				closeBg();
		} 
	}; 		
	window.document.onfocus=function (){
		if(popuWinObj){
			if(!popuWinObj.closed)
				popuWinObj.focus();
			else
				closeBg();    
		}
	};		
	window.document.onclick=function (){
		if(popuWinObj){
			if(!popuWinObj.closed)
				popuWinObj.focus();
			else
				closeBg();    
		}
	};		
	window.document.ondblclick=function (){
		if(popuWinObj){
			if(!popuWinObj.closed)
				popuWinObj.focus();
			else
				closeBg();    
		}
	};  	
	createBgDiv();
}
function createBgDiv(){  		
	var mydiv = window.document.createElement("div"); 
	mydiv.setAttribute("id","bgDiv");
	mydiv.style.filter = "alpha(opacity=35)";
	mydiv.style.opacity = "0.4";
	mydiv.style.display = "none";
	mydiv.style.position = "absolute";
	mydiv.style.left = "0px";
	mydiv.style.right = "0px";
	mydiv.style.top = "0px";
	mydiv.style.backgroundColor = "#ffffff" ;
	document.body.appendChild(mydiv);  		
}
function showBg() { 
	var bgObj=document.getElementById("bgDiv");
	bgObj.style.width = document.body.offsetWidth + "px";
	bgObj.style.height = screen.height + "px";
	bgObj.style.display = "block";
}
function closeBg(){
	var bgObj=document.getElementById("bgDiv");
	bgObj.style.display = "none";
	try{
		winCloseTodoFun();
	}catch(e){
	}
}

//弹出层
var bgObj;
var msgObj;
function RemoveParentDivWindow(){
    window.parent.document.body.removeChild(window.parent.document.getElementById("unvalidbgdiv")); 
    window.parent.document.body.removeChild(window.parent.document.getElementById("player")); 
}

// 弹出DIV的对话框
function OpenDiv(href,windowwidth,windowheight, title){ 

    var msg = "open window";
	var w = windowwidth;
	var h = windowheight;
	var titleheight = "23px"; // 窗口标题高度 
    var titlecolor = "#FFFFFF"; // 窗口标题颜色 
	var bordercolor = "#445566"; // 提示窗口的边框颜色 
	var titlebgcolor = "#223344"; // 窗口标题背景色
	var bgcolor = "#FFFFFF"; // 提示内容的背景色	
	var iWidth = document.documentElement.clientWidth;
	var iHeight = document.documentElement.clientHeight; 	

    // draw back div
	bgObj = document.createElement("div"); 
    bgObj.id = "unvalidbgdiv";
    bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:" + iWidth + "px;height:" + iHeight + "px;filter:Alpha(Opacity=90);opacity:0.3;background-color:#DDDDDD;z-index:101;" 
    document.body.appendChild(bgObj);  
	
	
	// draw message window div
	msgObj=document.createElement("div");
	msgObj.id = "player";
	msgObj.style.cssText = "position:absolute;font:11px 'Arial';top:"+(iHeight-h)/4+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;padding:0px;line-height:22px;z-index:102;";   // container
	document.body.appendChild(msgObj);

	var table = document.createElement("table");
	msgObj.appendChild(table);
	table.style.cssText = "margin:0px;border: 2px solid " + bordercolor + ";padding:0px;";
	table.cellSpacing = 0;	

	var tr = table.insertRow(-1);
	var titleBar = tr.insertCell(-1);
	titleBar.style.cssText = "background-color: " + titlebgcolor + ";background-repeat: repeat-x;width:480px;height:"+titleheight+"px;text-align:left;font:bold 12px 'Arial';color:"+titlecolor+";cursor:move;"; // title
	titleBar.style.paddingLeft = "10px";
	titleBar.innerHTML = title;

	var moveX = 0;
	var moveY = 0;
	var moveTop = 0;
	var moveLeft = 0;
	var moveable = false;
	var docMouseMoveEvent = document.onmousemove;
	var docMouseUpEvent = document.onmouseup;
	titleBar.onmousedown = function() {
		var evt = getEvent();
		moveable = true; 
		moveX = evt.clientX;
		moveY = evt.clientY;
		moveTop = parseInt(msgObj.style.top);
		moveLeft = parseInt(msgObj.style.left);
		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
				if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
				}
			}	
		};
		document.onmouseup = function () { 
			if (moveable) { 
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false; 
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			} 
		};
	}
	var closeBtn = tr.insertCell(-1);
	closeBtn.style.cssText = "color:" + titlecolor + ";background-color: " + titlebgcolor + ";background-repeat: repeat-x;text-align:center; width: 25px;cursor:pointer;";
	closeBtn.innerHTML = "<span >关闭</span>";   //close
	closeBtn.onclick = function(){ 
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj); 
	} 
	
	if(document.addEventListener){//如果是Firefox
	    document.addEventListener("keypress",fireFoxHandler, true);
	}else{
	    document.attachEvent("onkeypress",ieHandler);
	}
	
	function fireFoxHandler(evt){
	    //alert("firefox");
	    if(evt.keyCode==27){	
	       document.body.removeChild(bgObj); 
	       document.body.removeChild(msgObj);
	    }
	}	
	function ieHandler(evt){
	    //alert("IE");
	    if(evt.keyCode==27){
	       document.body.removeChild(bgObj); 
		   document.body.removeChild(msgObj);
	    }
	}
	
	// add iframe 
	var msgBox = table.insertRow(-1).insertCell(-1);
	msgBox.style.cssText = "font:10pt 'Arial';background-color:" + bgcolor;
	msgBox.colSpan  = 2;
	var ext = msg.substr(msg.lastIndexOf (".") + 1).toLowerCase();	
	var workscontent = '<div style="border:2px solid white"><iframe src=' + href + ' width="' + windowwidth + '" height="' + windowheight + '" style="border:none;" frameborder="0"></iframe></div>';
	msgBox.innerHTML = workscontent;

    // 获得Event对象，用于兼容IE和FireFox
    function getEvent() {
	    return window.event || arguments.callee.caller.arguments[0];
    }
	return;	
} 

function RemoveParentDivWindowNoBg(){
    window.parent.document.body.removeChild(window.parent.document.getElementById("player")); 
}

function OpenDivNoBg(href,windowwidth,windowheight, title, windowleft, windowtop){ 
//show(msg, mediaindex)
    var msg = "open window";
	var w = windowwidth;
	var h = windowheight;
	var titleheight = "23px"; // 窗口标题高度 
	var bordercolor = "#333333"; // 提示窗口的边框颜色 
	var titlecolor = "#333333"; // 窗口标题颜色 
	var titlebgcolor = "#333333"; // 窗口标题背景色
	var bgcolor = "#999999"; // 提示内容的背景色	
	var iWidth = document.documentElement.clientWidth;
	var iHeight = document.documentElement.clientHeight; 	
	//$("#bk_swf_player").hide();

	// draw message window div
	msgObj=document.createElement("div");
	msgObj.id = "player";
	msgObj.style.cssText = "position:absolute;font:11px 'Arial';top:"+ windowtop+"px;left:"+ windowleft+"px;width:"+w+"px;height:"+h+"px;text-align:center;padding:1px;line-height:22px;z-index:102;";   // container
	document.body.appendChild(msgObj);

	var table = document.createElement("table");
	msgObj.appendChild(table);
	table.style.cssText = "margin:0px;border:0px;padding:0px;";
	table.cellSpacing = 0;	

	var tr = table.insertRow(-1);
	var titleBar = tr.insertCell(-1);
	titleBar.style.cssText = "background-color: #CCCCCC;border-top: 1px solid #EEEEEE;border-left: 1px solid #EEEEEE; background-repeat: repeat-x;width:480px;height:"+titleheight+"px;text-align:left;font:bold 12px 'Arial';color:"+titlecolor+";cursor:move;"; // title
	titleBar.style.paddingLeft = "10px";
	titleBar.innerHTML = title;

	var moveX = 0;
	var moveY = 0;
	var moveTop = 0;
	var moveLeft = 0;
	var moveable = false;
	var docMouseMoveEvent = document.onmousemove;
	var docMouseUpEvent = document.onmouseup;
	titleBar.onmousedown = function() {
		var evt = getEvent();
		moveable = true; 
		moveX = evt.clientX;
		moveY = evt.clientY;
		moveTop = parseInt(msgObj.style.top);
		moveLeft = parseInt(msgObj.style.left);
		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
				if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
				}
			}	
		};
		document.onmouseup = function () { 
			if (moveable) { 
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false; 
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			} 
		};
	}
	var closeBtn = tr.insertCell(-1);
	closeBtn.style.cssText = "background-color: #CCCCCC;border-top: 1px solid #EEEEEE;border-right: 1px solid #AAAAAA; background-repeat: repeat-x;text-align:center; width: 25px;cursor:pointer;";
	closeBtn.innerHTML = "<span style='color:#333333'>关闭</span>";   //close
	closeBtn.onclick = function(){ 
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj); 
	} 
	
	if(document.addEventListener){//如果是Firefox
	    document.addEventListener("keypress",fireFoxHandler, true);
	}else{
	    document.attachEvent("onkeypress",ieHandler);
	}
	
	function fireFoxHandler(evt){
	    //alert("firefox");
	    if(evt.keyCode==27){	
	       document.body.removeChild(bgObj); 
	       document.body.removeChild(msgObj);
	    }
	}	
	function ieHandler(evt){
	    //alert("IE");
	    if(evt.keyCode==27){
	       document.body.removeChild(bgObj); 
		   document.body.removeChild(msgObj);
	    }
	}
	
	// add iframe 
	var msgBox = table.insertRow(-1).insertCell(-1);
	msgBox.style.cssText = "font:10pt 'Arial';background-color:" + bgcolor;
	msgBox.colSpan  = 2;
	var ext = msg.substr(msg.lastIndexOf (".") + 1).toLowerCase();	
	var workscontent = '<iframe src=' + href + ' width="' + windowwidth + '" height="' + windowheight + '" style="border:none;" frameborder="0"></iframe>';
	msgBox.innerHTML = workscontent;

    // 获得Event对象，用于兼容IE和FireFox
    function getEvent() {
	    return window.event || arguments.callee.caller.arguments[0];
    }
	return;	
} 
