$(function () {

    $("a").click(function () {
        var href = $(this).attr("href").toLowerCase();
        if (href.indexOf("=del") != -1)//如果存在为删除
        {
            if (confirm("您确定要执行删除操作吗?")) {
                return true;
            }
            else {
                return false;
            }
        }
    });
    function SetDefaultCSS() {
        var allWidth = $("body").css("width").replace("px", "");
        var rightWidth = allWidth - $(".lw").css("width").replace("px", "") - $(".lw").css("margin-right").replace("px", "") - $(".lw").css("margin-left").replace("px", "");
        $(".rw").css("width", (rightWidth - 20) + "px");
    }
    SetDefaultCSS();
    $(window).resize(function () {
        SetDefaultCSS();
    });
    $("form").submit(function () {
        $(this).find("button[type=submit]").addClass("loading").attr("disabled", "disabled");
    });
    $("#accordion .title").click(function () {
        $(this).parent().parent().find("ul").removeClass("show");
        var pul = $(this).parent();
        if (pul.hasClass("show")) {
            pul.removeClass("show");
        } else {
            pul.addClass("show");
        }
    });
    $("#accordion li a").click(function () {
        var SecIndex = $(this).parent().index();
        var FirIndex = $(this).parent().parent().index();
        CommonEventAsyncAjax("/CommAPI/SYS/ManagerMenuCookie.ashx", { "Action": "SetCookie", "CookiesValue": FirIndex + "," + SecIndex }, function (data) {
        });
    });
    CommonEventAjax(5000, "/CommAPI/SYS/ManagerMenuCookie.ashx", { "Action": "GetCookie" }, function (data) {
        var MenuIndex = data.split(",");
        if (MenuIndex.length == 2) {
            SetLeftMenu(MenuIndex[0], MenuIndex[1]);
        }
    });
    function SetLeftMenu(FirIndex, SecIndex) {
        $($($("#accordion ul").get(FirIndex)).addClass("show").children().get(SecIndex)).children().append("&nbsp;&gt;").css("font-weight", "bold");
    }
    $(".msgtit span").click(function () {
        $(this).parent().parent().parent().fadeOut();
    });

    $(".showQzSysMsg").click(function () {
        $("#QzSysMsg").fadeIn();
        CommonEventAjax(10000, "/commapi/sys/softmsg.ashx", {}, function (bdata) {
            var dataTable = eval(bdata);
            var outHtml = "<table>";
            for (var i = 0; i < dataTable.length; i++) {
                outHtml += "<tr><td><div style=\"width:210px;display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;\"><a href=\"http://soft.qzsys.com/article/show_" + dataTable[i].id + ".html\" target=\"_blank\" title=\"" + dataTable[i].Title + "\">" + dataTable[i].Title + "</a></div></td><td>" + dataTable[i].AddTime.split("T")[0] + "</td></tr>";
            }
            outHtml += "<tr><td></td><td><a href=\"http://soft.qzsys.com\" target=\"_blank\">更多...</a></td></table>";
            $(".msglist").html(outHtml);
        });
    });
});