$(function () {


    //删除职位
    $("a[rel='del']").click(function () {
        var $delObject = $(this);
        if (confirm("确定要删除 [ " + $delObject.attr("title") + " ] 吗？")) {
            $.ajax({
                type: "POST",
                url: "Ajax/Job.ashx",
                data: { 'com': 'deljob', 'jid': $delObject.attr("href"), 'title': $delObject.attr("title")},
                datatype: "json",
                beforeSend: function (data, textStatus) {
                    showMsg("[ " + $delObject.attr("title") + " ] 正在删除中..", true);
                },
                success: function (data, textStatus) {
                    if (data == "1") {
                        $delObject.parent().parent("tr").remove();
                    } else {
                        alert("删除失败!");
                    }
                    showMsg("", false);
                },
                error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
            })
        }
        return false;
    });

    //操作属性
    $("a[rel='attribute']").click(function () {
        var $Object = $(this);
        var nowID = $Object.attr("name");
        var numberID = $Object.attr("href");
        $.ajax({
            type: "POST",
            url: "Ajax/Job.ashx",
            data: { 'com': 'attribute', 'jid': $Object.attr("rev"), 'number': numberID, 'now': nowID, 'log': $Object.text() + "《" + $Object.attr("title") + "》" },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                showMsg("[ " + $Object.attr("title") + " ] 正在改变属性中 ", true);
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    var retText = "";
                    switch (numberID) {
                        case "1":
                            retText = "头条";
                            break;
                        case "2":
                            retText = "推荐";
                            break;
                        case "3":
                            retText = "置顶";
                            break;
                    }

                    if (nowID == "0") {
                        $Object.attr("name", "1");
                        $Object.text("取消" + retText);
                        $Object.attr("class", "Q underline");

                    } else {
                        $Object.attr("name", "0");
                        $Object.text(retText);
                        $Object.attr("class", "F underline");
                    }
                } else {
                    alert("操作失败!");
                }
                showMsg("", false);
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        })

        return false;
    });

});