//----bx---
function SaveOrClearAccount(op) {
    if (op == null || op == false) {
        var v = bx.store.cookie.get("_adminloginaccount");
        if (v != "") {
            document.getElementById("txtAccount").value = v;
            document.getElementById("remember").checked = true;
        }
    } else {
        if (document.getElementById("remember").checked) {
            bx.store.cookie.set("_adminloginaccount", document.getElementById("txtAccount").value, 365 * 24 * 60 * 60 * 1000);
        } else {
            bx.store.cookie.clear("_adminloginaccount");
        }
    }
}
var verurl;
function refreshVerification() {
    if (verurl == null) { verurl = document.getElementById("imgVerification").src; }
    document.getElementById("imgVerification").src = verurl + "?" + new Date().getUTCMilliseconds();
    document.getElementById("txtVerification").value = "";
}
function enterSubmit(evt) {
    evt = evt ? evt : (window.event ? window.event : null);
    if (evt.keyCode == 13) {
        document.getElementById("btnEnterSubmit").click();
    }
}
function adminLogin() {
    SaveOrClearAccount(true);
    var unm = document.getElementById("txtAccount").value;
    var pwd = document.getElementById("txtPassword").value;
    var vcode = document.getElementById("txtVerification").value;
    if (unm == "" || pwd == "") {
        alert("用户名或密码不能为空");
        return false;
    }
    if (vcode == "") {
        alert("验证码不能为空");
        return false;
    }
    var isLogin = false;
    $.ajax({
        url: "Login.aspx",
        type: "POST",
        cache: false,
        async: false,
        dataType: "json",
        data: "account=" + unm + "&password=" + pwd + "&imgcode=" + vcode,
        success: function (data) {
            if (data.status == "success") {
                isLogin = true;
                location.href = "ManagerIndex.aspx";
            }
            else if (data.error == "password") {
                alert("用户名或密码错误");
                refreshVerification();
            }
            else if (data.error == "verification") {
                alert("验证码错误");
                refreshVerification();
            }
            else {
                alert("出现未定义的错误");
            }
        }
    })
    return isLogin;
}
window.onload = function () {
    SaveOrClearAccount();
}