$(function () {
    //提交判断
    $("form").submit(function () {
        $("input[type='text'],input[type='password'],textarea").trigger("blur");
        $("select").trigger("change");

        ///新增方法填写在此///

        /////

        if ($("form span").hasClass("ico-error")) {
            $("input:submit").attr("disabled", false);
            $("input:submit").next("span").attr("class", "point ico-error R");
            $("input:submit").next("span").text("请按照提示正确操作，检查各项填写");
            setInterval(delSubmitBtnMsg, 3000);
            return false;
        } else {
            $("input:submit").attr("disabled", true);
            $("input:submit").next("span").attr("class", "Q");
            $("input:submit").next("span").html("<img src=\"Images/Loading.gif\" align=\"middle\" /> 正在保存…");
        }
    });

    //更新url重写规则
    $("#updateUrlRewrite").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/Navi.ashx",
            data: { 'com': 'updatenavirewrite' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });


    //更新导航缓存
    $("#updateNaviCache").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/Navi.ashx",
            data: { 'com': 'updatenavicache' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });

    //更新页面缓存
    $("#updatePageCache").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/Navi.ashx",
            data: { 'com': 'updatepagecache' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });

    //更新底部链接缓存
    $("#updateBottomLink").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/Bottom.ashx",
            data: { 'com': 'updatecache' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });

    //更新站点配置缓存
    $("#updateSiteConfig").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/SiteConfig.ashx",
            data: { 'com': 'updatecache' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });

    //更新公司信息缓存
    $("#updateCompany").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/Company.ashx",
            data: { 'com': 'updatecache' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });

    //更新友情链接缓存
    $("#updateLink").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/Link.ashx",
            data: { 'com': 'updatecache' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });
    //更新幻灯片缓存
    $("#updateSlide").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/Slide.ashx",
            data: { 'com': 'updatecache' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });
    //更新TAG缓存
    $("#updateTag").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/Tag.ashx",
            data: { 'com': 'updatecache' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });

    //更新TAG缓存
    $("#updateOnlineTools").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/OnlineTools.ashx",
            data: { 'com': 'updatecache' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });

    //更新TAG缓存
    $("#updatePic").click(function () {
        var $obj = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/SwfUpload.ashx",
            data: { 'com': 'uploadthumbnail' },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                $obj.next("span").attr("class", "point ico-remind R");
                $obj.next("span").text("更新中...");
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    $obj.next("span").attr("class", "point ico-via Q");
                    $obj.next("span").text("更新成功");
                    $obj.attr("disabled", true);
                } else {
                    $obj.next("span").attr("class", "point ico-error R");
                    $obj.next("span").text("更新失败");
                    $obj.attr("disabled", false);
                }
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        });
        return false;
    });
})