$(function () {

    //查询
    $("#serach_Btn").click(function () {
        var para = "";
        if ($("#s_memberName").val() != "") para += "&membername=" + $("#s_memberName").val();
        if ($("#s_key").val() != "") para += "&key=" + $("#s_key").val();
        location.href = $(this).attr("href") + para;
        return false;
    })

    //显示全部留言
    $("a[rel='showAllContent']").click(function () {
        $(this).prev().text($(this).attr("rev"));
        $(this).remove();
        return false;
    })

    //审核评论
    $("a[rel='audit']").click(function () {
        var $object = $(this);
        $.ajax({
            type: "POST",
            url: "Ajax/Product.ashx",
            data: { 'com': 'auditreview', 'pid': $object.attr("rev"), 'now': $object.attr("href"), 'nickname': $object.attr("nickname"), 'title': $object.attr("title") },
            datatype: "json",
            beforeSend: function (data, textStatus) {
                showMsg("[ " + $object.attr("title") + " ] 正在审核操作中 ", true);
            },
            success: function (data, textStatus) {
                if (data == "1") {
                    if ($object.attr("href") == "0") {
                        $object.text("[审核]");
                        $object.attr("href", "1");
                        $object.attr("class", "F underline");
                    } else {
                        $object.attr("href", "0");
                        $object.text("[取消审核]");
                        $object.attr("class", "Q underline");
                    }
                } else {
                    alert("审核失败!");
                    $object.text("[审核]");
                }
                showMsg("", false);
            },
            error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
        })

        return false;
    });

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