<%template _header%>
<%if {infloat}!=1%>
<div id="nav">
	<div class="wrap s_clear"><a href="{config.forumurl}">{config.forumtitle}</a> &raquo; <strong>用户注册</strong></div>
</div>
<%/if%>
<%if {agree}=="" && {infloat}!=1%>
	<%if page_err==0%>
		<%if {config.rules}==1%>
<div class="wrap s_clear">
<div class="main">
<h1>用户注册协议</h1>
<form id="form1" name="form1" method="post" action="" style="margin-left:80px;">
<table cellspacing="0" cellpadding="0" width="100%" align="center" class="formtable">
	<tbody>
	<tr>
		<td>
			<textarea name="textarea" cols="" rows="" readonly="readonly" style="width:600px;height:320px;margin:10px 0;">{config.rulestxt}</textarea>
		</td>
	</tr>
	<tr>
		<td>
		<input name="agree" type="hidden" value="true" />
		<input disabled="disabled" type="submit" id="btnagree" value="我同意" />
		<input name="cancel" type="button" id="cancel" value="不同意" onClick="javascript:location.replace('index.aspx')" />				  
		<script type="text/javascript">
		var secs = 5;
		var wait = secs * 1000;
		$("btnagree").value = "同 意(" + secs + ")";
		$("btnagree").disabled = true;
		for(i = 1; i <= secs; i++) {
			window.setTimeout("update(" + i + ")", i * 1000);
		}
		window.setTimeout("timer()", wait);
		function update(num, value) {
			if(num == (wait/1000)) {
					$("btnagree").value = "同 意";
			} else {
					printnr = (wait / 1000) - num;
					$("btnagree").value = "同 意(" + printnr + ")";
			}
		}
		function timer() {
			$("btnagree").disabled = false;
			$("btnagree").value = "同 意";
		}
		</script>
		 </td>
	 </tr>
	 </tbody>
</table>
</form>
</div>
</div>
		<%csharp%>
		/*
		<script type="text/javascript">
		location.replace('register.aspx?agree=yes')
		</script>
		*/
		<%/csharp%>
		<%/if%>
	<%else%>
		<%template _errmsgbox%>
	<%/if%>
	</div>
<%else%>


<%if {createuser}==""%>

<%if {infloat}!=1%>
<div class="wrap s_clear" id="wrap">
<div class="main" style="padding-left:160px">
<%/if%>
<div class="float" id="floatlayout_register" style="width: 600px; height: 400px;">
	<div style="width: 1800px">
	<div class="floatbox floatbox1">
	<%if {infloat}==1%>
		<h3 class="float_ctrl">
			<span><a href="javascript:;" class="float_close" onclick="floatwin('close_register')" title="关闭">关闭</a></span>
		</h3>
	<%/if%>
		<%if {config.rules}==1%>
		<div class="gateform" id="bbrule" style="display:none">
		<h3>网站服务条款</h3>
		<div  style="margin-bottom:10px">
		<textarea name="textarea" cols="" rows="" readonly="readonly" style="height:230px;width:510px;border:0">{config.rulestxt}</textarea>
		</div>
		<input id="btnagree" type="button" value="我同意" onclick="javascript:$('agree').checked=true;$('bbrule').style.display='none';$('bbreg').style.display=''"/>
		<input name="cancel" type="button" id="cancel" value="不同意" onClick="floatwin('close_register')" />		
		</div>
		<%/if%>
		<div class="gateform" id="bbreg">
		<h3 id="returnregmessage">注册</h3>
		<%if {infloat}==1%>  
		<form id="form2" name="form2" method="post" onsubmit="javascript:$('form2').action='{rooturl}register.aspx?infloat=1&createuser=1&';ajaxpost('form2', 'returnregmessage', 'returnregmessage', 'onerror');return false;" action="{rooturl}register.aspx?infloat=1&createuser=1&">
        <%else%>
		<form id="form1" name="form1" method="post" action="?createuser=1">
		<%/if%>
		<div class="loginform regform">
			<div style="overflow: hidden;overflow-y:auto" class="regform" id="reginfo_a">
				<span id="activation_hidden">
				    <%if {invitecode}!=""||{config.Regstatus}==3%>
                    <label><em>邀请码:</em><input name="invitecode" type="text" id="invitecode" size="20" class="txt" maxlength="7"<%if {invitecode}!=""%> value="{invitecode}" readonly="readonly"<%/if%> /> *</label>
	                <%/if%>
					<label><em>用户名:</em><input type="text" class="txt" tabindex="1"  value="" maxlength="20" size="25" autocomplete="off" name="{config.antispamregisterusername}" id="username" onkeyup="checkusername(this.value);"/> *</label>
					<label><em>密码:</em><input type="password" class="txt" tabindex="1"  id="password" size="25" name="password" onblur="return checkpasswd(this);"/> *</label>				
					<label id="passwdpower" style="display: none;"><em>密码强度</em><strong id="showmsg"></strong></label>
					<label><em>确认密码:</em><input type="password" class="txt" value="" tabindex="1"  id="password2" size="25" name="password2" onblur="checkdoublepassword(this.form)"/> *</label>
					<label><em>Email:</em><input type="text" class="txt" tabindex="1"  id="email" size="25" autocomplete="off" name="{config.antispamregisteremail}" onblur="checkemail(this.value)"/> *</label>
					<%if {config.Realnamesystem}==1%>
					<label><em>真实姓名:</em><input name="realname" type="text" id="realname" size="10" class="txt" /> *</label>
					<label><em>身份证:</em><input name="idcard" type="text" id="idcard" size="20" class="txt" /> *</label>
					<label><em>移动电话:</em><input name="mobile" type="text" id="mobile" size="20" class="txt" /> *</label>
					<label><em>固定电话:</em><input name="phone" type="text" id="phone" size="20" class="txt" /> *</label>
					<%/if%>
				</span>
				<%if {isseccode}%>
				<div class="regsec">
					<label style="display: inline;"><em>验证: </em><span style="position: relative;">
			<%template _vcode%>
		</span></label>
				</div>
				<%/if%>
			</div>
		</div>
		<div class="logininfo singleinfo">
			<h4>已有帐号？<a onclick="floatwin('close_register');floatwin('open_login', this.href, 600, 400, '600,0');return false;" href="{rooturl}login.aspx">现在登录</a></h4>
		</div>
		<p class="fsubmit">
			<span id="reginfo_b_btn">
			<button tabindex="1" value="true" name="regsubmit" type="submit" id="registerformsubmit" class="submit" <%if {config.rules}==1%>onclick="return checkagreed();" <%/if%>>创建用户</button>
			<%if {config.rules}==1%>
			<input type="checkbox" id="agree" value="true" name="agree" class="checkbox" style="margin-left:5px;"/><label for="agreebbrule">同 意<a onclick="javascript:$('bbrule').style.display='';$('bbreg').style.display='none'" href="javascript:;">网站服务条款</a></label>
			   <script type="text/javascript" reload="1">
			        function checkagreed() {
			             if ($('agree').checked == true) {
			                  return true;
			             }
			             else {
			                  $('returnregmessage').innerHTML = "<img src='{imagedir}/check_error.gif'/>请确认《网络服务条款》"; ;
			                  return false;
			             }
			       }
               </script>
			<%/if%>
			</span>
		</p>
		</form>
		</div>
	</div>
	</div>
</div>

</div>
</div>
<script type="text/javascript">
	var PasswordStrength ={
		Level : ["极佳","一般","较弱","太短"],
		LevelValue : [15,10,5,0],//强度值
		Factor : [1,2,5],//字符加数,分别为字母，数字，其它
		KindFactor : [0,0,10,20],//密码含几种组成的加数 
		Regex : [/[a-zA-Z]/g,/\d/g,/[^a-zA-Z0-9]/g] //字符正则数字正则其它正则
		}
		
	PasswordStrength.StrengthValue = function(pwd)
	{
		var strengthValue = 0;
		var ComposedKind = 0;
		for(var i = 0 ; i < this.Regex.length;i++)
		{
			var chars = pwd.match(this.Regex[i]);
			if(chars != null)
			{
				strengthValue += chars.length * this.Factor[i];
				ComposedKind ++;
			}
		}
		strengthValue += this.KindFactor[ComposedKind];
		return strengthValue;
	} 

	PasswordStrength.StrengthLevel = function(pwd)
	{
		var value = this.StrengthValue(pwd);
		for(var i = 0 ; i < this.LevelValue.length ; i ++)
		{
			if(value >= this.LevelValue[i] )
				return this.Level[i];
		}
	}

	function checkpasswd(o)
	{
		var pshowmsg;
		if(o.value.length<6)  {
		   pshowmsg="<span>不得少于6个字符</span>";
		} 
		else
		{
		 
		   var showmsg=PasswordStrength.StrengthLevel(o.value);
		   switch(showmsg) {
		   case "太短": showmsg+=" <img src='images/level/1.gif' width='88' height='11' />";break;
		   case "较弱": showmsg+=" <img src='images/level/2.gif' width='88' height='11' />";break;
		   case "一般": showmsg+=" <img src='images/level/3.gif' width='88' height='11' />";break;
		   case "极佳": showmsg+=" <img src='images/level/4.gif' width='88' height='11' />";break;
		   }
		   $('passwdpower').style.display='';
		   $('showmsg').innerHTML = showmsg;
		   
		}
		 
		if(pshowmsg!='' &&  pshowmsg!=null && pshowmsg!=undefined)
		{
		$('returnregmessage').innerHTML=pshowmsg;
		$('returnregmessage').className='onerror';
		}
		else
		{
		$('returnregmessage').className='';
		$('returnregmessage').innerHTML='注册';
		}
        
 
	}
	function checkemail(strMail)
	{
		var str;
		if(strMail.length==0) return false; 
		var objReg = new RegExp("[A-Za-z0-9-_]+@[A-Za-z0-9-_]+[\.][A-Za-z0-9-_]") 
		var IsRightFmt = objReg.test(strMail) 
		var objRegErrChar = new RegExp("[^a-z0-9-._@]","ig") 
		var IsRightChar = (strMail.search(objRegErrChar)==-1) 
		var IsRightLength = strMail.length <= 60 
		var IsRightPos = (strMail.indexOf("@",0) != 0 && strMail.indexOf(".",0) != 0 && strMail.lastIndexOf("@")+1 != strMail.length && strMail.lastIndexOf(".")+1 != strMail.length) 
		var IsNoDupChar = (strMail.indexOf("@",0) == strMail.lastIndexOf("@")) 
		if(!(IsRightFmt && IsRightChar && IsRightLength && IsRightPos && IsNoDupChar)) 
		 {
		 str="E-mail 地址无效，请返回重新填写。";
		 }
	    if(str!='' &&  str!=null && str!=undefined)
		{
		$('returnregmessage').innerHTML=str;
		$('returnregmessage').className='onerror';
		}
		else
		{
		$('returnregmessage').className='';
		$('returnregmessage').innerHTML='注册';
		}
	}
	function htmlEncode(source, display, tabs)
	{
		function special(source)
		{
			var result = '';
			for (var i = 0; i < source.length; i++)
			{
				var c = source.charAt(i);
				if (c < ' ' || c > '~')
				{
					c = '&#' + c.charCodeAt() + ';';
				}
				result += c;
			}
			return result;
		}
		
		function format(source)
		{
			// Use only integer part of tabs, and default to 4
			tabs = (tabs >= 0) ? Math.floor(tabs) : 4;
			
			// split along line breaks
			var lines = source.split(/\r\n|\r|\n/);
			
			// expand tabs
			for (var i = 0; i < lines.length; i++)
			{
				var line = lines[i];
				var newLine = '';
				for (var p = 0; p < line.length; p++)
				{
					var c = line.charAt(p);
					if (c === '\t')
					{
						var spaces = tabs - (newLine.length % tabs);
						for (var s = 0; s < spaces; s++)
						{
							newLine += ' ';
						}
					}
					else
					{
						newLine += c;
					}
				}
				// If a line starts or ends with a space, it evaporates in html
				// unless it's an nbsp.
				newLine = newLine.replace(/(^ )|( $)/g, '&nbsp;');
				lines[i] = newLine;
			}
			
			// re-join lines
			var result = lines.join('<br />');
			
			// break up contiguous blocks of spaces with non-breaking spaces
			result = result.replace(/  /g, ' &nbsp;');
			
			// tada!
			return result;
		}

		var result = source;
		
		// ampersands (&)
		result = result.replace(/\&/g,'&amp;');

		// less-thans (<)
		result = result.replace(/\</g,'&lt;');

		// greater-thans (>)
		result = result.replace(/\>/g,'&gt;');
		
		if (display)
		{
			// format for display
			result = format(result);
		}
		else
		{
			// Replace quotes if it isn't for display,
			// since it's probably going in an html attribute.
			result = result.replace(new RegExp('"','g'), '&quot;');
		}

		// special characters
		result = special(result);
		
		// tada!
		return result;
	}

	var profile_username_toolong = '对不起，您的用户名超过 20 个字符，请输入一个较短的用户名。';
	var profile_username_tooshort = '对不起，您输入的用户名小于3个字符, 请输入一个较长的用户名。';
	var profile_username_pass = "<img src='{imagedir}/check_right.gif'/>";

	function checkusername(username)
	{
		var unlen = username.replace(/[^\x00-\xff]/g, "**").length;

		if(unlen < 3 || unlen > 20) {
			$("returnregmessage").innerHTML =(unlen < 3 ? profile_username_tooshort : profile_username_toolong);
			$('returnregmessage').className='onerror';
			return;
		}
		ajaxRead("{rooturl}tools/ajax.aspx?t=checkusername&username=" + escape(username), "showcheckresult(obj,'" + escape(username) + "');");
	}

	function showcheckresult(obj, username)
	{
		var res = obj.getElementsByTagName('result');
		var result = "";
		if (res[0] != null && res[0] != undefined)
		{
			if (res[0].childNodes.length > 1) {
				result = res[0].childNodes[1].nodeValue;
			} else {
				result = res[0].firstChild.nodeValue;    		
			}
		}
		if (result == "1")
		{
		    var tips="对不起，您输入的用户名 \"" + htmlEncode(unescape(username), true, 4) + "\" 已经被他人使用或被禁用。";
			$('returnregmessage').innerHTML=tips;
			$('returnregmessage').className='onerror';
		}
		else
		{
			$('returnregmessage').className='';
			 $('returnregmessage').innerHTML='注册';
		}
	}

	function checkdoublepassword(theform)
	{
	  var pw1 = theform.password.value;
	  var pw2 = theform.password2.value;
	  if(pw1=='' &&  pw2=='')
	  {
	  return;
	  }
	  var str;
	  
		 if(pw1!=pw2)
		 {
		  str ="两次输入的密码不一致";
		 }
		  if(str!='' &&  str!=null && str!=undefined)
		  {
		  $('returnregmessage').innerHTML=str;
		  $('returnregmessage').className='onerror';
		  }
		  else
		  {
		  $('returnregmessage').className='';
		  $('returnregmessage').innerHTML='注册';
		  }
	}
	</script>
	<script type="text/javascript"  src="{jsdir}/ajax.js"></script>
<%else%>
<%if {createuser}!=""%>
    <%if {infloat}==1%>
	<%if page_err==0%>
	<script>
	$('form2').style.display='none';
	$('returnregmessage').className='';
	</script>
		<div class="msgbox">
			<h1>{config.forumtitle}　提示信息</h1>
			<p>{msgbox_text}</p>
			<%if {msgbox_url}!=""%>
			<h1><a href="javascript:;" onclick="location.reload()">如果长时间没有响应请点击此处</a></h1>
			<script>setTimeout('location.reload()', 3000);</script>
			<%/if%>
		</div>
	<%else%>
	<p>{msgbox_text}</p>
	<%/if%>
	<%else%>
		<%if page_err==0%>
		<%template _msgbox%>
		<%else%>
		<%template _errmsgbox%>
		<%/if%>
	<%/if%>
<%/if%>
<%/if%>
<%/if%>
<%template _copyright%>
<%template _footer%>