<!--{template 'default/head'}-->
<script language=javascript>
var loginVerify = parseInt('{$_SET['login_code']}');
loginVerify = isNaN(loginVerify) ? 0 : loginVerify;
function synLogin(js, fun){
	if(js.length == 0) fun();
	else loadJS(js, fun);
}
function CheckForm()
{
	var url = "{$forward_encode}";
	if($('username').value.trim()=="")
	{
		alert("请输入用户名！");
		$('username').focus();
		return false;
	}
	if($('password').value.trim() == "")
	{
		alert("请输入密码！");
		$('password').focus();
		return false;
	}
	if(loginVerify > 0){
		if($('verify_code').value.trim().length != 4){
			alert("请输入验证码！");
			$('verify_code').focus();
			return false;
		}
	}
	$('login_submit').disabled = true;
	removeClassName($('_loading'), 'hidden');
	Form.send('ajaxForm', function(resp){
		var json = evaljson(resp);
		if(json == null || typeof json.status == 'undefined') return alert("服务器异常，请按F5刷新浏览器");
		if(json.status == 200){
			synLogin(json.syn_js, function(){
				window.location.replace(url || "user.php");
			});
		}else if(json.status == 302){
			synLogin(json.syn_js, function(){
				window.location.replace(json.message);
			});
		}else{
			changeVerifyImage();
			if($('verify_code') != null) $('verify_code').value = '';
			alert(json.message);
			addClassName($('_loading'), 'hidden');
			$('login_submit').disabled = false;
		}
	});
	return false;
}
function changeVerifyImage(){
	if($('verify_code_img') != null) $('verify_code_img').src = 'code.php?height=30&bgcolor=ffffff&d='+(new Date()).toString();
	return false;
}
</script>
<div class="cbody">   
	<form name="ajaxForm" id="ajaxForm" method="post" action="user.php?ac=login&forward={$forward}" onSubmit="return CheckForm();" class="label login">
      <p>
			<label for="username" class="f-label">用户名</label><input class="f-text" name="username" type="text" id="username" size="25" value="{$username}">
      </p>
      <p>
        <label for="password" class="f-label">密码</label><input  class="f-text" name="password" type="password" id="password" size="25"> <input type="checkbox" name="cookietime" id="cookietime" value="1" /> <label for="cookietime">记住我</label>
      </p>
	  <!--{if $_SET['login_code']}-->
      <p>
        <label class='f-label'>验证码</label>
        <input name="verify_code" type="text" class="f-text" id="verify_code" size="25" maxlength="4" style="width:50px" /> &nbsp;
		把下面的数字再输入一遍，<a href="###" onclick="return changeVerifyImage()">看不清楚？换一张</a>
      </p>	  
      <p class="note">
        <img title="点击更换图片" src="code.php?height=30&bgcolor=ffffff" onclick="return changeVerifyImage()" id="verify_code_img" />
      </p>	
	  <!--{/if}-->
      <p class='note'>
          <input name="myFormAc" type="hidden" value="update">
          <input type="submit" id="login_submit" class="f-button" value=" 登录！ " /><span id="_loading" class="loading hidden">提交中，请等待...</span>
      </p>
      <p class='note'>
		 <a href="user.php?ac=reg&forward={$forward}">新用户注册</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="user.php?ac=password">忘记密码了？</a>
      </p>
	  </form>
</div>
<!--{template 'default/foot'}-->