$(function () {
    //删除图片资源
    $("a[rel='delpic']").click(function () {
        var $delObject = $(this);
        if (confirm("确定要" + $delObject.attr("title") + " 吗？")) {
            $.ajax({
                type: "POST",
                url: "Ajax/Resource.ashx",
                data: { 'com': 'delpic', 'filepath': $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") {
                        $("#picNumber").text(parseInt($("#picNumber").text())-1);
                        $delObject.parent().parent("li").remove();
                    } else {
                        alert("删除失败!");
                    }
                    showMsg("", false);
                },
                error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
            })
        }
        return false;
    });


    //删除文件资源
    $("a[rel='delfile']").click(function () {
        var $delObject = $(this);
        if (confirm("确定要" + $delObject.attr("title") + " 吗？")) {
            $.ajax({
                type: "POST",
                url: "Ajax/Resource.ashx",
                data: { 'com': 'delfile', 'filepath': $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") {
                        $("#fileNumber").text(parseInt($("#fileNumber").text()) - 1);
                        $delObject.parent().parent("tr").remove();
                    } else {
                        alert("删除失败!");
                    }
                    showMsg("", false);
                },
                error: function (e) { alert("连接失败,请向Eoyoo官方技术人员反馈!"); }
            })
        }
        return false;
    });

    //播放器层
    $("a[rel='playvideo']").click(function () {
        $object = $(this);


        var showHtml = "";
        showHtml += "<div class=\"title\">视频播放</div>";
        showHtml += "<p>";
        showHtml += "<div style=\"height:280px;\" id=\"videoPlayBox\"></div>";
        showHtml += "</p>";
        $("#ouBox .video").html(showHtml);

        //播放器赋值
        $f("videoPlayBox", "/Plugin/flowplayer/flowplayer-3.2.14.swf", {
            clip: {
                url: $object.attr("href"),
                autoPlay: true,
                autoBuffering: true
            }
        });

        if ($("#ouBox").is(":hidden")) $("#ouBox").slideToggle(60);
        return false;
    });

    //关闭层停止播放
    $("#ouBox a[class='close']").click(function () {
        $f("videoPlayBox").stop();
    })
});