/**********************************************************************************************************
作者：杨伟
时间：2011-08-17
描述：主要实现主页动态加载数据

***********************************************************************************************************/
var jq = jQuery.noConflict();
var reply_content = null;
var message = null;
var count = -1;
var indexCount = 0;
var FeverCount = 0;
var typeID = "";
var userName = "";
var Reply_ArticleID = "";
var Reply_ID = "";
var userID = "";
var istrue = false; //标志位
var id = ""; //标示文章的ID
var order = ""; //表示所选择的种类（文本、图片、 链接、视频）
var user = "";
var jqself = ""; //加载热度时传的一个jq（this）

jq(document).ready(function () {
    //初始从后台拿数据化页面，
    
    jq("#mes_warn").show();
    Init();
    jq("#mes_warn").hide(2000);

    jq(".feed-img-thumb.post-some-img.clearfix").show();
    jq(".feed-img-all.post-some-img.clearfix").hide();

    jq(".feed-video-img-holder").show();
    jq(".feed-full-video-wrap.clearfix").hide();


    jq(".feed-one-img").live('click', function () {
        jq(this).parent().hide();
        jq(this).parent().next().show();
    });

    jq(".feed-big-img").live('click', function () {
        jq(this).parent().hide();
        jq(this).parent().prev().show();
    });


    jq(".feed-video-play").live('click', function () {
        jq(this).parent().hide();
        jq(this).parent().parent().prepend(get_parent_video_url(this));
    });
    jq(".feed-video-close").live('click', function () {
        jq(this).parent().parent().next().show();
        jq(this).parent().parent().remove();
    });
    jq("#next-page").live('click', function () {
        next();
    });

});
//滚动条事件，滚动到底部，调用next（）函数，再获取部分数据
jq(window).scroll(function () {
    if (jq(window).scrollTop() == jq(document).height() - jq(window).height()) {
        jq("#load_image").show();
        jq("#load_text").show();       
        next();
        jq("#load_image").fadeOut(2000);
        jq("#load_text").fadeOut(2000);
    }
});

//初始化函数 ajax从后台拿json数据
function Init() {
    jq.post(
                        '/ashx/Dd_index.ashx',
                        {
                            requestType: "1"
                        },
                        function (data) {
                            show(data);
                        }
                     );
}

//再获取数据
function next() {
    jq.post(
                        '/ashx/Dd_index.ashx',
                        {
                            requestType: "2",
                            select_time: this.time.value
                        },
                        function (data) {
                            show(data);
                        }
                       );
}
//将Json数据转化为标签内容
function show(data) {

    var json = eval(data); //把后台的json用eval进行转化成数组

    for (var index in json) {
        switch (json[index].type) {
            case "picture":
                indexCount = json[index].count;
                FeverCount = json[index].feverCount;
                var typeorders = "1";
                jq("#feed-list").append(
                    '<div id="' + json[index].TypeID + '" UserID="' + json[index].UserID + '" class="feed feed-text" data-comment="1" typeOrder="1">'
                    + '<div class="feed-avatar">'
                    + '<a href="#"  id="feed-avatar' + json[index].UserID + json[index].TypeID + typeorders + '" class="blog-avatar" title="'
                    + json[index].blogName
                    + '" style="background-image: url(' + DealUserImg(json[index].TypeID, json[index].UserID , typeorders ) + ');">'
                    + json[index].blogName
                    + '</a>'
                    + '</div>'
                    + '<div class="feed-content-holder pop">'
                    + '<div class="pop-triangle"></div>'
                    + '<div class="pop-content clearfix">'
                    + '<div class="feed-basic">'
                    + '<a class="feed-user" href="#">'
                    + json[index].blogName
                    + '</a>'
                    + '</div>'
                    + '<div class="clear"></div>'
                    + '<div class="feed-ct">'
                    + '<div class="feed-img-thumb post-some-img clearfix" >'
                    + show_small_img(json[index].imageUrl, json[index].discript)
                    + '</div>'
                    + '<div class="feed-img-all post-some-img clearfix" style="display:none;" >'
                    + show_big_img(json[index].imageUrl, json[index].discript)
                    + '</div>'
                    + '</div>'
                    + show_flag(json[index].lable)
                    + '</div>'
                    + '<div class="feed-act">'
                    + show_or_hidden(json[index].UserID)
                    + '</div>'
                    + '</div>'
                    + '<div class="feed-ft J_FeedFooter" style="display:none;" id="feed-ft J_FeedFooter">'
                    + '<div  class="feed-ft-triangle J_FeedFooterTriangle" style="left: 431.85px;">'
                    + '</div>'
                    + '<div class="feed-comment comment">'
                    + '<div class="add-comment clearfix">'
                    + '<textarea id="cmt" class="input-cmt" autocomplete="off">'
                    + '</textarea>'
                    + '<span id="idclick" class="blue-button add-t-btn">'
                    + '发布'
                    + '</span>'
                    + '</div>'
                    + '<div id="Reply drop-down list" >'
                    + '<ul class="cmt-list" style="">'
                    + '</ul>'
                    + '</div>'
                    + '</div>'
                    + '<div class="more-act-holder"></div>'
                    + '</div>'
                     + '<div style="left: 395.5px;" class="feed-ft-triangle J_FeedFooterTriangle" >'
                    + '<s class="outter"></s>'
                    + '<s class="inner"></s>'
                    + '</div>'
                    + '<div class="feed-notes notes" style="display: none;">'
                    + '<div class="feed-notes-body">'
                    + '<ul class="feed-notes-list" id="feed-notes-list">'
                    + '</ul>'
                    + '</div>'
                    + '<a style="color: rgb(103, 140, 178); border-bottom-color: rgb(103, 140, 178); border-bottom-width: 1px; border-bottom-style: solid;" class="J_NotesFolder">收起</a>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    );
                break;
            case "music":
                indexCount = json[index].count;
                FeverCount = json[index].feverCount;
                var typeorders = "2";
                jq("#feed-list").append(
                    '<div id="' + json[index].TypeID + '" UserID="' + json[index].UserID + '" class="feed feed-text" data-comment="1" typeOrder="2">'
                   + '<div class="feed-avatar" >'
                    + '<a href="#" id="feed-avatar' + json[index].UserID + json[index].TypeID + typeorders + '" class="blog-avatar" title="'
                    + json[index].blogName
                    + '" style="background-image: url(' + DealUserImg(json[index].TypeID, json[index].UserID, typeorders) + ');">'
                    + json[index].blogName
                    + '</a>'
                    + '</div>'
                    + '<div class="feed-content-holder pop">'
                    + '<div class="pop-triangle"></div>'
                    + '<div class="pop-content clearfix">'
                    + '<div class="feed-basic">'
                    + '<a class="feed-user" href="#">'
                    + json[index].blogName
                    + '</a>'
                    + '</div>'
                    + '<div class="clear"></div>'

                    + '<div id="deletediv">'
                    + '<application/x-shockwave-flash>'
                    + musicUrl(json[index].musicUrl)
                    + '</div>'

                    + '<p>'
                    + json[index].content
                    + '</p>'
                    + '</h4>'
                    + show_flag(json[index].lable)

                    + '</div>'
                    + '<div class="feed-act">'
                    + show_or_hidden(json[index].UserID)
                    + '</div>'
                    + '</div>'
                    + '<div class="feed-ft J_FeedFooter" style="display:none;" id="feed-ft J_FeedFooter">'
                    + '<div  class="feed-ft-triangle J_FeedFooterTriangle" style="left: 431.85px;">'
                    + '</div>'
                    + '<div class="feed-comment comment">'
                    + '<div class="add-comment clearfix">'
                    + '<textarea id="cmt" class="input-cmt" autocomplete="off">'
                    + '</textarea>'
                    + '<span id="idclick" class="blue-button add-t-btn">'
                    + '发布'
                    + '</span>'
                    + '</div>'
                    + '<div id="Reply drop-down list">'
                    + '<ul  class="cmt-list" style="">'
                    + '</ul>'
                    + '</div>'
                    + '</div>'
                    + '<div class="more-act-holder"></div>'
                    + '</div>'
                    + '<div style="left: 395.5px;" class="feed-ft-triangle J_FeedFooterTriangle" >'
                    + '<s class="outter"></s>'
                    + '<s class="inner"></s>'
                    + '</div>'
                    + '<div class="feed-notes notes" style="display: none;">'
                    + '<div class="feed-notes-body">'
                    + '<ul class="feed-notes-list" id="feed-notes-list">'

                    + '</ul>'
                    + '</div>'
                    + '<a style="color: rgb(103, 140, 178); border-bottom-color: rgb(103, 140, 178); border-bottom-width: 1px; border-bottom-style: solid;" class="J_NotesFolder">收起</a>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    );
                break;
            case "link":
                indexCount = json[index].count;
                FeverCount = json[index].feverCount;
                var typeorders = "3";
                jq("#feed-list").append(
                    '<div id="' + json[index].TypeID + '" UserID="' + json[index].UserID + '" class="feed feed-text" data-comment="1" typeOrder="3">'
                   + '<div class="feed-avatar" >'
                    + '<a href="#" id="feed-avatar' + json[index].UserID + json[index].TypeID + typeorders + '" class="blog-avatar" title="'
                    + json[index].blogName
                    + '" style="background-image: url(' + DealUserImg(json[index].TypeID, json[index].UserID , typeorders) + ');">'
                    + json[index].blogName
                    + '</a>'
                    + '</div>'
                    + '<div class="feed-content-holder pop">'
                    + '<div class="pop-triangle"></div>'
                    + '<div class="pop-content clearfix">'
                    + '<div class="feed-basic">'
                    + '<a class="feed-user" href="#">'
                    + json[index].blogName
                    + '</a>'
                    + '</div>'
                    + '<div class="clear"></div>'
                    + '<h4 class="feed-title"><a href="'
                    + json[index].url
                    + '" target="_blank">'
                    + json[index].title
                    + '</a>'
                    + '<p>'
                    + json[index].discript
                    + '</p>'
                    + '</h4>'
                    + show_flag(json[index].lable)

                    + '</div>'
                    + '<div class="feed-act">'
                    + show_or_hidden(json[index].UserID)
                    + '</div>'
                    + '</div>'
                    + '<div class="feed-ft J_FeedFooter" style="display:none;" id="feed-ft J_FeedFooter">'
                    + '<div  class="feed-ft-triangle J_FeedFooterTriangle" style="left: 431.85px;">'
                    + '</div>'
                    + '<div class="feed-comment comment">'
                    + '<div class="add-comment clearfix">'
                    + '<textarea id="cmt" class="input-cmt" autocomplete="off">'
                    + '</textarea>'
                    + '<span id="idclick" class="blue-button add-t-btn">'
                    + '发布'
                    + '</span>'
                    + '</div>'
                    + '<div id="Reply drop-down list">'
                    + '<ul  class="cmt-list" style="">'
                    + '</ul>'
                    + '</div>'
                    + '</div>'
                    + '<div class="more-act-holder"></div>'
                    + '</div>'
                    + '<div style="left: 395.5px;" class="feed-ft-triangle J_FeedFooterTriangle" >'
                    + '<s class="outter"></s>'
                    + '<s class="inner"></s>'
                    + '</div>'
                    + '<div class="feed-notes notes" style="display: none;">'
                    + '<div class="feed-notes-body">'
                    + '<ul class="feed-notes-list" id="feed-notes-list">'

                    + '</ul>'
                    + '</div>'
                    + '<a style="color: rgb(103, 140, 178); border-bottom-color: rgb(103, 140, 178); border-bottom-width: 1px; border-bottom-style: solid;" class="J_NotesFolder">收起</a>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    );
                break;
            case "text":
                indexCount = json[index].count;
                FeverCount = json[index].feverCount;
                var typeorders = "0";
                jq("#feed-list").append(
                    '<div id="' + json[index].TypeID + '" UserID="' + json[index].UserID + '" class="feed feed-text" data-comment="1" typeOrder="0">'
                    + '<div class="feed-avatar" >'
                    + '<a href="#" id="feed-avatar' + json[index].UserID + json[index].TypeID + typeorders + '" class="blog-avatar" title="'
                    + json[index].blogName
                    + '" style="background-image: url(' + DealUserImg(json[index].TypeID, json[index].UserID , typeorders ) + ');">'
                    + json[index].blogName
                    + '</a>'
                    + '</div>'
                    + '<div class="feed-content-holder pop">'
                    + '<div class="pop-triangle"></div>'

                    + '<div class="pop-content clearfix">'

                    + '<div class="feed-basic">'
                    + '<a class="feed-user" href="#">'
                    + json[index].blogName
                    + '</a>'
                    + '</div>'

                    + '<div class="clear"></div>'

                    + '<h4 class="feed-title">'
                    + json[index].title
                    + '</h4>'
                    + '<div class="feed-ct">'
                    + '<div class="feed-txt-full tich-content">'
                    + '<div class="feed-txt-summary">'
                    + json[index].content
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + show_flag(json[index].lable)

                    + '</div>'
                    + '<div class="feed-act">'
                    + show_or_hidden(json[index].UserID)
                    + '</div>'
                    + '</div>'
                    + '<div class="feed-ft J_FeedFooter" style="display:none;" id="feed-ft J_FeedFooter">'
                    + '<div  class="feed-ft-triangle J_FeedFooterTriangle" style="left: 431.85px;">'
                    + '</div>'
                    + '<div class="feed-comment comment">'
                    + '<div class="add-comment clearfix">'
                    + '<textarea id="cmt" class="input-cmt" autocomplete="off">'
                    + '</textarea>'
                    + '<span id="idclick" class="blue-button add-t-btn">'
                    + '发布'
                    + '</span>'
                    + '</div>'
                    + '<div id="Reply drop-down list">'
                    + '<ul  class="cmt-list" style="">'
                    + '</ul>'
                    + '</div>'
                    + '</div>'

                    + '<div class="more-act-holder"></div>'
                    + '</div>'
                    + '<div style="left: 395.5px;" class="feed-ft-triangle J_FeedFooterTriangle" >'
                    + '<s class="outter"></s>'
                    + '<s class="inner"></s>'
                    + '</div>'
                    + '<div class="feed-notes notes" style="display: none;">'
                    + '<div class="feed-notes-body">'
                    + '<ul class="feed-notes-list" id="feed-notes-list">'

                    + '</ul>'
                    + '</div>'
                    + '<a style="color: rgb(103, 140, 178); border-bottom-color: rgb(103, 140, 178); border-bottom-width: 1px; border-bottom-style: solid;" class="J_NotesFolder">收起</a>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    );
                break;
            case "video":
                indexCount = json[index].count;
                FeverCount = json[index].feverCount;
                var typeorders = "4";
                jq("#feed-list").append(
                    '<div id="' + json[index].TypeID + '" UserID="' + json[index].UserID + '" class="feed feed-text" data-comment="1" typeOrder="4">'
                    + '<div class="feed-avatar" >'
                    + '<a href="#" id="feed-avatar' + json[index].UserID + json[index].TypeID  + typeorders + '" class="blog-avatar" title="'
                    + json[index].blogName
                    + '" style="background-image: url(' + DealUserImg(json[index].TypeID, json[index].UserID,typeorders) + ');">'
                    + json[index].blogName
                    + '</a>'
                    + '</div>'
                    + '<div class="feed-content-holder pop">'
                    + '<div class="pop-triangle"></div>'
                    + '<div class="pop-content clearfix">'
                    + '<div class="feed-basic">'
                    + '<a class="feed-user" href="#">'
                    + json[index].blogName
                    + '</a>'
                    + '</div>'
                    + '<div class="clear"></div>'
                    + '<div class="feed-ct">'
                    + '<div class="feed-video-ct" data=\'[{"flashurl":"'
                    + json[index].videoUrl
                    + '","videourl":"'
                    + get_video(json[index].videoUrl)
                    + '"}]\' >'
                    + '<div class="feed-video-img-holder">'
                    + '<img class="feed-video-img" src="'
                    + json[index].imageUrl
                    + '" >'
                    + '<a class="feed-video-play">播放</a>'
                    + '</div>'
                    + '<div class="feed-video-info">'
                    + '<div class="feed-video-cmt rich-content">'
                    + '<p>'
                    + json[index].discript
                    + '</p>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + show_flag(json[index].lable)

                    + '</div>'
                    + '<div class="feed-act">'
                    + show_or_hidden(json[index].UserID)
                    + '</div>'
                    + '</div>'

                    + '<div class="feed-ft J_FeedFooter" style="display:none;" id="feed-ft J_FeedFooter">'
                    + '<div  class="feed-ft-triangle J_FeedFooterTriangle" style="left: 431.85px;">'
                    + '</div>'
                    + '<div class="feed-comment comment">'
                    + '<div class="add-comment clearfix">'
                    + '<textarea id="cmt" class="input-cmt" autocomplete="off">'
                    + '</textarea>'
                    + '<span id="idclick" class="blue-button add-t-btn">'
                    + '发布'
                    + '</span>'
                    + '</div>'
                    + '<div id="Reply drop-down list">'
                    + '<ul class="cmt-list" style="">'
                    + '</ul>'
                    + '</div>'
                    + '</div>'
                    + '<div class="more-act-holder"></div>'
                    + '</div>'
                    + '<div style="left: 395.5px;" class="feed-ft-triangle J_FeedFooterTriangle" >'
                    + '<s class="outter"></s>'
                    + '<s class="inner"></s>'
                    + '</div>'
                    + '<div class="feed-notes notes" style="display: none;">'
                    + '<div class="feed-notes-body">'
                    + '<ul class="feed-notes-list" id="feed-notes-list">'
                    + '</ul>'
                    + '</div>'
                    + '<a style="color: rgb(103, 140, 178); border-bottom-color: rgb(103, 140, 178); border-bottom-width: 1px; border-bottom-style: solid;" class="J_NotesFolder">收起</a>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    );
                break;
            case "time":
                this.time.value = json[index].time;
                break;
        }
    }
}
//绑定音乐播放器
function musicUrl(url) {
    var input = "<embed wmode='transparent' id='musicflash' name='' style='width: 405px; height: 100px; margin: 0 auto;padding: 0px;' name='musicflash' type='application/x-shockwave-flash' src='" + url + "'>"
                + "</embed>";
    return input;         
}

//显示和隐藏：(回应 喜欢 转载 删除 热度 编辑) 其中个人的权限（回应、编辑、删除）大家的权限为（回应、喜欢、转载、热度）
function show_or_hidden(id) {
    var input = "";
    if (id == user[0]) {
        input = '<a class="feed-del">删除&nbsp;</a>'
                                + '<a class="feed-edit" >编辑&nbsp;</a>'
                                + '<a class="feed-cmt" id="cmt">' + CheckCount(indexCount) + '&nbsp;</a>'
                                + '<a class="feed-nt" id="nt">' + GetFevorCount(FeverCount) + '&nbsp;</a>'
    }
    else {
        input = '<a class="feed-fav" title="喜欢">❤&nbsp;</a>'
                                + '<a class="feed-rt">转载&nbsp;</a>'
                                + '<a class="feed-cmt" id="cmt">' + CheckCount(indexCount) + '&nbsp;</a>'
                                + '<a class="feed-nt" id="nt">' + GetFevorCount(FeverCount) + '&nbsp;</a>'
    }
    return input;
}
//显示回应（1）回应(1)
function CheckCount(count) {
    if (count != 0) {
        message = "回应" + "(" + count + ")";
    }
    else {
        message = "回应";
    }
    return message;
}

//主页回应!当点击回应时显示或隐藏div框。toggle()方法是：显示时隐藏，隐藏时显示！
jq(document).ready(function () {
    jq(".feed-cmt").live('click', function () {
        if (jq(this).parent().parent().next().next().next().css("display") == "none") {
            jq(this).parent().parent().next().toggle();
        }
        else {
            jq(this).parent().parent().next().next().next().css("display", "none");
            jq(this).parent().parent().next().toggle();
        }
    });
});

//构造小图显示
function show_small_img(url, discript) {
    var url_arry = url.split("|");
    var length = url_arry.length;
    var img_box = "";
    for (var index = 0; index < length - 2; index++) {
        img_box += '<div class="feed-one-img"><img width="100" height="100"  src="'
            + url_arry[0] + '/' + url_arry[index + 1]
            + '" class="feed-img"></div>';
    }
    img_box = img_box + '<div class="feed-img-desc">' + discript + '</div>';
    return img_box;

}
//构造视频地址
function get_video(videoUrl) {
    var video = "http://v.youku.com/v_show/id_" + videoUrl.substr(39, 14) + ".html";
    return video;
}
//构造大图显示
function show_big_img(url, discript) {
    var url_arry = url.split("|");
    var length = url_arry.length;
    var url_image = url_arry[0].split('/');
    var img_box = "";
    for (var index = 0; index < length - 2; index++)
        img_box += '<div class="feed-big-img"><div class="feed-big-img-holder"><img width="500"  src="/'
             + url_image[1] + '/UploadPictures/' + url_image[3] + '/' + url_image[4] + '/' + url_arry[index + 1]
            + '" class="feed-img" ></div></div>';
    img_box = img_box + '<div class="feed-img-desc">' + discript + '</div>';
    return img_box;
}
//构造标签显示
function show_flag(lable) {
    var flag_arry = lable.split(",");
    var flag_box = '<div class="feed-tag">标签:';
    for (var index in flag_arry) {
        flag_box += '<a href="#">'
            + flag_arry[index]
            + '</a><span class="tag-comma">&nbsp;</span>'
    }
    return flag_box;
}
//从父级标签得到视频地址信息，构造视频播放
function get_parent_video_url(video_play) {
    var parent = jq(video_play).parent("div").parent("div");
    var json = eval(parent.attr("data").toString());
    video_show = '<div class="feed-full-video-wrap clearfix">'
            + '<div class="feed-full-video">'
            + '<object width="500" height="416">'
            + '<param value="true" name="isAutoPlay">'
            + '<param value="sameDomain" name="allowscriptaccess">'
            + '<param value="transparent" name="wmode">'
            + '<param value="true" name="allowfullscreen">'
            + '<param value='
            + json[0].flashurl.toString()
            + '&amp;isAutoPlay=true" name="movie">'
            + '<embed width="500" height="416" allowfullscreen="true" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="sameDomain" src="'
            + json[0].flashurl.toString()
            + '&amp;isAutoPlay=true" flashvars="isAutoPlay=true">'
            + '</object>'
            + '</div>'
            + '<div class="feed-video-footer clearfix">'
            + '<span class="feed-video-link">'
            + '<a target="_blank" href="'
            + json[0].videourl.toString()
            + '">youku.com</a>→'
            + '</span>'
            + '<a class="feed-video-close">关闭视频</a>'
            + '</div>'
            + '</div>';
    return video_show;
}


//回应
jq(document).ready(function () {
    blogname.innerHTML = user[1];
    //Init();
    //首页回复 如果没有值则光标聚焦
    jq("#idclick").live("click", function () {
        if (jq(this).text().length - 2 == 0) {
            jq("textarea").focus();
        }
    });

    //回复信息的处理 
    jq("#idclick").live("click", function () {
        var self = jq(this);
        if (jq(this).prev().attr("value") != "") {
            jq.ajax({
                type: "post", //两种类型 get和post
                url: '/ashx/Dd_index.ashx',
                data: { userID: user[0], content: jq(this).prev().attr("value"), typeID: jq(this).parent().parent().parent().parent().parent().attr("id"), typeOrder: jq(this).parent().parent().parent().parent().parent().attr("typeOrder"), state: "replayALL", Type_Process: "relpy", time: new Date().getTime() },
                success: function (data) {
                    var ID = data.split(',');
                    if (ID[0] == "1") {
                        userID = user[0]; //获取用户ID
                        userName = user[1]; //获取用户的昵称
                        Reply_ArticleID = ID[1]; //回应的（文章、图片、链接、音乐、视频……）ID
                        Reply_ID = ID[2]; //回应ID
                        //回应的内容
                        self.parent().next().children().prepend(Reply_drop_down_list(self.prev().html(), Reply_ID));
                        self.prev().val(""); //清除回应框中的内容
                    }
                },
                error: function () {
                    alert("回应失败！！！");
                }
            });
        }
    });

    //点击回应时加载回复的信息
    jq(".feed-cmt").live("click", function () {
        var myself = jq(this);
        if (jq(this).children().html() != "isornotclick") {
            myself.append("<p style='display:none'>isornotclick</p>"); //唯一标识是否被点击，如果点击则追加
            jq.ajax({
                type: "post",
                url: '/ashx/Dd_index.ashx',
                data: { userID: user[0], typeID: jq(this).parent().parent().parent().parent().attr("id"), Orders: jq(this).parent().parent().parent().parent().attr("typeOrder"), mark: "favor", state: "replycontentALL", Type_Process: "replycontent", time: new Date().getTime() },
                success: function (data) {
                    var content = data.split(',');
                    if (content[0] == "1") {
                        var value = content[2].split('*'); //用*分割
                        for (var i = 0; i < value.length - 1; i++) {
                            var val = value[i].split('#'); //最后用#划分
                            userID = val[0];
                            userName = val[1];
                            Reply_ID = val[3];
                            Reply_ArticleID = content[1];
                            myself.parent().parent().next().children().children().next().children().append(Reply_drop_down_list(val[2], Reply_ID));
                        }

                    }
                },
                error: function () {

                }
            });
        }
    });
    //删除回应信息的方法
    jq(".cmt-del").live("click", function () {
        var jqueryself = jq(this);
        if (confirm("确定要删除吗？")) {
            jq.ajax({
                type: "post",
                url: '/ashx/Dd_index.ashx',
                data: { TypeID: jq(this).parent().attr("id"), state: "DelReply", Type_Process: "DelreplyContent", time: new Date().getTime() },
                success: function (data) {
                    if (data == "true") {
                        jqueryself.parent().remove(); //随着数据库中的数据的删除而删除页面中的值
                    }
                },
                error: function () {
                    alert("删除失败！！");
                }
            });
        }
    });
});

jq(document).ready(function () {
    //编辑
    var oneself = jq(this);
    jq(".feed-edit").live('click', function () {
        var ID = jq(this).parent().parent().parent().parent().attr("id");
        var Orders = jq(this).parent().parent().parent().parent().attr("typeOrder");
        var originID = jq(this).parent().parent().parent().parent().attr("UserID");
        switch (Orders) {
            case "0":
                reship('Dd_text.aspx', ID, originID, "edit", "reContent");
                break;
            case "1":
                reship('Dd_picture.aspx', ID, originID, "edit", "reContent");
                break;
            case "2":
                reship('Dd_music.aspx', ID, originID, "edit", "reContent");
                break;
            case "3":
                reship('Dd_link.aspx', ID, originID, "edit", "reContent");
                break;
            case "4":
                reship('Dd_video.aspx', ID, originID, "edit", "reContent");
                break;
        }
    });
    //删除发表的文本
    jq(".feed-del").live('click', function () {
        if (confirm("您确定删除？确定点击'确定'，否则点击'取消'！")) {
            jq.ajax({
                type: 'get',
                url: '/ashx/Dd_index.ashx',
                data: { ID: jq(this).parent().parent().parent().parent().attr("id"), Orders: jq(this).parent().parent().parent().parent().attr("typeOrder"), state: "DeleteArticle", Type_Process: "Delete", time: new Date().getTime() },
                success: function (data) {
                    if (data == "true") {

                    }
                },
                error: function () {
                    alert("删除失败！");
                }
            });
            jq(this).parent().parent().parent().parent().remove();
        }
    });
});

//点击发布后显示的回应列表
function Reply_drop_down_list(reply_content, Reply_ID) {
    var input = '<li userid="' + userID + '" user="' + userName + '" Articleid="' + Reply_ArticleID + '" id="' + Reply_ID + '" class="cmt-list-item clearfix first-cmt" style="opacity: 1;">'
			      + '<a href="http://diandian.cn"><img id="replylist'+Reply_ID+'" width="20" height="20" src="' + BindSmallPicture(userID,Reply_ID) + '" class="cmt-avatar">'
			      + '</a>'
				  + '<span class="cmt-main">'
				  + '<a class="cmt-user" href="http://diandian.com/11076262">' + userName + '</a>'
				  + '<span class="cmt-content" style="display:block" id="cmt-content-id">' + reply_content
				  + '</span>'
				  + '</span>'
			      + '<a class="cmt-del">'+showDel(userID)+'</a>'
		          + '</li>';
    return input;
}

function showDel(userid) {
    if (user[0] == userid) {
        return "删除";
    }
    else {
        return "";
    }
}
//热度jq(this).parent().parent().next().next().next()显示的div
jq(document).ready(function () {
    jq(".feed-nt").live('click', function () {
        if (jq(this).parent().parent().next().css("display") == "none") {
            jq(this).parent().parent().next().next().next().toggle();
        }
        else {
            jq(this).parent().parent().next().css("display", "none");
            jq(this).parent().parent().next().next().next().toggle();
        }
        jqself = jq(this); //给全局变量赋值
        if (jq(this).children().html() != "isornotclick") {
            jq(this).parent().parent().next().next().next().children().children().html("正在加载…");
            jq.ajax({
                type: 'post',
                url: '../ashx/Dd_index.ashx',
                data: {
                    ID: jq(this).parent().parent().parent().parent().attr("id"),
                    Orders: jq(this).parent().parent().parent().parent().attr("typeOrder"),
                    UserName: jq(this).parent().parent().children().children().html(),
                    state: "fever",
                    Type_Process: "addfever",
                    time: new Date().getTime()
                },
                success: function (data) {
                    if (data != null) {
                        jqself.parent().parent().next().next().next().children().children().html("");
                        Heat(data);
                    }
                },
                error: function () {

                }
            });
            jqself.append("<p style='display:none'>isornotclick</p>");
        }
    });


    //favor(喜欢)
    jq(".feed-fav").live('click', function () {
        jq(this).toggle(
        function () {
            jq(this).css("color", "red");
            var username = user[1]; //用户的名字
            jq.ajax({
                type: 'post',
                url: '../ashx/Dd_index.ashx',
                data: { UserID: user[0], ID: jq(this).parent().parent().parent().parent().attr("id"), Orders: jq(this).parent().parent().parent().parent().attr("typeOrder"), state: "favor", Type_Process: "addfavor", time: new Date().getTime() },
                success: function (data) {
                    var val = data.split(',');
                    if (val[0] == "1") {

                    }
                },
                error: function () {
                    alert("添加喜欢失败");
                }
            });
        },
        function () {
            jq(this).css("color", "");
        });
    });


    jq(".J_NotesFolder").live('click', function () {
        jq(this).parent().toggle();
    });
});
//获取热度的个数
function GetFevorCount(count) {
    if (count != 0) {
        return "热度" + "(" + count + ")";
    }
    else {
        return "";
    }
}
//转载时传一个ID值
jq(document).ready(function () {
    jq(".feed-rt").live('click', function () {
        var ArticleID = jq(this).parent().parent().parent().parent().attr("id");
        var Orders = jq(this).parent().parent().parent().parent().attr("typeOrder");
        var OriginUserID = jq(this).parent().parent().parent().parent().attr("UserID");
        switch (Orders) {
            case "0":
                reship('Dd_text.aspx', ArticleID, OriginUserID, "reship", "reshipAll"); //调用转载的方法
                break;
            case "1":
                reship('Dd_picture.aspx', ArticleID, OriginUserID, "reship", "reshipAll");
                break;
            case "2":
                reship("Dd_music.aspx", ArticleID, OriginUserID, "reship", "reshipAll");
                break;
            case "3":
                reship('Dd_link.aspx', ArticleID, OriginUserID, "reship", "reshipAll");
                break;
            case "4":
                reship('Dd_video.aspx', ArticleID, OriginUserID, "reship", "reshipAll");
                break;
        }
    });
});


//热度
function Heat(data) {
    var json = eval(data); //把后台的json用eval进行转化成数组
    for (var index in json) {
        switch (json[index].Mark) {
            case "favor":
            jqself.parent().parent().next().next().next().children().children().append(
            '<li class="notes-list-item nt-fav clearfix">'
             + '<div class="notes-item-hd clearfix">'
             + '<a href="http://haitian.com">'
             + '<img class="notes-avatar" id="notes-avatar' + json[index].Like_Guid + '" alt="' + json[index].User_BlogName + '" src="' + BindSmallPictureOfFever(json[index].Like_UserID, json[index].Like_Guid) + '" width="20" height="20">'
             + '</a>'
             + '<span class="notes-info">'
             + '<a class="notes-user" href="http://haitian.com">' + json[index].User_BlogName + '</a>很喜欢此'+json[index].Text+'</span>'
             + '<s class="notes-icon">'
             + '</s>'
             + '</div>'
             + '</li>'
             );
            break;
        case "reply":
                jqself.parent().parent().next().next().next().children().children().append(
             '<li class="notes-list-item nt-cmt clearfix">'
             + '<div class="notes-item-hd clearfix">'
             + '<a href="http://haitian.com/13696033">'
             + '<img class="notes-avatar" id="notes-avatar' + json[index].Reply_Guid + '" alt="' + json[index].User_BlogName + '" src="' + BindSmallPictureOfFever(json[index].Reply_UserID, json[index].Reply_Guid) + '" width="20" height="20">'
             + '</a>'
             + '<span class="notes-info">'
             + '<a class="notes-user" href="http://haitian.com">' + json[index].User_BlogName + '</a>在&nbsp;'
             + '<a href="http://haitian.com/">'+json[index].UserName+'</a>&nbsp;回应了此'+json[index].Text
             + '</span>'
             + '<s class="notes-icon"></s>'
             + '</div>'
             + '<div class="notes-comment">' + json[index].Reply_Content
             + '</div>'
             + '</li>'
             );
            break;
        case "reship":
                jqself.parent().parent().next().next().next().children().children().append(
             '<li class="notes-list-item nt-rt clearfix last">'
             + '<div class="notes-item-hd clearfix">'
             + '<a href="http://haitian.com">'
             + '<img class="notes-avatar" id="notes-avatar' + json[index].Reprint_Guid + '" alt="' + json[index].User_BlogName + '" src="' + BindSmallPictureOfFever(json[index].Reprint_UserID, json[index].Reprint_Guid) + ' width="20" height="20">'
             + '</a>'
             + '<span class="notes-info">'
             + '<a class="notes-user" href="http://haitian.com">' + json[index].User_BlogName + '</a>从&nbsp;'
             + '<a href="http://haitian.com">' + json[index].UserName + '</a>&nbsp;转载了此' + json[index].Text + '到&nbsp;'
             + '<a href="//244686853.diandian.com">' + json[index].User_BlogName + '</a>'
             + '</span>'
             + '<s class="notes-icon">'
             + '</s>'
             + '</div>'
             + '</li>'
             );
             break;
        }
    }
}

//转载或编辑的一个方法 Jump_page跳转的页面，id为所选中的id,status表示状态
function reship(Jump_page, id,originID, status, type_process) {
    jq.ajax({
        type: 'post',
        url: '/Web/' + Jump_page,
        data: { userName: user[1], ID: id, userID: originID, state: status, Type_Process: type_process, time: new Date().getTime() },
        success: function (data) {
            document.location = "/Web/" + Jump_page;
        },
        error: function () {

        }
    });
}


