<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>找回密码 - {?$saxue_sitename?}</title>
<meta name="keywords" content="{?$meta_keywords?}" />
<meta name="description" content="{?$meta_description?}" />
<link rel="stylesheet" href="{?$saxue_skin_url?}/css/gen.css" />
<link rel="stylesheet" href="{?$saxue_skin_url?}/css/register.css" />
<script type="text/javascript" src="{?$saxue_skin_server?}/lib/jquery.min.js"></script>
<script type="text/javascript" src="{?$saxue_skin_server?}/lib/jquery.form.js"></script>
</head>
<body>
{?include file = "topbar.html"?}
<div class="header mt15">
	<h1 class="fl"><a href="{?$saxue_url?}"><img src="{?$saxue_skin_url?}/images/logo.png" alt="{?$saxue_sitename?}"/></a></h1>
	<div class="fl mr10"><span class="logotxt">找回密码</span></div>
</div>
<div class="line"></div>
<div class="wrap">
	<div class="regist_content">
		<form id="frmForget" method="post">
		<input type="hidden" name="action" value="resetpass" />
		<input type="hidden" name="dosubmit" value="1" />
		<input type="hidden" name="data" value="{?$data?}" />
		<div class="regist_left">
			<div class="register_pro" id="register_pro">
				<p class="green">请输入新密码，提交成功后可使用新密码登录{?$saxue_sitename?}</p>
			</div>
			<dl class="cc">
				<dt><label>用户名：</label></dt>
				<dd class="box ip"><span>{?$uname?}</span></dd>
			</dl>
			<dl class="cc">
				<dt><label>新密码：</label></dt>
				<dd class="box ip"><input type="password" name="newpass" id="newpass" class="input" onfocus="showTip(this,'newpass')" onblur="showTips(this,'newpass')" /></dd>
				<dd class="tp"><div id="newpass_info"></div></dd>
			</dl>
			<dl class="cc">
				<dt><label>重复新密码：</label></dt>
				<dd class="box ip"><input type="password" name="repass" id="repass" class="input" onfocus="showTip(this,'repass')" onblur="showTips(this,'repass')" /></dd>
				<dd class="tp"><div id="repass_info"></div></dd>
			</dl>
			<dl>
				<dt>&nbsp;</dt>
				<dd class="btn-dialog"><span class="btn"><input type="submit" value="重设密码" /></span></dd>
			</dl>
			<div style="height:150px"></div>
		</div>
		</form>
		<div class="regist_right">
    			<p><a href="register.php" style="font-size:14px;color:blue">注册新账号</a></p>
				<p>使用合作网站账号登录：</p>
				<p>
					<a href="javascript:;" title="使用QQ帐号登录" class="account_qq j-login-qq">用QQ帐号登陆</a>
					<a href="javascript:;" title="使用微博帐号登录" class="account_sinaweibo j-login-weibo">用微博帐号登陆</a>
				<p>
				<p><br><img src="{?$saxue_skin_url?}/images/member/register-pic.png"><p>
		</div>
	</div>
</div> 
<script language="javascript" type="text/javascript">
var regminpwd 	= parseInt('{?$config.regminpwd?}');
var regmaxpwd 	= parseInt('{?$config.regmaxpwd?}');
var regnpdifferf= parseInt('{?$config.regnpdifferf?}');
var pwdcomplex	= '{?$config.regchrpwd?}';
var newpassInfo = new Array(
		" ",
		"密码设置错误，密码中必须包含小写字母",
		"密码设置错误，密码中必须包含大写字母",
		"密码设置错误，密码中必须包含数字",
		"密码设置错误，密码中必须包含符号",
		"密码设置错误，密码长度太短",
		"密码设置错误，密码太长",
		"密码设置错误，密码不允许和用户名相同",
		"密码设置错误，密码不允以下字符:\ & ' \" ! / * , < > % # ?。",
        getPwdRule());
var repassInfo = new Array(
		" ",
		"两次输入的密码不一致。",
		"请再输入一遍您上面填写的密码");
function getObj(id) {
	return document.getElementById(id);
}
function showTips(obj,type) {
	var key;
	if( type == 'newpass' ) {
		key = checkPwd(obj);
	} else {
		key = checkPwdRepeat(obj);
	}
	if( parseInt(key) == 0 ) {
		getObj(obj.id + '_info').innerHTML = '<img src="{?$saxue_skin_url?}/images/icon/right.png" align="absmiddle">';
	} else {
		getObj(obj.id + '_info').innerHTML = '<img src="{?$saxue_skin_url?}/images/icon/error.png" align="absmiddle">&nbsp;'+eval(obj.id + 'Info')[key];
	}
	return key;		
}
function showTip(obj,type) {
	var lastid = eval(obj.id + 'Info').length - 1;		
	if(eval(obj.id + 'Info')[lastid] != '') {
		getObj(obj.id + '_info').innerHTML = eval(obj.id + 'Info')[lastid];
	}	
}
function checkAll() {
	var ispwd = showTips(getObj('newpass'), 'newpass');
	var ispwdrepeat = showTips(getObj('repass'), 'repass');
	if (ispwd == 0 && ispwdrepeat == 0) return true;
	return false; 
}
function checkPwd(obj) {
	var pwd = obj.value;
	if(pwd.length<regminpwd){
		return 5;
	}else if(regmaxpwd>0 && pwd.length>regmaxpwd) {
		return 6;
	}else if(regnpdifferf>0 && '{?$uname?}'==pwd) {
		return 7;
	}
	if(/[\\/\&\'\"\*\,<>#\?% ]/.test(pwd)){
		return 8;
	}
	if (pwdcomplex!=''){
		var rule = pwdcomplex.split(',');
		var pwdReg;
		for(var i=0;i<rule.length;i++){
			switch(Number(rule[i])){
				case 1:
					pwdReg = /[a-z]/;
					if(!pwdReg.test(pwd)) return 1;
					break;
				case 2:
					pwdReg = /[A-Z]/;
					if(!pwdReg.test(pwd)) return 2;
					break;
				case 3:
					pwdReg = /[0-9]/;
					if(!pwdReg.test(pwd)) return 3;
					break;
				case 4:
					pwdReg = /[^a-zA-Z0-9]/;
					if(!pwdReg.test(pwd)) return 4;
					break;
				default:
					break;
			}
		}
	}
	var pwdRepeat = getObj('repass');
	if(pwdRepeat.value && checkPwdRepeat(pwdRepeat)){
	    getObj('repass_info').innerHTML = '<img src="{?$saxue_skin_url?}/images/icon/error.png" align="absmiddle"> '+repassInfo[1];
	}
	return 0;
}
function checkPwdRepeat(obj){
	if (obj.value==getObj('newpass').value && obj.value.length > 0) {
		return 0;
	} else {
		return 1;
	}
}
function getPwdRule(){
	var intiString 	= "";
	if(regminpwd){
		intiString 	+= "最小长度:"+regminpwd+" ";
	}
	if(regmaxpwd){
		intiString 	+= "最大长度:"+regmaxpwd+" ";
	}
	if(!pwdcomplex){
		return intiString;
	}
	var addString 	= " 必须包含:";
	var rule = pwdcomplex.split(',');
	for(var i=0;i<rule.length;i++){
		switch(Number(rule[i])){
			case 1:
				addString += "小写字母 ";
				break;
			case 2:
				addString += "大写字母 ";
				break;
			case 3:
				addString += "数字 ";
				break;
			case 4:
				addString += "符号 ";
				break;
			default:
				break;
		}
	}
	return intiString + addString;
}
$(function(){
	$("#frmForget").ajaxForm({
		beforeSubmit : function(){
			var check = checkAll();
			if (!check){
				return false;
			}
		},
        dataType: "json",
        success : function(data){
			if(data.flag == 0){
				alert(data.msg);
			}else{
				alert('重设密码成功，请使用您的新密码登录');
				window.location.href='login.php';
			}
        }
    });
})
</script>
{?include file = "member/footer.html"?}
</body></html>
