var FrontJobs_search01 = {
	patternDate :/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/,
    patternCurrency :/^\d{1,8}(\.\d{0,2})?$/,
	/**
	 * 职位搜索验证函数。
	 * @param 1.compId 组件id
	 * @param 2.searchForm 页面提交的表单，主要用来匹配关键字，工作地点，和类型。 
	 * @param 3.needCheckNull  是否进行非空校验  
	 * @param 4.openMode  打开方式  
	 * 
	 */	
	searchOffers:function(compId , searchForm,needCheckNull,openMode){
		
		var queryName = searchForm.keywordsInput;
		
		var initName = searchForm.initName.value;
		var initLocal = searchForm.initLocal.value;
		//日期搜索校验
		var checkPublishDate =FrontJobs_search01.isCheckPublishDate(compId);
		//职位类型id
		var offertypeid = '';
		//判断工作地区是否合法变量
		var checkSpecial = true;
		
		var checkKeywords = FrontJobs_search01.checkText(compId,queryName,needCheckNull,initName);
		
		searchForm.keywords.value = encodeURIComponent(queryName.value);
		
		if(queryName.value == initName){
			searchForm.keywords.value = "";
		}
		
		//工作地区
		var queryLocal = searchForm.workareaInput;
		
		if(queryLocal){
			checkSpecial = FrontJobs_search01.checkText(compId,queryLocal);
			
			searchForm.workarea.value = encodeURIComponent(queryLocal.value);
			
			if(queryLocal.value == initLocal){
				searchForm.workarea.value = "";
			}
		}
		//职位类型
		var offertype = searchForm.offertype;
		
		if(offertype){
			offertypeid = offertype.options[offertype.selectedIndex].value;
		}
		
		var startDate = '';
		var endDate = '';
		if(document.getElementById(compId+"_beginValue")){
			startDate = jQuery("#"+compId+"_beginValue").val();
		}
		
		if(document.getElementById(compId+"_endValue")){
			endDate = jQuery("#"+compId+"_endValue").val();
		}
   
		var url = searchForm.action.replace('keywordsparam',encodeURIComponent(searchForm.keywords.value)).replace('workareaparam',encodeURIComponent(searchForm.workarea.value)).replace('offertypeparam',offertypeid).replace('enddateparam',endDate).replace('startdateparam',startDate);
		//验证都通过才进行提交
		if(checkKeywords && checkSpecial&&checkPublishDate){
			//searchForm.submit();
			//alert(url)
			if(openMode == '1'){
				window.location.href = url;
			}else{
				window.open(url);
			}
			
		}
	},
	isCheckPublishDate:function(compId){
	        //判断开始日期是否错误
	       if (jQuery("#"+compId+"_beginValue").val()
	                && !this.patternDate.test(jQuery("#"+compId+"_beginValue").val())) {
	            alert(i18n_FrontJobs_search01_inputcorrectdate);
	            jQuery("#"+compId+"_beginValue").focus();
	            return false;
	        }
	        //判断结束日期是否错误
	        if (jQuery("#"+compId+"_endValue").val()
	                && !this.patternDate.test(jQuery("#"+compId+"_endValue").val())) {
	            alert(i18n_FrontJobs_search01_inputcorrectdate);
	            jQuery("#"+compId+"_endValue").focus();
	            return false;
	        }
	        //判断开始日期是否小于截止日期
	         if (jQuery("#"+compId+"_beginValue").val()
	                && jQuery("#"+compId+"_endValue").val()
	                && (jQuery("#"+compId+"_beginValue").val() > jQuery("#"+compId+"_endValue").val())) {
	            alert(i18n_FrontJobs_search01_mustlessenddate);
	            jQuery("#"+compId+"_endValue").focus();
	            return false;
	        }
	        //判断开始日期是否小于当前日期
	         if (jQuery("#"+compId+"_beginValue").val()
	                && jQuery("#nowDate").val()
	                && (jQuery("#"+compId+"_beginValue").val() > jQuery("#nowDate").val())) {
	            alert(i18n_FrontJobs_search01_startlessnowdate);
	            jQuery("#"+compId+"_beginValue").focus();
	            return false;
	        }
	        //判断截止日期是否小于当前日期
	         if (jQuery("#"+compId+"_endValue").val()
	                && jQuery("#nowDate").val()
	                && (jQuery("#"+compId+"_endValue").val() > jQuery("#nowDate").val())) {
	            alert(i18n_FrontJobs_search01_endlessnowdate);
	            jQuery("#"+compId+"_endValue").focus();
	            return false;
	        }
	         return true;
       },
	/**
	 * 校验文本框方法 
	 * @param compId 组件id
	 * @param obj 传入需要校验的对象 
	 * @param needCheckNull 是否要非空校验  
	 * @param initName 请输入关键字
	 */
	checkText:function(compId , obj , needCheckNull , initName){
		
		if( needCheckNull != null && needCheckNull != '' && needCheckNull == 'needkeywords' ){
			if(obj.value == '' || obj.value == initName){
				document.getElementById(compId+obj.id+'Error1').style.display = '';
				return false;
			}
		}
		//特殊字符校验
		//if(hasSpecSymbol(obj.value)){
		//	document.getElementById(obj.id+'Error').style.display = 'block';
		//	return false;
		//}
		return true;
	},
	/**
	 * 清除错误信息 
	 * @param obj传入的待清空对象
	 * @param compId 组件id
	 */
	cleanError:function(compId,obj){
		//document.getElementById(obj.id+'Error').style.display = 'none';
		if(obj.id == 'keywordsInput'){
			document.getElementById(compId+obj.id+'Error1').style.display = 'none';
		}
	}
	
};



