﻿var Prefix = "";
$(function() {
    $("#nva-top div").each(function(i) {
        $(this).bind("mouseover", function() {
            $("#nva-right div").attr("style", "display:none");
            var index = $(this).attr("id");
            $("a", this.parentNode).removeClass("onhovertype");
            $("a", this).addClass("onhovertype");
            index = index.substr(1);
            index = parseInt(index);
            var el = "#nva-right div:nth-child(" + index + ")";
            $(el).attr("style", "display:block;");
        });
    });
    $("#txtUserName").focus(function() {
        if (this.value == "用户名") {
            this.value = "";
        }
    });
    $("#txtPassWord").focus(function() {
        if (this.value == "密码") {
            this.value = "";
        }
    });
    $("#txtUserName").blur(function() {
        if (this.value == "") {
            this.value = "用户名";
        }
    });
    $("#txtPassWord").blur(function() {
        if (this.value == "") {
            this.value = "密码";
        }
    });
    $("#imgLogin").click(function() {
        var username = $("#txtUserName").val();
        if (username == "用户名" || username == "") {
            alert("请输入用户名！");
            return;
        }
        var password = $("#txtPassWord").val();
        if (password == "密码" || password == "") {
            alert("请输入密码！");
            return;
        }
        var strcur = location.href;
        var strUrl = strcur.replace("//", "").split('/');
        if (strcur.indexOf("T8c8.Web") != -1) {
            switch (strUrl.length) {
                case 4:
                    Prefix = "../";
                    break;
                case 5:
                    Prefix = "../../";
                    break;
            }
        }
        else {
            switch (strUrl.length) {
                case 3:
                    Prefix = "../";
                    break;
                case 4:
                    Prefix = "../../";
                    break;
                case 5:
                    Prefix = "../../../";
                    break;
            }
        }

        $.ajax({
            type: "POST",
            url: Prefix + "data/LoginDeal.ashx?username=" + username + "&password=" + password,
            success: function(msg) {
                alert(msg);
                if (msg.indexOf("登陆成功") != -1) {
                    window.location = window.location;
                }
                else if (msg.indexOf("多次登陆失败") != -1) {
                    window.location = Prefix + 'login.aspx';
                }
            }
        });
    });
});
function killErrors() {
    return true;
}
window.onerror = killErrors;