




//分页提交
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("/BASTOBSP/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;
}


function openWindow(url,name,top,left,width,height,resizable,scrollbars){
	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);
}

var popwin = null;
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();
}


