




//分页提交
function pageSubmit(action) {
    document.forms[0].elements["pageHelper.action"].value = action;
	document.forms[0].act.value="list";
    document.forms[0].submit();
}

//分页提交2:pageSubmitByNo
function pageSubmitByNo(pageNo) {
    document.forms[0].elements["pageHelper.action"].value = "current";
	document.forms[0].elements["pageHelper.currPageNo"].value = pageNo;
	document.forms[0].act.value="list";
    document.forms[0].submit();
}

//分页提交3
function pageSubmitByFrm(objForm,action) {
    objForm.elements["pageHelper.action"].value = action;
	objForm.act.value="list";
    objForm.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("/CSEPCN/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_btn(theForm,action,va_flag,mu_flag,au_flag)
{
	theForm.act.value = action;
	
	if(va_flag){
		if(!validateForm(theForm)){
			return false;
		}
	}
	
	if(mu_flag){
		if(!CheckOptions(theForm))
		{
			alert("请至少选择一项要操作的数据！");
			return false;
		}
	}
	
	if(au_flag){
		return au(theForm);
	} 

	//删除特殊处理
	if (action == "delete") {
		if(confirm('确定要删除选中项吗？')){
			openWindow("about:blank","win",450,200,"no");
			theForm.target="win";
		} else {
			return false;
		}
	}
	if (action == "expire") {
			openWindow("about:blank","win",450,200,"no");
			theForm.target="win";
	}
	return true;
}

//用于链接多项功能操作,参数为（form,action,是否验证form,是否有多项数据,是否需要授权）
function exec_link(theForm,action,va_flag,mu_flag,au_flag)
{
	theForm.act.value = action;
	
	if(va_flag){
		if(!validateForm(theForm)){
			return false;
		}
	}
	
	if(mu_flag){
		if(!CheckOptions(theForm))
		{
			alert("请至少选择一项要操作的数据！");
			return false;
		}
	}
	
	if(au_flag){
		return au(theForm);
	} 

	//删除特殊处理
	if (action == "delete") {
		if(confirm('确定要删除选中项吗？')){
			openWindow("about:blank","win",450,200,"no");
			theForm.target="win";
		} else {
			return false;
		}
	}

	theForm.submit();
}

//选中默认删除项
function delit(did) {
	var objs = document.getElementsByName("choice");
	
	if(did!=0){
		for(var i=0; i<objs.length; i++) {
			if(objs[i].value!=did )
				objs[i].checked=false;
			else {
				objs[i].checked=true;
			}
		}
	}
}

//查询
function searchit(myform) {
    myform.act.value = "list";
	myform.elements["pageHelper.currPageNo"].value = 1;
	myform.elements["pageHelper.action"].value = "current";
    myform.submit();
}

//排序
function sortit(myform,sortby,sc) {
    myform.act.value = "list";
	myform.elements["pageHelper.currPageNo"].value = 1;
	myform.elements["pageHelper.action"].value = "current";

 	if ("undefined"!=typeof(myform.sortby))
		myform.sortby.value =sortby;
	if ("undefined"!=typeof(myform.sortsc))
		myform.sortsc.value = sc;
	if ("undefined"!=typeof(myform.fvsortby))
		myform.fvsortby.value =sortby;
	if ("undefined"!=typeof(myform.desc))
		myform.desc.value = sc;

    myform.submit();
}

function openWindow(sDialog,winName,sWidth,sHeight,isScroll) {
	var xx=(window.screen.width-sWidth)/2;
	var yy=(window.screen.height-sHeight)/2;
	window.open(sDialog,winName,"menubar=no,location=no,resizable=yes,scrollbars="+isScroll+",status=no,left="+xx+",top="+yy+",Width="+sWidth+",Height="+sHeight);
}

function addit(page) {
	openWindow(page,"addwin",450,200,"no");
}

function editit(page) { 
	openWindow(page,"modwin",450,200,"no");
}

function SelectTime(obj, hasTime, sPath) {
	if (!obj) return false;
	if (typeof (obj.value) != "string") return false;
	var date = obj.value;
	var thisDate = window.showModalDialog(sPath+"/js/calendar/calendar.htm", new Array(date, hasTime),"dialogHeight:290px;dialogWidth:230px;help:no;status:no;");
	if (typeof (thisDate) != "undefined") obj.value = thisDate.toString();
}

//js得到随机数
function GetRandom()
{
	try
	{
	 var str="A"+(Math.random()*10000000)*10000000*10000+"";
	 return str;
	}
	catch(e)
	{}
}
