




//分页提交
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("/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('确定要删除选中项吗？')){//Are you sure to delete the selected item?
			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("请至少选择一项要操作的数据！");//Please select at least one item！
			return false;
		}
	}
	
	if(au_flag){
		return au(theForm);
	} 

	//删除特殊处理
	if (action == "delete") {
		if(confirm('确定要删除选中项吗？')){//Are you sure to delete the selected item?
			openWindow("about:blank","win",450,200,"no");
			theForm.target="win";
			
		} else {
			return false;
		}
	}

	theForm.submit();
}

//用于多项功能操作,参数为（form,action,是否验证form,是否有多项数据,是否需要授权）
function exec_op(theForm,action,va_flag,mu_flag,au_flag)
{
	theForm.action.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);
	} 

	return true;
}

//选中默认删除项
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;
	if ("undefined"!=typeof(myform.bvsortby))
		myform.bvsortby.value =sortby;
	if ("undefined"!=typeof(myform.bvdesc))
		myform.bvdesc.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=yes,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)
	{}
}

//--------------------------------------------------------------

function showHideSection(objectId) {
   if (document.getElementById(objectId) != null) {
        if (document.getElementById(objectId).style.display == "none") {
            document.getElementById(objectId).style.display = "";
            if (document.getElementById(objectId+"Img")) {
                document.getElementById(objectId+"Img").src = "/images/ampic/botton_filter_hide.gif";
            }
        } else {
            document.getElementById(objectId).style.display = "none";
            if (document.getElementById(objectId+"Img")) {
                document.getElementById(objectId+"Img").src = "/images/ampic/botton_filter_show.gif";
            }
        }
	}
}
function showHideFilter(objectId) {
    if (document.getElementById("filterTableImg").src.indexOf("botton_filter_show") > 0) {
        document.getElementById("filterTableImg").src = "/images/ampic/botton_filter_hide.gif";
		 document.getElementById(objectId).style.display = "";
    } else {
        document.getElementById("filterTableImg").src = "/images/ampic/botton_filter_show.gif";
         document.getElementById(objectId).style.display =  "none";
    }
    //document.getElementById("filterControls").style.display = disFilter;
}


function clearFilter(theForm) {
    document.getElementById("searchFilter").value = "";
    document.getElementById("searchPattern").value = "*";
    //document.getElementById("searchAction").click();
    elForm = document.getElementById(theForm);
    iscDeselectAll(theForm);
    elForm.submit();
    document.getElementById("searchAction").click();
}
//全部选中删除复选框
function iscSelectAll(tmpForm,tmpBox) {
	var isDom='ture';
    if (isDom) { theForm = document.forms[tmpForm] }
    else { theForm = document.getElementById(tmpForm) }
    if (!tmpBox) {
        for (i=0;i<theForm.length;i++) {
            if (theForm[i].type == "checkbox") {
                theForm[i].checked = true;
               // findParentRow(theForm.elements[i],"table-row-selected");
            }
        }

    }  else {
        for (i=0;i<theForm.length;i++) {

            if ((theForm[i].type == "checkbox") && (theForm[i].id == tmpBox)) {
                theForm[i].checked = true;
              //  findParentRow(theForm.elements[i],"table-row-selected");
            }
        }
    }

}
//取消全选删除复选框
function iscDeselectAll(tmpForm,tmpBox) {
	var isDom='ture';
    if (isDom) { theForm = document.forms[tmpForm] }
    else { theForm = document.getElementById(tmpForm) }

    if (!tmpBox) {
        for (i=0;i<theForm.length;i++) {
            if (theForm[i].type == "checkbox") {
                theForm[i].checked = false;
               // findParentRow(theForm.elements[i],"table-row");
            }
        }
    }  else {
        for (i=0;i<theForm.length;i++) {

            if ((theForm[i].type == "checkbox") && (theForm[i].id == tmpBox)) {
                theForm[i].checked = false;
                //findParentRow(theForm.elements[i],"table-row");
            }
        }
    }
}

function deleteCkeckedIteam(theForm){
	theForm=document.forms[0];
	theForm.act.value="delete";

	//if(!validateForm(theForm)){
	//	return false;
	//}

	if(!CheckOptions(theForm))
	{
		alert("请至少选择一项要操作的数据!！");//
		return false;
	}
	//return au(theForm);
	if(confirm('确定要删除选中项吗？')){//
//		alert("act"+theForm.act.value);
		
		openWindow("about:blank","win",450,200,"no");

		theForm.target="win";

		//theForm.submit();
	} else {
		return false;
	}
	theForm.submit();
}