<!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 class="userbg">
{?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 method="post" id="register">
    	<input type="hidden" name="action" id="action" value="newuser" />
		<div class="regist_content">
			<div class="regist_left">
    			<p><br></p>
				{?if $config.regacttype == 1?}
				<div class="register_pro" id="register_pro">
					<p class="red">{?$saxue_sitename?}注册采用邮件验证机制，请填写真实邮箱，用来接收验证邮件。</p>
					<span id="reg-close"><a class="reg-close" onclick="$('#register_pro').hide();return false;" href="javascript:void(0)">X</a></span>
				</div>
				{?/if?}
				<dl class="cc">
					<dt><label for="uname">用户名：</label></dt>
					<dd class="box ip"><input type="text" name="uname" id="uname" maxlength="30" class="input" /></dd>
					<dd class="tp"><div id="uname_info"></div></dd>
				</dl>
				<dl class="cc">
					<dt><label for="email">邮箱：</label></dt>
					<dd class="box ip" >
						<input type="text" name="email" id="email" maxlength="30" class="input" autocomplete="off"/>
						<div class="email_tip_list none" id="email_tip_list">
							<span class="f12 ml5">请选择邮箱类型</span>
							<ul>
								<li class="curr"><em></em></li>
								<li><em></em></li>
								<li><em></em></li>
								<li><em></em></li>
								<li><em></em></li>
								<li><em></em></li>
								<li><em></em></li>
							</ul>
						</div>        
					</dd>
					<dd class="tp"><div id="email_info"></div></dd>
				</dl>
				<dl class="cc">
					<dt><label for="password">密码：</label></dt>
					<dd class="box ip"><input type="password" name="password" id="password" maxlength="20" class="input" /></dd>
					<dd class="tp"><div id="password_info"></div></dd>
				</dl>
				<dl class="cc">
					<dt><label for="repassword">确认密码：</label></dt>
					<dd class="box ip"><input type="password" name="repassword" id="repassword" maxlength="20" class="input" /></dd>
					<dd class="tp"><div id="repassword_info"></div></dd>
				</dl>
				{?if $config.regcheckcode == 1?}
				<dl class="cc">
					<dt><label for="checkcode">验证码：</label></dt>
					<dd class="box ip">
						<input type="text" name="checkcode" id="checkcode" maxlength="4" class="input w90" />&nbsp;
						<img src="/api/checkcode.php" style="cursor:pointer;" align="absmiddle" onclick="this.src='/api/checkcode.php?rand='+Math.random();">
					</dd>
					<dd class="tp"><div id="checkcode_info"></div></dd>
				</dl>
				{?/if?}
				<dl class="cc registerclause">
					<dt>&nbsp;</dt>
					<dd class="ip"><label><input type="checkbox" id="registerclause" value="1" name="rgpermit">&nbsp;我已阅读并完全同意 <a checked="checked" class="b" style="cursor:pointer" onClick="javascript:$('#register_rules').toggle();">《注册协议》</a></label></dd>
					<dd class="tp"><div id="registerclause_info"></div></dd>
				</dl>
				<dl class="cc">
					<dt>&nbsp;</dt>
					<dd><div class="register_rules" id="register_rules" style="display:none;">{?$config.regagreement|nl2br?}</div></dd>
				</dl>
				<dl>
					<dt>&nbsp;</dt>
					<dd><input type="submit" class="confirm" value="立即注册" title="立即注册" /></dd>
				</dl>
				<div style="height:50px"></div>
			</div>
   
			<div class="regist_right">
    			<p><br></p>
    			<p>已有{?$saxue_sitename?}账号？请直接登录</p>
				<p><input type="button" class="btn_login" title="登录" value="登录" onClick="location.href='login.php';"/></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> 
<script type="text/javascript" src="{?$saxue_skin_url?}/js/register.js"></script>
<script type="text/javascript">
var MyResult = function(inpID, list){
	this.maillist = new Array('','@qq.com', '@163.com', '@sina.com', '@126.net', '@hotmail.com', '@gmail.com');
	this.inp = document.getElementById(inpID);
	this.list = document.getElementById(list);
	this.tabIndex = 0;
	this.val = null;
	this.realVal=null;
	var t = this;
	this.init = function(){
		document.onclick = function(){
			t.hideRList();
		}
		//文本域的键盘事件
		this.inp.onkeyup = function(event){
			t.realVal=t.val = this.value.replace(/(^\s*)/g, "");
			if (t.val == "") {
				t.hideRList()
			} else {
				var event = event || window.event;
				var keycode = event.keyCode;
				if(keycode==13){
					return false;
				}
				t.showRList(t.val, t.list)
			}
		}
		this.inp.onclick=function(event){
			//alert(event);
			var evt=event||window.event;
			//阻止冒泡
			if (window.event) {
				evt.cancelBubble = true;
			}
			else {
				evt.stopPropagation();
			}
			return false;
		}
	}
	//获取索引值
	this.index = function(currEle, elements){
		for (var i = 0, len = elements.length; i < len; i++) {
			if (elements[i] == currEle) {
				return i;
			}
		}
	}
	this.strlength = function(str) {
		var l = str.length;   
		var n = l; 
		for (var i=0;i<l;i++) {   
			if (str.charCodeAt(i)<0||str.charCodeAt(i)>255) n++ ; //全角字符     
		}   
		return n;
	}
	
	//显示提示层
	this.showRList = function(str, obj){
		obj.style.display = "block";
		//为em赋值
		var j = 0;
		t.each(t.list.getElementsByTagName("em"), function(i){
			if(str.indexOf("@")!=-1){
				var index=str.indexOf("@");
				var str2=str.substr(0,index);
				i.innerHTML = str2 + this.maillist[j];
				if(j>0){
					i.parentNode.style.display = i.innerHTML.indexOf(str.substring(index)) === -1 ? 'none' : 'block';	
				}else{
					i.innerHTML=str;
				}
			}else{	
				i.innerHTML = str + this.maillist[j];
			}
			j++;
		})
		//鼠标滑动事件
		var lis = t.list.getElementsByTagName("li")
		for (var i = 0, len = t.len(); i < len; i++) {
			lis[i].onmouseover = function(){
				var index = t.index(this, lis);
				t.tabSelect(index);
			}
			lis[i].onmousedown = function(e){
				var ev=e||window.event;
				if(ev.preventDefault){
					ev.preventDefault();
				}else{
					ev.returnValue=false;	
				}
				t.inp.value = this.getElementsByTagName("em")[0].innerHTML
				t.hideRList();
				return false;
			}
		}
		
		//键盘事件
		document.onkeydown = function(event){
			var event = event || window.event;
			var keycode = event.keyCode;
			return function(){
				//方位键
				if (keycode == 40 || keycode == 39) {
					t.tabIndex++;
					if (t.tabIndex == t.len()) {
						t.tabIndex = 0;
					}
					t.tabSelect(t.tabIndex);
					var currentEle=t.list.getElementsByTagName("li")[t.tabIndex];
					if(currentEle&&currentEle.style.display=="none"){
						arguments.callee();
					}
				} else if (keycode == 37 || keycode == 38) {
					t.tabIndex--;
					if (t.tabIndex == -1) {
						t.tabIndex = t.len() - 1;
					}
					t.tabSelect(t.tabIndex);
					var currentEle=t.list.getElementsByTagName("li")[t.tabIndex];
					if(currentEle&&currentEle.style.display=="none"){
						arguments.callee();
					}
				}
				if (keycode == 13) {
					//回车
					t.inp.value = t.getElementsByClassName("curr", t.list)[0].getElementsByTagName("em")[0].innerHTML;
					t.hideRList();
					if(event.preventDefault){
						event.preventDefault();
					}else{
						event.returnValue=false;
					}
					return false;
				}
			}();
		}
	}
	//通过ID获取元素
	this.getObj = function(ele){
		return document.getElementById(ele);
	}
	//通过className获取元素
	this.getElementsByClassName = function(classname, parentElement){
		var eles = (parentElement || document.body).getElementsByTagName("*");
		var arr = [];
		for (var i = 0, len = eles.length; i < len; i++) {
			if (eles[i].className.indexOf(classname) != -1) {
				arr.push(eles[i]);
			}
		}
		return arr;
	}
	//each~
	this.each = function(array, callback){
		for (var i = 0, len = array.length; i < len; i++) {
			callback.call(this, array[i], i);
		}
	}
	//li的长
	this.len = function(){
		return t.list.getElementsByTagName("li").length;
	}
	//切换li状态(curr or "")
	this.tabSelect = function(j){
		var lis = t.list.getElementsByTagName("li");
		for (var i = 0, len = lis.length; i < len; i++) {
			lis[i].className = "";
		}
		lis[j].className = "curr";
	}
	//隐藏
	this.hideRList = function(){
		t.list.style.display = "none";
	}
	//url跳转
	this.goUrl = function(href,q,n){//n 1:新窗口打开   否则当前页面打开
		var href=href+q;
		if(!n){
			location.href =href;
		}else{
			window.open(href,"_blank");
		}
		return false;
	}
}
var showmylist = new MyResult("email", "email_tip_list");
showmylist.init();

var charset = 'utf-8';
var regAjaxCheckUrl	= '/member/regcheck.php';
var regminname	= parseInt('{?$config.regminname?}');
var regmaxname	= parseInt('{?$config.regmaxname?}');
var regminpwd 	= parseInt('{?$config.regminpwd?}');
var regmaxpwd 	= parseInt('{?$config.regmaxpwd?}');
var regnpdifferf= parseInt('{?$config.regnpdifferf?}');

var pwdcomplex	= '{?$config.regchrpwd?}';
var inticlass 	= "ignore";
var rightclass	= "correct";
var falseclass	= "wrong";
var loadingclass	= "loading";

var checkboxArray = new Array();
var radioArray	= new Array();
var regInfo 	= new Array();
var regSelects  = new Array();
regInfo[0] 		= new Array(
	"",
	"用户名不能为空",
	"用户名长度错误",
	"此用户名包含不可接受字符或被管理员屏蔽,请选择其它用户名",
	"用户名只能包含英文或者数字",
	"该用户名禁止注册",
	"该用户名已经被注册，请选用其他用户名" ,
	"不能有空格，长度控制在 "+regminname+"-"+regmaxname+" 字符以内 ");
var uname 	= new Element("uname",regInfo[0],"uname_info");

regInfo[1] 		= new Array(
	" ",
	"密码设置错误，密码中必须包含小写字母",
	"密码设置错误，密码中必须包含大写字母",
	"密码设置错误，密码中必须包含数字",
	"密码设置错误，密码中必须包含符号",
	"密码设置错误，密码长度太短",
	"密码设置错误，密码太长",
	"密码设置错误，密码不允许和用户名相同",
	"密码设置错误，密码不允以下字符:\ & ' \" ! / * , < > % # ?。..",
	getPwdRule());
var password 	= new Element("password",regInfo[1],"password_info");

regInfo[2] 		= new Array(
	" ",
	"两次输入的密码不一致。请再输入一次您上面输入的密码",
	"请再输入一遍您上面填写的密码");
var repassword	= new Element("repassword",regInfo[2],"repassword_info");

regInfo[3] 		= new Array(
	" ",
	"请输入您的电子邮箱",
	"电子邮箱格式错误",
	"该电子邮箱已被注册，请更换别的邮箱",
	"电子邮箱不是系统指定的邮箱地址，不能注册",
	"您的电子邮箱域名已被列入黑名单，请换一个再试",
	"请输入正确的电子邮箱地址");
var email 		= new Element("email",regInfo[3],"email_info");
{?if $config.regcheckcode == 1?}
regInfo[4] 	=	new Array(
	" ",
	"验证码错误",
	"请输入验证码"	);
var checkcode 	= new Element("checkcode",regInfo[4],"checkcode_info");
{?/if?}
regInfo[5] 		= new Array(
	"",
	"请先确定已阅读并完全同意条款内容");
var registerclause 	= new Element("registerclause",regInfo[5],"registerclause_info");

function openWin(e){
	var ev=e||window.event;
	var ele=ev.target||ev.srcElement;
	var url=ele.getAttribute("lang");
	window.open(url);
	if(ev.preventDefault){
		ev.preventDefault();
	}else{
		ev.returnValue=false;
	}
}

function getPwdRule(){
	var intiString 	= "";
	if(regminpwd){
		intiString 	+= "最小长度："+regminpwd+"，";
	}
	if(regmaxpwd){
		intiString 	+= "最大长度："+regmaxpwd+"，";
	}
	if(regnpdifferf){
		intiString	+= "密码不能与用户名相同，";
	}
	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(){
	$("#register").ajaxForm({
		beforeSubmit : function(){
			var check = checkAll();
			if (!check){
				return false;
			}
		},
        dataType: "json",
        success : function(data){
			var reff='{?$jumpurl?}';
			if(reff=='' || reff==window.location.href){
				reff='/member/';
			}
			if(data.flag == 0){
				alert(data.msg);
				return false;
			}else if(data.flag == 1){
				alert('注册成功，请使用注册邮箱激活帐号');
			}else if(data.flag == 2){
				alert('注册成功，等待管理员审核帐号');
			}else if(data.flag == 3){
				alert('注册成功，激活邮件发送失败，请联系管理员审核帐号\n\n'+data.msg.replace(/<br[^>]*>/ig, "\n"));
			}else{
				alert('注册完成，请牢记您的帐号和密码');
			}
			window.location.href=reff;
        }
    });
})
</script>
{?include file = "member/footer.html"?}
</body></html>