﻿// JScript 文件

document.onkeydown = function(e){
    e = e || window.event;
    var key = e.keyCode || e.which;
    if(key==13){
        doLogin();
        return false;
    }
};
function doLogin(){
    lblMessage.innerHTML="";
    $('output').update('<img src="/images/wait.gif" alt="" /> 正在处理请求...');
    if($('txtAcc').isEmpty() | $('txtPwd').isEmpty() | $('txtVcode').isEmpty()){
        $('output').update('错误！请填写帐号和密码。');
        return;
    }
    var pwd = MD5($F('txtPwd')).toLowerCase();
    var acc = $F('txtAcc');
    var vCode = $F('txtVcode').toLowerCase();
    var rem = $F('rembeAcc');
    req('AccountAjax.Login',{'acc':acc,'pwd':pwd,'vCode':vCode,'rem':rem},
        function(req) {
            acc = req.responseText.evalJSON();
            if(typeof acc == 'string'){
                $('output').update(acc);
                $('btnLogin').disabled = false;
                $('btnLogin').value = '登 陆';
            }else{
                location=location;
            }
            refreshValidator();
        },
        function(){
            $('btnLogin').disabled = true;
            $('btnLogin').value = '请稍等...';
        },
        function(){
            $('btnLogin').disabled = false;
            $('btnLogin').value = '登 陆';
            $('output').update('错误！连接失败。');
            refreshValidator();
        }
    );
}

function refreshValidator(){
    $('Validator').src = '/Validator.aspx#'+new Date().getTime();
}
function showLoginTip(n){
    switch(n){
        case 0:
            $('vcodetip').innerHTML = '点击验证码可以更换验证码';
            break;
    }
}
function hideLoginTip(n){
    switch(n){
        case 0:
            $('vcodetip').innerHTML = '';
            break;
    }
}

