
function submitform(val){
        var m=document.thisForm;
        if (m.searcherName.value=="" && typeof(m.searcherName)=="object"){
            alert("系統提示:請輸入搜索器名稱!");
            m.searcherName.focus();
            return false;
        }
        if(m.searcherName.value.indexOf("'")!="-1"){
        	alert("系統提示:搜索器名稱資料中含有特殊字符,請更正!");
            m.searcherName.focus();
            return false;
        }
        if(getStrCharLen(m.searcherName.value)>50){
        	alert("搜索器名稱資料過長,請更正為50位字符(25位漢字)以下!");
            m.searcherName.focus();
            return false;
        }
        if(getStrCharLen(m.keyWord.value)>50){
        	alert("搜索器關鍵字資料過長,請更正為50位字符(25位漢字)以下!");
            m.keyWord.focus();
            return false;
        }
        if(m.keyWord.value.indexOf("'")!="-1"){
        	alert("系統提示:搜索器關鍵字資料中含有特殊字符,請更正!");
            m.keyWord.focus();
            return false;
        }
        if(document.thisForm.reqDegreeID1.value>document.thisForm.reqDegreeID2.value){
	   		alert("學歷要求區間不合法,請更正!");
	   		document.thisForm.reqDegreeID2.focus();
	   		return false;
   		}
        switch(val){
            case "save":                  //保存
            	if(m.modType.value!="create" && typeof(m.modType)=="object"){
                	m.action="/memberSearch.do?action=create";
                	m.submit();
                	break;
                }
                if(m.modType.value=="update" && typeof(m.modType)=="object"){
                	m.action="/memberSearch.do?action=update";
                	m.submit();
                	break;
                }
            case "saveAndSearch":         //保存並搜索


            	if(m.modType.value!="create" && typeof(m.modType)=="object"){
                	m.action="/memberSearch.do?action=createAndFind";
                	m.submit();
                	break;
                }
                if(m.modType.value=="update" && typeof(m.modType)=="object"){
                	m.action="/memberSearch.do?action=updateAndFind";
                	m.submit();
                	break;
            	}
			case "search":
            	if(m.modType.value!="search" && typeof(m.modType)=="object"){
                	m.action="/memberSearch.do?action=search";
                	m.submit();
                	break;
                }
                if(m.modType.value=="save" && typeof(m.modType)=="object"){
                	m.action="/memberSearch.do?action=createAndFind";
                	m.submit();
                	break;
            	}
        }
}
//表單資料提交
function saveSearcher(val){
        var m=document.thisForm;
        if (m.searcherName.value=="" && typeof(m.searcherName)=="object"){
            alert("系統提示:請輸入搜索器名稱!");
            m.searcherName.focus();
            return false;
        }
        if(m.searcherName.value.indexOf("'")!="-1"){
        	alert("系統提示:搜索器名稱資料中含有特殊字符,請更正!");
            m.searcherName.focus();
            return false;
        }
        if(getStrCharLen(m.searcherName.value)>50){
        	alert("搜索器名稱資料過長,請更正為50位字符(25位漢字)以下!");
            m.searcherName.focus();
            return false;
        }
        if(getStrCharLen(m.keyWord.value)>50){
        	alert("搜索器關鍵字資料過長,請更正為50位字符(25位漢字)以下!");
            m.keyWord.focus();
            return false;
        }
        if(m.keyWord.value.indexOf("'")!="-1"){
        	alert("系統提示:搜索器關鍵字資料中含有特殊字符,請更正!");
            m.keyWord.focus();
            return false;
        }
        if(document.thisForm.reqDegreeID1.value>document.thisForm.reqDegreeID2.value){
	   		alert("學歷要求區間不合法,請更正!");
	   		document.thisForm.reqDegreeID2.focus();
	   		return false;
   		}
        switch(val){
            case "create":                  //保存
				m.action="/memberSearch.do?action=create";
				m.submit();
				break;
            case "update":         //保存並搜索


				m.action="/memberSearch.do?action=update";
				m.submit();
				break;
            case "updateAndFind":         //保存並搜索


				m.action="/memberSearch.do?action=updateAndFind";
				m.submit();
				break;
        }
}
//表單資料提交
function searchResume(){
	var m=document.thisForm;
	if(	(thisForm.jobFunction1.value=="" || thisForm.jobFunction1.value=="0") && 
		(thisForm.jobFunction2.value=="" || thisForm.jobFunction2.value=="0") && 
		(thisForm.jobFunction3.value=="" || thisForm.jobFunction3.value=="0") && thisForm.keyWord.value=="") {
		alert("工作崗位和關鍵字至少要填一項！");
		return false;
	}
	if(document.thisForm.reqDegreeID1.value>document.thisForm.reqDegreeID2.value){
		alert("學歷要求區間不合法,請更正!");
		document.thisForm.reqDegreeID2.focus();
		return false;
	}
	if(m.savetosearcher.checked==true) {
		if(m.searcherName.value=="") {
			alert("請輸入搜索器的名稱！");
			document.thisForm.searcherName.focus();
			return false;
		}
		m.action="/memberSearch.do?action=createAndFind";
	}
	else {
		m.action="/memberSearch.do?action=search";
	}
	document.thisForm.SeekerName.value="";
	document.thisForm.target="_blank";
	m.submit();
}
//新增簡歷搜索器
function createSearcher(){
			var m=document.thisForm;
			var searcherCounts=m.searcherCounts;
			
			if(typeof(m)=="object" && typeof(searcherCounts)=="object"){
				if(parseInt(searcherCounts.value)<10){
					document.location.href="/member/memberSearch/memberSearcherCreate.jsp";
				}
				else{
					alert("您最多可建立10個簡歷搜索器,請刪除其中一個然後新增!");
					return false;
				}
			}
}
//刪除簡歷搜索器
function delSearcher(referenceID){
			var m=document.thisForm;
			if(typeof(document.all.selectedID)=="object"){
				document.all.selectedID.value=referenceID;
			}
			if(window.confirm("你確定要刪除此簡歷搜索器嗎?") && document.all.selectedID.value!=""){
				if(typeof(m)=="object"){
					
					m.action="/memberSearch.do?action=delete";
                	m.submit();
                }
			}
}
//修改簡歷搜索器
function editSearcher(refID)
{
	document.thisForm.ID.value=refID;
	document.thisForm.action='/member/memberSearch/memberSearcherUpdate.jsp';
	document.thisForm.submit();
}
//配置已選擇的工作崗位類別


function initJobCategory(){
			var m=document.thisForm;
			var job1=m.jobFunction1;
			var job2=m.jobFunction2;
			var job3=m.jobFunction3;
			var jobList=m.subCatelog;
			var jobSel=m.jobcatelog;
			
			if(chkObj(job1) && job1.value!=""){
				var opt1=document.createElement("OPTION");
				configSelect(job1);
				sel_onchange(m.mainCatalog,m.subCatelog,'jobcatelog');
				for(var i=0;i<jobList.length;i++){
					if(jobList.options[i].value==job1.value){
							//alert(job1.value);
							opt1.value=jobList.options[i].value;
							opt1.text=jobList.options[i].text;
							jobSel.add(opt1);
					}
				}
			}
			if(chkObj(job2) && job2.value!=""){
				var opt2=document.createElement("OPTION");
				configSelect(job2);
				sel_onchange(m.mainCatalog,m.subCatelog,'jobcatelog');
				for(var j=0;j<jobList.length;j++){
					if(jobList.options[j].value==job2.value){
							opt2.value=jobList.options[j].value;
							opt2.text=jobList.options[j].text;
							jobSel.add(opt2);
					}
				}
			}
			if(chkObj(job3) && job3.value!=""){
				var opt3=document.createElement("OPTION");
				configSelect(job3);
				sel_onchange(m.mainCatalog,m.subCatelog,'jobcatelog');
				for(var k=0;k<jobList.length;k++){
					if(jobList.options[k].value==job3.value){
							opt3.value=jobList.options[k].value;
							opt3.text=jobList.options[k].text;
							jobSel.add(opt3);
					}
				}
			}
}
//檢查工作崗位後設定工作崗位下拉菜單
function configSelect(varObj){
			if(varObj.value!="0"){
				var strLocal=varObj.value.substr(0,2)+"00";
				var m=document.thisForm;
				var mainJob=m.mainCatalog;
				if(typeof(m)=="object" && typeof(mainJob)=="object"){
					for(var i=0;i<mainJob.length;i++){
						if(mainJob.options[i].value==strLocal){
							mainJob.options[i].selected=true;
						}
					}
				}
			}
}
//選擇只顯示應屆畢業生時的表單處理
function choosegr() {
    if(thisForm.memberclassflag.checked==true) {
        thisForm.reqWorkYear.disabled=true;
    }
    else {
        thisForm.reqWorkYear.disabled=false;
    }
}
//檢驗一表單是否為對象


function chkObj(varObject){
			if(typeof(varObject)=="object"){
			   return true;
			}
			else{
		       return false;
		}
}

function configLocationC(hideObj,selObj){
			if(typeof(hideObj)=="object" && typeof(selObj)=="object"){
				if(hideObj.value!="" && hideObj.value!="0" && hideObj.value!="undefined"){
					for(var i=0;i<selObj.length;i++){
						if(selObj.options[i].value==hideObj.value){
							selObj.options[i].selected=true;
							break;
						}
					}
				}
			}
}
//頁面載入時配置相關表單

/*
function intiFromData(){
		if(document.thisForm.mainCatalog.value!="0")
		{
			sel_onchange(document.thisForm.mainCatalog,document.thisForm.subCatelog,'jobcatelog');
		}
		initJobCategory();
		var m=document.thisForm;
		if(typeof(m)=="object"){
			//配置簡歷更新日期


			if(typeof(m.resumeUpdatedate)=="object" && typeof(m.resumeUpdatedate)=="object"){
				for(var i=0;i<m.resumeUpdatedate.length;i++){
					if(m.resumeUpdatedate.value==m.resumeUpdatedate.options[i].value){
						m.resumeUpdatedate.options[i].selected=true;
						break;
					}
				}
			}

		}
}*/

/**按個人會員姓名或編號查找簡歷*/
function SearchByName(){  
	var seeker=document.thisForm.SeekerName.value;
	if (seeker.length<1){
	 alert("請填寫求職者的名字或編號!");
	 document.thisForm.SeekerName.focus();
	 return false;
	}
	document.thisForm.SeekerName.value = seeker.toUpperCase();
	document.thisForm.target="_blank";
	document.thisForm.action="/memberSearch.do?action=search";
	document.thisForm.submit();
}
