<?php if (!defined('IN_CONTEXT')) die('access violation error!'); ?>
<script type="text/javascript" language="javascript">
<!--
function on_success(response) {
    var o_result = _eval_json(response);
    if (!o_result) {
        return on_failure(response);
    }
    
    var stat = document.getElementById("loginform_stat");
    if (o_result.result == "ERROR") {
        document.forms["loginform"].reset();
        reload_captcha();
        
        stat.innerHTML = o_result.errmsg;
        return false;
    } else if (o_result.result == "OK") {
        stat.innerHTML = "<?php _e('OK, redirecting...'); ?>";
        
        window.location.href = o_result.forward;
    } else {
        return on_failure(response);
    }
}

function on_failure(response) {
    document.forms["loginform"].reset();
    reload_captcha();
    
    document.getElementById("loginform_stat").innerHTML = "<?php _e('Request failed!'); ?>";
    return false;
}

function reload_captcha() {
    var captcha = document.getElementById("login_captcha");
    if (captcha) {
        captcha.src = "../captcha.php?s=" + random_str(6);
    }
}

$(document).ready(function() {
    $("#login_user").focus();
});
//-->
</script>
<div id="logo"></div>
<div id="in">
	<div id="left"></div>
	<div id="right">
<?php
$loginform = new Form('index.php', 'loginform', 'check_login_info');
$loginform->p_open('frontpage', 'dologin', '_ajax');
?>
	<ul>
        <li><span><?php _e('Username'); ?>: </span><?php echo Html::input('text', 'login_user', '', 'style="width:192px;"', $loginform, 'RequiredTextbox', __('Please input your username!')); ?></li>
        <li><span><?php _e('Password'); ?>: </span><?php echo Html::input('password', 'login_pwd', '', 'style="width:192px;"', $loginform, 'RequiredTextbox',  __('Please input your password!')); ?></li>
        <li><span><?php _e('Security'); ?>: </span><img style="position:relative;top:3px;margin-right:4px;" id="login_captcha" src="../captcha.php" class="captchaimg" border="0" /><?php echo Html::input('text', 'rand_rs', '', 'style="width:52px;"', $loginform, 'RequiredTextbox', __('Please give me an answer!')); ?></li>
        <li><?php echo Html::input('submit', 'bt_login', '','class="button"'); ?></li>
	</ul>
<?php
$loginform->close();
$running_msg = __('Checking user...');
$custom_js = <<<JS
$("#loginform_stat").css({"display":"block"});
$("#loginform_stat").html("$running_msg");
_ajax_submit(thisForm, on_success, on_failure);
return false;

JS;
$loginform->addCustValidationJs($custom_js);
$loginform->writeValidateJs();
?>
	</div>
</div>
<span id="loginform_stat" style="text-align:center;margin-top:28px;	color:#999999;font-family:Arial,Helvetica,sans-serif;display:block;font-size:12px;">欢迎使用</span>
<div id="footer">Copyright © 2010 建站之家All Rights Reserved.</div>
