$(document).ready(function(){
//省变化市则跟着变化
	$("#provinceid2").change(function(){
		var provinceid = $("#provinceid2 option:selected").val();
		if(provinceid==""){
			$("#codeByAreaid").empty();
			$("#codeByAreaid").append("<option>请选择</option>");
		}else{
			$.post("userinfo.do",{ operate: "getCity", provinceid: provinceid },function(data){
				var citys = data.split(";");
				$("#codeByAreaid").empty();
				$("#codeByAreaid").append("<option>请选择</option>");
				for(var i = 0; i < citys.length-1; i++)
				{
					var cityss = citys[i].split(",");
					$("#codeByAreaid").append("<option value="+cityss[0]+">"+cityss[1]+"</option>");
				}
			})
		}
	});
	var check = true;
	$("#username").blur(function(){
		if(jQuery.trim(this.value)=="")
		{
			$("#uname").html("<span class='red01'>用户名不能为空！</span>");
			check = false;
		}else{
			var reg = /\w{6,15}/;
			if(this.value.match(reg))
				$.post("./userinfo.do",{operate:'checkUsernameAjax',username:this.value},function(data){
					if(data=='no')
					{
						$("#uname").html("<span class='red01'>该用户名已经被注册！</span>");
						check = false;
					}
					if(data=='yes')
					{
						$("#uname").html("<span class='gray999'>该用户名可以使用！</span>");
						check = true;
					}
				})
			else
			{
				$("#uname").html("<span class='red01'>用户名必须在6-15位之间！</span>");
				check = false;
			}
			}
	})
	$("#password").blur(function(){
		if(jQuery.trim(this.value)=="")
		{
			$("#passw").html("<span class='red01'>密码不能为空！</span>");
			check = false;
		}else{
			var reg = /\w{6,16}/;
			if(this.value.match(reg))
			{
				if(jQuery.trim($("#repassword").val())!=this.value)
				{
					$("#repassw").html("<span class='red01'>两次密码不一致！</span>");
					$("#passw").html("长度为6-16位的字母、数字、下划线组合。");
					check = false;
				}
				else
				{
					$("#passw").html("长度为6-16位的字母、数字、下划线组合。");
					check = true;
				}
			}
			else{
				$("#passw").html("<span class='red01'>密码必须在6-16位之间！</span>");
				check = false;
			}
		}
	})
	$("#repassword").blur(function(){
		if(jQuery.trim(this.value)!=jQuery.trim($("#password").val()))
		{
			$("#repassw").html("<span class='red01'>两次密码不一致！</span>");
			check = false;
		}
		else
		{
			$("#repassw").html("再输入一次登录密码。");
			check = true;
		}
	})
	$("#email").blur(function(){
		var emailReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
		if(this.value.match(emailReg))
		{
			$("#emai").html("用于接受招聘企业的面试通知。");
			check = true;
		}
		else{
			$("#emai").html("<span class='red01'>请输入正确格式的Email！</span>");
			check = false;
		}
	})
	$("#name").blur(function(){
		if(this.value=="")
		{
			check = false;
			$("#nameMessage").html("<span class='red01'>公司名称不能为空！</span>");
		}
		else
		{
			check = true;
			$("#nameMessage").html("<span class='gray999'>请填写完整地公司名称</span>");
		}
	})
	$("#codeByIndustryid").blur(function(){
		if(this.value=="")
		{
			check = false;
			$("#codeByIndustry").html("<span class='red01'> 请选择所属行业！</span>");
		}
		else{
			check = true;
			$("#codeByIndustry").html("用于指引求职者正确地搜索到您的职位信息");
		}
	})
	$("#codeByAreaid").blur(function(){
	
		if(this.value=="" || this.value=="--请选择--" || this.value=="请选择")
		{
			check = false;
			$("#codeByArea").html("*<span class='red01'>请选择地区！</span>");
		}
		else
		{
			check = true;
			$("#codeByArea").html("*");
		}
	})
	$("#codeByProperty").blur(function(){
		if(this.value=="")
		{
			check = false;
			$("#codeByProperty1").html("<span class='red01'>请选择公司性质！</span>");
		}
		else{
			check = true;
			$("#codeByProperty1").html("");
		}
	})
	$("#companysize").blur(function(){
		if(this.value=="")
		{
			check = false;
			$("#companysizeMess").html("* 请选择公司规模！");
		}
		else
		{
			check = true;
			$("#companysizeMess").html("*");
		}
	})
	
	$("#introduction").blur(function(){
		if(this.value=="")
		{	
			check = false;
			$("#introductionMsg").html("<span class='red01'>请填写公司简介！</span>");
		}else if(this.value.length>=1000)		{	
			check = false;
			$("#introductionMsg").html("<span class='red01'>公司简介过长！</span>");
		}
		else
		{
			check = true;
			$("#introductionMsg").html("帮助求职者了解您的企业");
		}
	})
	
	$("#companylinkman").blur(function(){
		if(this.value=="")
		{
			check = false;
			$("#companylinkmanMsg").html("<span class='red01'>请填写公司联系人！</span>");
		}
		else
		{
			check = true;
			$("#companylinkmanMsg").html("用于求职者及时与您取得联系。");
		}
	})
	
	$("#telephone").blur(function(){
		
		if(this.value.length<7)
		{
			$("#telephoneMsg").html("<span class='red01'>请填写规定格式的固定电话</span>");
			check = false;
		}
		else 
		{
			$("#telephoneMsg").html("例：027-87581245");
			check = true;
		}
	})
	$("#fax").blur(function(){
		if(this.value.length>0)
		{
		if(this.value.length<7)
		{
			$("#faxMsg").html("<span class='red01'>请填写规定格式的传真号码</span>");
			check = false;
		}
		else 
		{
			$("#faxMsg").html("例：027-87581245");
			check = true;
		}
		}else
		{
			check = true;
		}
	})
	$("#homepage").blur(function(){
		var urlReg = /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
		if(this.value!="")
		{
			if(this.value.match(urlReg))
			{
				$("#homepageMsg").html("");
				check = true;
			}
			else{
				$("#homepageMsg").html("<span class='red01'>请填写正确格式的主页地址！</span>");
				check = false;
			}
		}
		else{
			$("#homepageMsg").html("");
			check = true;
		}
	})
	$("#postcode").blur(function(){
		var postcodeReg = /^\d{6}$/;
		if(this.value!="")
		{
			if(this.value.match(postcodeReg))
			{
				$("#postcodeMsg").html("");
				check = true;
			}
			else{
				$("#postcodeMsg").html("<span class='red01'>请填写正确格式的邮政编码！</span>");
				check = false;
			}
		}
		else{
			$("#postcodeMsg").html("");
			check = true;
		}
	})
	
	$("#address").blur(function(){
		if(this.value=="")
		{
			$("#addressMsg").html("<span class='red01'>请填写公司地址！</span>");
			check = false;
		}
		else{
			check = true;
			$("#addressMsg").html("用于指引收到您面试通知的求职者到您的企业参加面试。");
		}
	})
	
	
	
	$("#submitReg").click(function(){
		$("#username").focus();
		$("#username").blur(); 
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#password").focus();
		$("#password").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#repassword").focus();
		$("#repassword").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		} 
		$("#email").focus();
		$("#email").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		} 
		$("#name").focus();
		$("#name").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		} 
		$("#codeByIndustryid").focus();
		$("#codeByIndustryid").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#codeByAreaid").focus();
		$("#codeByAreaid").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#codeByProperty").focus();
		$("#codeByProperty").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#companysize").focus();
		$("#companysize").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#introduction").focus();
		$("#introduction").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#companylinkman").focus();
		$("#companylinkman").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#telephone").focus();
		$("#telephone").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#homepage").focus();
		$("#homepage").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#postcode").focus();
		$("#postcode").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		$("#address").focus();
		$("#address").blur();
		if(!check)
		{
			alert("请填写完整！");
			return false;
		}
		if(check)
		{	
			$('#form1').submit();
			return false;
		}
		else
		{
			alert("请填写完整！");
			return false;
		}
		
	})
	/*
	$("#enterDown").chidren().not($("#introduction")).keydown(function(event){
					var currentKey = event.keyCode;
					if(currentKey==13)
					{
						$("#username").focus();
						$("#username").blur(); 
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#password").focus();
						$("#password").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#repassword").focus();
						$("#repassword").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						} 
						$("#email").focus();
						$("#email").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						} 
						$("#name").focus();
						$("#name").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						} 
						$("#codeByIndustryid").focus();
						$("#codeByIndustryid").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#codeByAreaid").focus();
						$("#codeByAreaid").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#codeByProperty").focus();
						$("#codeByProperty").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#companysize").focus();
						$("#companysize").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#introduction").focus();
						$("#introduction").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#companylinkman").focus();
						$("#companylinkman").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#telephone").focus();
						$("#telephone").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#homepage").focus();
						$("#homepage").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#postcode").focus();
						$("#postcode").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						$("#address").focus();
						$("#address").blur();
						if(!check)
						{
							alert("请填写完整！");
							return false;
						}
						if(check)
						{
							$('form:first').submit()
						}
						else
						{
							alert("请填写完整！");
							return false;
						}
						if(check)
						{
							$('form:first').submit()
						}
						else
						{
							alert("请填写完整！");
							return false;
						}
					}
					})*/
	
	
})
//叶辉新加的方法








