$(function (){
//	var _widht = document.documentElement.clientWidth;  //屏幕宽
	var _height = document.documentElement.clientHeight; //屏幕高
//	var boxWidth = $(".phone-find2").width();
	var boxHeight = $(".phone-find2").height();
	$(".phone-find2").css({ top: (_height - boxHeight) / 2 +"px"});

		var vc = GetQueryString("vc");
		var state = GetQueryString("state");
		var mobilePhone = GetQueryString("mobilePhone");
		var isPass = false;
		if(mobilePhone.length != 11 || vc.length != 4 ){
			location.href="login.html";
		}
		var valPassword = function (){
			var password = $("#password").val();
			if(password.length==0){
				 $(".msg1").text("密码不能为空");
			}else if(password.length<6){
				$(".msg1").text("密码长度过短,至少六位");
			}else{
				$(".msg1").text("");
			}
		}

		var valPassword2 = function (){
			var password = $("#password").val();
			var password2 = $("#password2").val();
			if(password2.length==0){
				 $(".msg2").text("密码不能为空");
			}else if(password2 != password){
				 $(".msg2").text("两次输入密码不一致");
			}else{
				isPass = true;
				 $(".msg2").text("");
			}
		}
		$("#password").blur(function (){
			valPassword();
		});
		$("#password2").blur(function (){
			valPassword2();
		});
		
		$("#resetPw").click(function (){
			valPassword();
			valPassword2();
			if(isPass == true){
				$.ajax("/ajax/resetPasswordWithMobilePhone",{
					type:"POST",
					 async: false,
					success:function(data){ 
						if(data.success){
							if(data.data == true){
								$.MsgBox.Alert("消息","密码重置成功,3秒后自动调转登录页面!");
								 window.setTimeout(function(){    
				                     location.href="login.html";
				                 }, 3000); 
							}else{
								$(".msg3").text("设置失败,验证码超时");
							}
						}else{
							$(".msg2").text("系统异常!");
							// alert("系统异常!");
						}
					},
					error:function(){$.MsgBox.Alert('message','fail')},
					data:{"vc":vc,"state":state,"mobilePhone":mobilePhone,"pw":$("#password2").val()},
				 	dataType: 'json'
				});
			}
		});
	});