<!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">
	<form id="frmForget" method="post">
	<input type="hidden" name="action" value="sendmail" />
		<div class="regist_content">
			<div class="regist_left">
				<div class="mt10 f16">请输入以下资料中的一项</div>
				<div class="mt30">
					<dl class="cc">
						<dt><label><input type="radio" name="gettype" id="typeemail" value="email" checked="checked">&nbsp;电子邮箱：</label></dt>
						<dd class="box ip"><input type="text" name="email" id="email" class="input" autocomplete="off" onkeyup="$('#emailinfo').html('')" value="{?$Saxue.get.email?}" /></dd>
						<dd class="tp red"><div id="emailinfo"></div></dd>
					</dl>
					<dl class="cc">
						<dt><label><input type="radio" name="gettype" id="typeuname" value="uname">&nbsp;会员帐号：</label></dt>
						<dd class="box ip"><input type="text" name="uname" id="uname" class="input" autocomplete="off" onkeyup="$('#unameinfo').html('')" value="{?$Saxue.get.uname?}" /></dd>
						<dd class="tp red"><div id="unameinfo"></div></dd>
					</dl>
				</div>
				<div class="mt30 f16">请输入图片中的验证码</div>
				<div class="mt30">
					<dl class="cc">
						<dt>验  证  码：</dt>
						<dd class="box ip">
							<input type="text" name="checkcode" id="checkcode" class="input w90" maxlength="4" autocomplete="off" onkeyup="$('#checkcodeinfo').html('')" />&nbsp;
							<img src="/api/checkcode.php" style="cursor:pointer;" align="absmiddle" id="codepic" onclick="this.src='/api/checkcode.php?rand='+Math.random();">
						</dd>
						<dd class="tp red"><div id="checkcodeinfo"></div></dd>
					</dl>
				</div>
				<dl>
					<dt>&nbsp;</dt>
					<dd class="btn-dialog"><span class="btn"><input type="submit" value="发送确认码" /></span></dd>
				</dl>
				<div style="height:50px"></div>
			</div>
			<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>   
    </form>
</div> 
{?include file = "member/footer.html"?}
<script language="javascript" type="text/javascript">
$(function() {
	$("input[type=radio][name=gettype]").each(function(index,el){
		$(this).click(function(){
        	refreshTips($(this).val());
        });
	});
	{?if $Saxue.get.uname!=''?}refreshTips('uname');{?else?}refreshTips('email');{?/if?}
	$("#frmForget").ajaxForm({
		beforeSubmit : function(){
			if (getType()=='email'){
				var email = $('#email').val();
				if(email.replace(/\s+/g,"") == ""){
					$('#emailinfo').html('<img src="{?$saxue_skin_url?}/images/icon/error.png" align="absmiddle"> 请填写电子邮箱。');
					$('#email').focus();
					return false;
				}
				var myReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
				if(!myReg.test(email)){
					$('#emailinfo').html('<img src="{?$saxue_skin_url?}/images/icon/error.png" align="absmiddle"> 电子邮箱格式错误。');
					$('#email').focus();
					return false;
				}
				$('#emailinfo').html('<img src="{?$saxue_skin_url?}/images/icon/right.png" align="absmiddle">');
			}else if (getType()=='uname'){
				var uname = $('#uname').val();
				if(uname.replace(/\s+/g,"") == ""){
					$('#unameinfo').html('<img src="{?$saxue_skin_url?}/images/icon/error.png" align="absmiddle"> 请填写会员帐号。');
					$('#uname').focus();
					return false;
				}
				var myReg = /^[\u4E00-\u9FA5\uF900-\uFA2D_\w]+$/;
				if(!myReg.test(uname)){
					$('#unameinfo').html('<img src="{?$saxue_skin_url?}/images/icon/error.png" align="absmiddle"> 会员帐号格式错误。');
					$('#uname').focus();
					return false;
				}
				$('#unameinfo').html('<img src="{?$saxue_skin_url?}/images/icon/right.png" align="absmiddle">');
			}
			var checkcode = $('#checkcode').val();
			checkcode = checkcode.replace(/\s+/g,"");
			if(checkcode == "" || checkcode.length!=4){
				$('#checkcodeinfo').html('<img src="{?$saxue_skin_url?}/images/icon/error.png" align="absmiddle"> 请填写验证码。');
				$('#checkcode').focus();
				return false;
			}
			$('#checkcodeinfo').html('<img src="{?$saxue_skin_url?}/images/icon/right.png" align="absmiddle">');
		},
        dataType: "json",
        success : function(data){
			if(data.flag == 0){
				$('#'+data.type+'info').html('<img src="{?$saxue_skin_url?}/images/icon/error.png" align="absmiddle"> '+data.msg);
				$('#codepic').attr('src','/api/checkcode.php?rand='+Math.random());
			}else{
				window.location.href='forget.php?action=mailsuccess&gettype='+data.type;
			}
        }
    });
});
function getType(){
	var type = $("input[@type='radio'][@name='gettype']:checked").val();
	if(!type || (type!='email' && type!='uname')) type = 'email';
	return type;
}
function refreshTips(type){
	$("#checkcodeinfo").html("");
	if(!type || (type!='email' && type!='uname')) type = getType();
	if(type!='email') disableTip("email");
	if(type!='uname') disableTip("uname");
	enableTip(type);
}
function enableTip(fieldid){
	$("#"+fieldid).removeAttr("disabled");
	$("#"+fieldid).focus();
	$("#type"+fieldid).attr("checked",true);
}
function disableTip(fieldid){
	$("#"+fieldid).val("");
	$("#"+fieldid).attr("disabled","disabled");
	$("#"+fieldid+'info').html("");
}
</script>
</body></html>
