$(function(){
	$("#getpwd").bind('click',function(){
		getpwd();
	});
	$("#resetpwd").bind('click',function(){
		resetpwd();
	});
});
function getpwd(){
	var mobile = $("#mobile").val();
	var query = new Object();
	query.mobile = mobile;
	query.mobilecode=$("input[name='sms_code']").val();
	query.code='getpwd';
	$.ajax({
		url:APP+'mobile/Login/resetpwd',
		data:query,
		dataType:'json',
		success:function(obj){
			if(obj.status==1){
				$("#findpwd").hide();
				$("#repwd").show();
				$("input[name='mid']").val(obj.mid);
			}else{
				$.showErr(obj.info,0,'hc');
			}
		}
	});
}
function resetpwd(){
	var password=$("input[name='password']").val();
	if(!password.match(/^[\w]{6,12}$/)){$.showErr('密码格式不正确',0,'hc');return false;}
	var repassword=$("input[name='confirm_pwd']").val();
	if(password!=repassword){$.showErr('两次密码不一致',0,'hc');return false;}
	var mid = $("input[name='mid']").val();
	var password = $("#password").val();
	var confirm_pwd = $("#confirm_pwd").val();
	var query = new Object();
	query.mid = mid;
	query.password = password;
	query.repassword = confirm_pwd;
	query.code='resetpwd';
	$.ajax({
		url:APP+'mobile/Login/resetpwd',
		data:query,
		dataType:'json',
		success:function(obj){
			if(obj.status==1){
				$.showSuccess(obj.info,0,'hc');
				if(obj.url){
					window.location.href=obj.url;
				}
			}else{
				$.showErr(obj.info,0,'hc');
			}
		}
	});
}
