




//分页提交
function pageSubmit(theForm,action) {
    theForm.elements["pageHelper.action"].value = action;
//	theForm.act.value="query";
    theForm.submit();
}

//全选框处理
function allselect(theForm){
	if (typeof(theForm.choice)!="undefined")
		{
			if(theForm.all.checked)
			{
				if(theForm.choice[0]==null) theForm.choice.checked = true;
				for(var i=0; theForm.choice[i]!=null; i++){
					theForm.choice[i].checked = true;
			}
		}
	else {
			if(theForm.choice[0]==null) theForm.choice.checked = false;
			for(var i=0; theForm.choice[i]!=null; i++)
			{
				theForm.choice[i].checked = false;
			}
		}
	}
}

//判断是否选择了一项
function CheckOptions(theForm)
{
	if(theForm.choice==null) return false;

	if(theForm.choice[0]==null)
	{
		return theForm.choice.checked;
	}

	for(var i=0; theForm.choice[i]!=null; i++)
	{
		if(theForm.choice[i].checked)
			return true;
	}
	return false;
}

//用于授权
function au(theForm){
	var a = window.showModalDialog("/NETPRO/common/authentic.jsp", "授权","dialogHeight:200px;dialogWidth:200px;help:no;status:no;");
	if (typeof (a) != "undefined")
	{
		theForm.acctno.value = a[0];
		theForm.acctpw.value = a[1];
		return true;
	}
	else{
		theForm.act.value="query";
		return false;
	}
}


//用于多项功能操作,参数为（form,action,是否验证form,是否有多项数据,是否需要授权,是否需要提醒,提醒内容）
function exec_op(theForm,action,va_flag,mu_flag,au_flag,rm_flag,rm_word)
{
	if(typeof(rm_flag) != "undefined" && typeof(rm_word) != "undefined"){
		if(rm_flag && !confirm(rm_word)){
			return false;
		}
	}

	theForm.act.value = action;

	if(action == 'query') 	{
		try{
			theForm.elements["pageHelper.action"].value = 'current';
			theForm.elements["pageHelper.currPageNo"].value = 1;
		}catch(e){}
	}
	
	if(va_flag){
		if(!validateForm(theForm)){
			return false;
		}
	}
	
	if(mu_flag){
		if(!CheckOptions(theForm))
		{
			alert("请至少选择一项要操作的数据！");
			return false;
		}
	}
	
	if(au_flag){
		return au(theForm);
	} 

	return true;

}

//获取form选择了哪些项的数据
function getCheckData(thatForm,thisForm,noword,oneword){
	var act = thisForm.oftpftnu.value;
	var data = '';
	var num = 0;

	if(thatForm.choice!=null) {
		if(thatForm.choice[0]==null){
			if(thatForm.choice.checked == true){
				data = thatForm.choice.value;
				num++;
			}
		}else {
			for(var i=0; thatForm.choice[i]!=null; i++){
				if(thatForm.choice[i].checked == true){
					if(data == '') {data = thatForm.choice[i].value;}
					else {data = data + "|" + thatForm.choice[i].value;}
					num++;
				}
			}
		}
	}

	if(act == "AD"){
		
	}else if(act == "MD" || act == "CH"|| act == "AJ"){
		if(num == 0){
			if(typeof(noword) == "undefined")alert("没有选择数据");
			else alert(noword);
			return false;
		}else if(num > 1) {
			if(typeof(oneword) == "undefined") alert("只能选择单项数据");
			else alert(oneword);
			return false;
		}
	}else if(act == "DL" || act == "PA" || act == "NP" || act == "PU" || act == "CP" ){
		if(num == 0){
			if(typeof(noword) == "undefined")alert("没有选择数据");
			else alert(noword);
			return false;
		}

	}

	thisForm.checkdata.value = data;
	return true;
}

var popwin = null;

function openWindow(url,name,top,left,width,height,resizable,scrollbars){
	if (popwin != null && popwin.open) popwin.close();

	var params = 'toolbar=no, menubar=no, location=no, status=no';
	params = params + ",top=" + top;
	params = params + ",left=" + left;
	params = params + ",width=" + width;
	params = params + ",height=" + height;
	params = params + ",resizable=" + resizable;
	params = params + ",scrollbars=" + scrollbars;
	popwin = window.open(url, name, params);
}

function newwin(objForm,winname,top,left,width,height,resizable,scrollbars){
	if (popwin != null && popwin.open) popwin.close();
	popwin = openWindow("",'popwin',top,left,width,height,resizable,scrollbars);
	objForm.target = winname;
} 

function invite(myform,top,left,width,height,resizable,scrollbars){
    newwin(myform,'popwin',top,left,width,height,resizable,scrollbars);
    myform.submit();
}

var xmldoc = false;
var lastUpdate = 0;
var topid = "";
function createxmldoc(){
	if(window.XMLHttpRequest){
		try{
			xmldoc = new XMLHttpRequest();
			if(xmldoc.overrideMimeType){
				xmldoc.overrideMimeType("text/xml");
			}
		}catch(e){}
	}else if(window.ActiveXObject){
		try{
			xmldoc = new ActiveXObject("Msxml4.XMLHTTP");
		}catch(e){
			try{
				xmldoc = new ActiveXObject("Msxml3.XMLHTTP");
			}catch(e){
				try{
					xmldoc = new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e){
					try{
						xmldoc = new ActiveXObject("Microsoft.XMLHTTP");
					}catch(e){}
				}
			}
		}
	}
	if(!xmldoc){
		return false;
	}
}

 function getReadyStateHandler() {
     if (xmldoc.readyState == 4) {
       if (xmldoc.status == 200) {
			try{
			 	var dataXML = xmldoc.responseXML;
				var msg = xmldoc.responseText;
				if (typeof DOMParser != "undefined") {
					dataXML = (new DOMParser()).parseFromString(msg, "application/xml"); 
				}else if (typeof ActiveXObject != "undefined") { 
					dataXML = new ActiveXObject("MSXML2.DOMDocument"); 
					dataXML.loadXML(msg); 
				}
		        updateData(dataXML);
			}catch(e){}
       } else {
         //alert("HTTP error "+xmldoc.status+": "+xmldoc.statusText);
       }
     }
 }

function getData(url){
	try{
		xmldoc = false;
		createxmldoc();
		if(xmldoc){
			xmldoc.open("POST",url + (topid!=""?"topid="+topid:""),true);
			xmldoc.onreadystatechange = getReadyStateHandler;
			xmldoc.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmldoc.send(null);
		}
	}catch(e){
		//alert(e.description);
	}
}

function bind(func, args) { 
	return function() { 
		func.apply(null, args); 
	}; 
} 

//document.oncontextmenu=new Function("event.returnValue=false;");//屏蔽右键
//document.onselectstart=new Function("event.returnValue=false;");//屏蔽选择

function KeyDown(){
  if ((event.keyCode==116)|| (event.ctrlKey && event.keyCode==82)){ 
     event.keyCode=0;
     event.returnValue=false;
  }
}