var userNameReturnValue=false;
var pusernameReturnValue=false;
var idCodeReturnValue=false;
var birReturnValue=false;
var telReturnValue=false;
var emailReturnValue=true;
var postalCodeReturnValue=true;
var companypostalcodeReturnValue=true;
var companypostalcodeReturnValue=true;
var faxReturnValue=true;

//验证姓名
function checkUserName(){

	var userName=document.getElementById("username").value;
	var userSpan=document.getElementById("userSpan");
	if(userName.trim()==''){
		userSpan.innerHTML=" 姓名必须填写且不能超过10个字";
		userSpan.className = "special note";		
		userNameReturnValue=false;
	}else{
		userSpan.className = "normal note";	
		userSpan.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
		userNameReturnValue=true;
	}
	
	return userNameReturnValue;
	
}
//验证拼音姓名
function checkpUsername(){
	var pUesrname=document.getElementById("pUesrname").value;
	var puserSpan=document.getElementById("puserSpan");
	var checkPuser=/^[A-Za-z\-]+$/;	
	if(pUesrname.trim()==''){
		puserSpan.innerHTML=" 拼音姓名必须填写";
		puserSpan.className = "special note";	
		pusernameReturnValue=false;
	}else if (!checkPuser.test(pUesrname)) {
		puserSpan.innerHTML=" 请正确填写拼音姓名，请参考zhangsan";
		puserSpan.className = "special note";
		pusernameReturnValue=false;
	}else{
		puserSpan.className = "normal note";
		puserSpan.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
		pusernameReturnValue=true;
	}
	
	return pusernameReturnValue;
}
//验证证件号码
function checkIdCode(){
	var codeDiv=document.getElementById("codeDiv");	
	var idNo=document.getElementById("idNumber").value;
	var idType=document.getElementById("idType").value;
	var codeCheck=/^(\d{15}|\d{18}|\d{17}(\d|X))$/;
	
	if(idType=='1'){
		if(!codeCheck.test(idNo.trim())){
			codeDiv.innerHTML=" 请输入证件号码的正确格式";
			codeDiv.className = "special note";
			idCodeReturnValue=false;
		}else{
			codeDiv.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
			codeDiv.className = "normal note";
			idCodeReturnValue=true;
		}
	}else {
		if(idNo.trim() ==''){
			codeDiv.innerHTML=" 请输入证件号码";
			codeDiv.className = "special note";
		}else{
			codeDiv.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
			codeDiv.className = "normal note";
			idCodeReturnValue=true;
		}
	}
	
}
//验证出生日期
function checkBirthday(){
	var checkDate=/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29))$/;
	var birthday=document.getElementById("birthday").value;
	var birSpan=document.getElementById("birSpan");
	if(birthday.trim()!=''){
		if(!checkDate.test(birthday)||birthday.length!=10){
			birSpan.innerHTML="格式不正确,请参考1983-08-14这种格式写";
			birSpan.className = "special note";
			birReturnValue=false;
		}else{
			birSpan.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
			birSpan.className = "normal note";
			birReturnValue=true;
		}
	}else{
		birSpan.innerHTML=" 出生日期必须填写,请参考1983-08-14这种格式写";
		birSpan.className = "special note";
		birReturnValue=false;
	}
	return birReturnValue;
}
//验证电话

function checkTel(){
	var tel=document.getElementById("tel").value;
	var telSpan=document.getElementById("telSpan");
	if(tel.trim()==''){
		telSpan.innerHTML="电话号码不能空";
		telSpan.className = "special note";
		telReturnValue=false;
	}else if(!phontNumber.test(tel)){
		telSpan.innerHTML=" 格式不正确，请参考021-6********这种格式写";
		telSpan.className = "special note";
		telReturnValue=false;
	}else{
		telSpan.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
		telSpan.className = "normal note";
		telReturnValue=true;
	}
	return telReturnValue;
}
//检查邮箱
function checkEmail(){
	var email=document.getElementById("email").value;
	var emailSpan=document.getElementById("emailDiv");
	if(email.trim() !=''){
			if(!emailVal.test(email.trim())){
				emailSpan.innerHTML=" 请参考san.zhang@163.com这种格式写";
				emailSpan.className = "special note";
				emailReturnValue= false;
			}else{
				emailSpan.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
				emailSpan.className = "normal note";
				emailReturnValue= true;
			}
	}
}
//国籍
function checkNa(){
	var nationality=document.getElementById("nationality").value;
	var nationalitySpan=document.getElementById("nationalityDiv");
	if(nationality.trim()!=""){
		nationalitySpan.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
	}else{
		nationalitySpan.innerHTML=" ";
	}
}
//公司
function checkwordAdd(){
	var company=document.getElementById("company").value;
	var companySpan=document.getElementById("companyDiv");
	if(company.trim()!=""){
		companySpan.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
	}else{
		companySpan.innerHTML=" ";
	}
}
function checkwordTel(){
	var companytel=document.getElementById("companytel").value;
	var companytelSpan=document.getElementById("wordTelDiv");
	if(companytel.trim()!=''){
		if(!phontNumber.test(companytel)){
			companytelSpan.innerHTML=" 格式不正确，请参考021-6********这种格式写";
			companytelSpan.className = "special note";
			companytelReturnValue=false;
		}else{
			companytelSpan.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
			companytelSpan.className = "normal note";
			companytelReturnValue=true;
		}
	}else{
		companytelSpan.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
		companytelSpan.className = "normal note";
		companytelReturnValue=true;
	}
	return companytelReturnValue;
}
function checkcompanypostalcode(){
	var companypostalcode=document.getElementById("companypostalcode").value;
	var companypostalcodeDiv=document.getElementById("companypostalcodeDiv");
	if(companypostalcode.trim()!=''){
		if(isNaN(companypostalcode)){
			companypostalcodeDiv.innerHTML=" 请正确填写邮编";
			companypostalcodeDiv.className = "special note";
			companypostalcodeReturnValue=false;
		}else{
			companypostalcodeDiv.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
			companypostalcodeDiv.className = "normal note";
			companypostalcodeReturnValue=true;
		}
	}else{
		companypostalcodeDiv.innerHTML="";
		companypostalcodeDiv.className = "normal note";
		companypostalcodeReturnValue=true;
	}
	return companypostalcodeReturnValue;
}
function checkaddress(){
	var address=document.getElementById("address").value;
	var addressDiv=document.getElementById("addressDiv");
	if(address.trim()!=""){
		addressDiv.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
	}else{
		addressDiv.innerHTML=" ";
	}
}
function checkpostalCode(){
	var postalCode=document.getElementById("postalCode").value;
	var postalCodeDiv=document.getElementById("postalCodeDiv");
	if(postalCode.trim()!=''){
		if(isNaN(postalCode)){
			postalCodeDiv.innerHTML=" 请正确填写邮编";
			postalCodeDiv.className = "special note";
			postalCodeReturnValue=false;
		}else{
			postalCodeDiv.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
			postalCodeDiv.className = "normal note";
			postalCodeReturnValue=true;
		}
	}else{
		postalCodeDiv.innerHTML="";
		postalCodeDiv.className = "normal note";
		postalCodeReturnValue=true;
	}
	return postalCodeReturnValue;
	
}
function checkfax(){
	var fax=document.getElementById("fax").value;
	var faxSpan=document.getElementById("faxDiv");
	if(fax.trim()!=''){
			if(!phontNumber.test(fax)){
				faxSpan.innerHTML=" 格式不正确,请参考021-6********这种格式写";
				faxSpan.className = "special note";
				faxReturnValue= false;
			}else{
				faxSpan.innerHTML="<img src=../page/frontsystem/images/yes.gif>";
				faxSpan.className = "normal note";
				faxReturnValue= true;
			}
	}else{
		faxSpan.innerHTML="";
		faxSpan.className = "normal note";
		faxReturnValue= true;
	}
	return faxReturnValue;
}
function checkForm(){
  if(userNameReturnValue&&telReturnValue&&emailReturnValue){
   	var form1=document.getElementById("form1");
  	 form1.submit();
  }else{
  	var mesDiv=document.getElementById("mesDiv");
  	mesDiv.className = "special note";
  	mesDiv.innerHTML="请认真核对你填写的资料";
  }
}
