﻿/// <reference path="jQuery.js" />

/******************************************************************/
//加载个人空间日历
/******************************************************************/
function InitCalendarData(param, dataDivId) {
    var aParamValues = new Array();
    InitParams(param, aParamValues);
    aParamValues["DataDivId"] = dataDivId;
    var div = GetContentDiv(aParamValues);

    div.className = "clearfix Box"; //整体样式 
    if (aParamValues["MoreMenuId"] == null) {
        aParamValues["MoreMenuId"] = 0;
    }    
    parent.Calendar().Init(function(y, m, d, objectId, dns, moreMenuId, type, callback) { parent.jQuery.ajax({ type: "POST", contentType: "application/json", data: "{ y: '" + y + "',m:'" + m + "', d:'" + d + "',objectId:'" + objectId + "',dns:'" + dns + "',moreMenuId:'" + moreMenuId + "', type: '" + type + "'}", dataType: "json", url: "/Service/Calendar.asmx/HitDay", success: function(msg) { callback(msg.d); } }); }, function(y, m, direction, type, objectId, callback) { parent.jQuery.ajax({ type: "POST", contentType: "application/json", data: "{ y: '" + y + "',m:'" + m + "', direction:'" + direction + "',type:'" + type + "',objectId:'" + objectId + "'}", dataType: "json", url: "/Service/Calendar.asmx/HitMonth", success: function(msg) { callback(msg.d); } }); }, function(response) { parent.location.href = response; }, div, "blog", aParamValues["UserId"], aParamValues["BlogId"], aParamValues["ReqDns"], aParamValues["MoreMenuId"]);
    InitContentDiv(aParamValues, div);
}


/******************************************************************/
//加载个人空间文章列表数据
/******************************************************************/
function InitArticleListData(param, dataDivId,  pageIndex) {
    var aParamValues = new Array();
    InitParams(param, aParamValues);
    aParamValues["DataDivId"] = dataDivId;
    var dataDiv = jQuery("#" + dataDivId);
    if (dataDiv.innerHMTL == "") {
        dataDiv.innerText = "数据加载中...";
    }
    if (aParamValues["CalendarDate"] == null) {
        aParamValues["CalendarDate"] = "0";
    }
    if (aParamValues["MoreMenuId"] == null) {
        aParamValues["MoreMenuId"] = 0;
    }
    if (aParamValues["CategoryId"] == null) {
        aParamValues["CategoryId"] = 0;
    }
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ userId: '" + aParamValues["UserId"] + "',pageIndex:'" + pageIndex + "', pageSize:'" + aParamValues["PageSize"] + "',blogArticleCategoryId:'" + aParamValues["CategoryId"] + "',CalendarDate:'" + aParamValues["CalendarDate"] + "',postShowMode:'" + aParamValues["PostShowMode"] + "', blogId: '" + aParamValues["BlogId"] + "',dns:'" + aParamValues["ReqDns"] + "',moreMenuId:'" + aParamValues["MoreMenuId"] + "',categoryGroupId:'" + (aParamValues["CategoryGroupId"] == null ? 0 : aParamValues["CategoryGroupId"]) + "',articleNature:'" + (aParamValues["ArticleNature"] == null ? 0 : aParamValues["ArticleNature"]) + "', articleFrom:'" + (aParamValues["ArticleFrom"] == null ? 0 : aParamValues["ArticleFrom"]) + "', articleType:'" + (aParamValues["ArticleType"] == null ? "0" : aParamValues["ArticleType"]) + "'}",
        dataType: "json",
        url: "/Service/BlogService.asmx/GetBlogArticleList",
        success: function(result) {
            var PageCount = result.d.PageCount;
            var div = GetContentDiv(aParamValues);
            var list = InitFixed(result.d.List, aParamValues["PageSize"], aParamValues["IsFixed"]);
            jQuery(div).addClass("clearfix Box");
            jQuery(div).html("");
            jQuery.each(list, function(i, item) {
                if (aParamValues["ImageArticleCategoryShowType"] == "1") {
                    jQuery(div).append(CreateArticleListForPic(item, aParamValues));
                }
                else {
                    switch (aParamValues["PostShowMode"]) {
                        case "0":
                            jQuery(div).append(CreateArticleContentList(item, aParamValues));
                            if (item != null)
                                jQuery(div).append(CreateBlogArticleFuncNav(item, aParamValues));
                            break;
                        case "1":
                            jQuery(div).append(CreateArticleSummaryList(item, aParamValues));
                            if (item != null)
                                jQuery(div).append(CreateBlogArticleFuncNav(item, aParamValues));
                            break;
                        case "2":
                            jQuery(div).append(CreateArticleList(item, aParamValues));
                            break;
                    }
                }
            });
            if (aParamValues["IsShowPageNav"] == "1") {
                jQuery(div).append(CreatePageNav(pageIndex, PageCount, "InitArticleListData('" + param + "','" + dataDivId + "',{0})", "PageNav")); //文章列表分页样式
            }
            InitContentDiv(aParamValues, div);
            SetAllVideoArticleImage();
        }
    });
}

//图片列表显示
function CreateArticleListForPic(item, aParamValues) {
    var str = "<div class=\"text-float-left TitleBox\" title=\"" + (item == null ? "&nbsp;" : item.Title) + "\">" +
                  "<div class=\"Photo\" style=\"width:" + aParamValues["ImageWidth"] + ";height:" + aParamValues["ImageHeight"] + ";\">" + (item == null ? "" : "<a href=" + item.Url + " target='_blank'>" + item.CoverImage + "</a>");
    if (item.IsVideoArticle == "1") {
        str += "<div style=\"position: relative;\"><img src=\"/Images/Video/play.jpg\" li=\"VideoArticleImage\" style=\"display:none;\" /></div>";
    }  
        str  += "</div>" +
                  "<div class=\"text-float-left TitleIcon\"></div>" +
                  "<div class=\"text-overflow Title\">" + (item == null ? "&nbsp;" : "<a href=" + item.Url + " target='_blank'>" + item.Title + "</a>") + "</div>" +
              "</div>";
    return str;
}

//列表显示
function CreateArticleList(item, aParamValues) {
    var str = "<div class=\"TitleBox\" title=\"" + (item == null ? "&nbsp;" : item.Title) + "\">";
    if (aParamValues["IsShowTime"] == 1) {
        str += "<div class=\"text-float-right Date\">" + (item == null ? "&nbsp;" : GetDateFormat(aParamValues["TimeFormat"], new Date(parseInt(item.UpdateTime.substring(6, item.UpdateTime.length - 2))))) + "</div>";
    }
    if (aParamValues["IsShowUser"] == 1) {
        str += "<div class=\"text-float-right Name\">" + (item == null ? "&nbsp;" : "<a href=" + item.UserUrl + ">" + item.UserName + "</a>") + "</div>";
    }
    if (item != null && aParamValues["IsShowTopFlag"] == 1 && item.Top == 1) {
        str += "<div class=\"text-float-right Top\"></div>";
    }
    str += "<div class=\"text-float-left TitleIcon\"></div>";
    if (aParamValues["IsShowCategory"] == 1) {
        str += "<div class=\"text-float-left Category\" title=\"所属类别\">" + (item == null ? "&nbsp;" : "<a href=" + item.CategoryUrl + ">" + item.CategoryName + "</a>") + "</div>";
    }
    str += "<div class=\"text-overflow Title\">" + (item == null ? "&nbsp;" : (item.IsVideoArticle == "1" ? "<img src=\"/Images/Video/v_ico.gif\" boader=0 align=\"absMiddle\" />" : (item.IsImageArticle == "1" ? "<span class=\"ImageTip\">[图文]</span>" : ""))) + (item == null ? "&nbsp;" : "<a href=" + item.Url + " target='_blank'>" + item.Title + "</a>") + "</div>";
    str += "</div>";
    return str;
}
//文章摘要列表显示
function CreateArticleSummaryList(item, aParamValues) {
    var str = "<div class=\"TitleBox\" title=\"" + (item == null ? "&nbsp;" : item.Title) + "\">";
    if (item != null && aParamValues["IsShowTopFlag"] == 1 && item.Top == 1) {
        str += "<div class=\"text-float-right Top\"></div>";
    }
    str += "<div class=\"text-float-left TitleIcon\"></div>" +
           "<div class=\"text-overflow Title\">" + (item == null ? "&nbsp;" : (item.IsVideoArticle == "1" ? "<img src=\"/Images/Video/v_ico.gif\" boader=0 align=\"absMiddle\" />" : (item.IsImageArticle == "1" ? "<span class=\"ImageTip\">[图文]</span>" : ""))) + (item == null ? "&nbsp;" : "<a href=" + item.Url + " target='_blank'>" + item.Title + "</a>") + "</div>";
    if (item != null && item.PasswordAccess == 2) {
        str += "<div class='PwdFont' width=\"100%\" align=\"center\" id=\"BlogArticleList_Pwd_" + item.ArticleId + "\">" + "请输入访问密码：<input type=\"password\" class='PwdBox' name=\"ArticleAccessPwd\" onfocus=\"setKeyDown('ArticleAccessPwd_" + item.ArticleId + "','ArticleAccessPwd_" + item.ArticleId + "','btnArticleAccessPwd" + item.ArticleId + "')\" id=\"ArticleAccessPwd_" + item.ArticleId + "\"><input id=\"btnArticleAccessPwd" + item.ArticleId + "\" class='PwdButton' type=\"button\" onclick=\"javascript:CheckBlogArticlePwdAccess(" + item.ArticleId + ");\" value=\"确定\"  />" + "</div>";
        str += "<div class=\"text-wrap Brief\" style=\"display:none;\" id=\"" + (item == null ? "&nbsp;" : "BlogArticleList_" + item.ArticleId) + "\">" + (item == null ? "" : item.Brief) + "</div>";
    }
    else {
        str += "<div class=\"text-wrap Brief\" id=\"" + (item == null ? "&nbsp;" : "BlogArticleList_" + item.ArticleId) + "\">" + (item == null ? "" : item.Brief) + "</div>";
    }

    str += "<div class=\"View\">" + (item == null ? "&nbsp;" : "<a href=" + item.Url + " target='_blank'>[查看全文]</a>") + "</div></div>";

    return str;
}
//文章完整列表显示
function CreateArticleContentList(item, aParamValues) {
    var str = "<div class=\"TitleBox\" title=\"" + (item == null ? "&nbsp;" : item.Title) + "\">";
    if (item != null && aParamValues["IsShowTopFlag"] == 1 && item.Top == 1) {
        str += "<div class=\"text-float-right Top\"></div>";
    }
    str += "<div class=\"text-float-left TitleIcon\"></div>" +
           "<div class=\"text-overflow Title\">" + (item == null ? "&nbsp;" : (item.IsVideoArticle == "1" ? "<img src=\"/Images/Video/v_ico.gif\" boader=0 align=\"absMiddle\" />" : (item.IsImageArticle == "1" ? "<span class=\"ImageTip\">[图文]</span>" : ""))) + (item == null ? "&nbsp;" : "<a href=" + item.Url + " target='_blank'>" + item.Title + "</a>") + "</div>";

    if (item != null && item.PasswordAccess == 2) {
        str += "<div class='PwdFont' width=\"100%\" align=\"center\" id=\"BlogArticleList_Pwd_" + item.ArticleId + "\">" + "请输入访问密码：<input type=\"password\" class='PwdBox' name=\"ArticleAccessPwd\" onfocus=\"setKeyDown('ArticleAccessPwd_" + item.ArticleId + "','ArticleAccessPwd_" + item.ArticleId + "','btnArticleAccessPwd" + item.ArticleId + "')\" id=\"ArticleAccessPwd_" + item.ArticleId + "\"><input id=\"btnArticleAccessPwd" + item.ArticleId + "\" class='PwdButton' type=\"button\" onclick=\"javascript:CheckBlogArticlePwdAccess(" + item.ArticleId + ");\" value=\"确定\"  />" + "</div>";
        str += "<div class=\"text-wrap Content\" style=\"display:none;\" id=\"" + (item == null ? "&nbsp;" : "BlogArticleList_" + item.ArticleId) + "\">" + (item == null ? "&nbsp;" : item.Content) + "</div>";
    }
    else {
        str += "<div class=\"text-wrap Content\" id=\"" + (item == null ? "&nbsp;" : "BlogArticleList_" + item.ArticleId) + "\">" + (item == null ? "&nbsp;" : item.Content) + "</div>";
    }

    str += "</div>";

    return str;
}
//功能导航
function CreateBlogArticleFuncNav(item, aParamValues) {
    var str = "<div style=\"width:100%\">";
    if (aParamValues["IsShowCategory"] == 1) {
        str += "<div class=\"text-float-right Category\">分类：<a href=" + item.CategoryUrl + ">" + item.CategoryName + "</a></div>";
    }
    str += "<div class=\"text-float-right Implement\"><a href=" + item.Url + "#Comments target='_blank'>评论</a> <a href=" + item.Url + " target='_blank'>阅读</a> <a href='javascript:void(0)' onclick=\"javascript:SetReport(" + item.ArticleId + ",1,'" + aParamValues["PathPrefix"] + "')\">举报</a></div>";
    if (aParamValues["IsShowUser"] == 1) {
        str += "<div class=\"text-float-right Name\"><a href=" + item.UserUrl + ">" + item.UserName + "</a></div>";
    }
    if (aParamValues["IsShowTime"] == 1) {
        str += "<div class=\"text-float-right Date\">发布时间：" + GetDateFormat(aParamValues["TimeFormat"], new Date(parseInt(item.UpdateTime.substring(6, item.UpdateTime.length - 2)))) + "</a></div>";
    }
    str += "</div>";

    return str;
}

//文章密码验证
function CreatePwdForRepeater(ArticleId) {
    var str;
    str = "<div class='PwdFont' width=\"100%\" align=\"center\" id=\"BlogArticleList_Pwd_" + ArticleId + "\">" + "请输入访问密码：<input type=\"password\" class='PwdBox' name=\"ArticleAccessPwd\" onfocus=\"setKeyDown('ArticleAccessPwd_" + ArticleId + "','ArticleAccessPwd_" + ArticleId + "','btnArticleAccessPwd" + ArticleId + "')\" id=\"ArticleAccessPwd_" + ArticleId + "\"><input id=\"btnArticleAccessPwd" + ArticleId + "\" class='PwdButton' type=\"button\" onclick=\"javascript:CheckBlogArticlePwdAccess(" + ArticleId + ");\" value=\"确定\"  />" + "</div>";

    return str;
}


/******************************************************************/
//个人空间密码访问处理
/******************************************************************/
function CheckBlogPwdAccess(blogId) {
    var password = jQuery("#AccessPwd").val();
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ pwd: '" + password + "',blogId:'" + blogId + "'}",
        dataType: "json",
        url: "/Service/BlogService.asmx/CheckBlogPwdAccess",
        success: function(result) {
            if (result.d == false) {
                _error_msg_show("您输入的密码不正确，请重试!", '', 'sorry', "错误");
            }
            else {
                _error_msg_show("重定向中，请稍候...", '', 'succ', "成功");
                location.href = document.location;
            }
        }
    });
}

/******************************************************************/
//个人空间文章密码访问处理
/******************************************************************/
function CheckBlogArticlePwdAccess(articleId) {
    var password = jQuery("#ArticleAccessPwd_" + articleId).val();
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ pwd: '" + password + "',pkId:'" + articleId + "'}",
        dataType: "json",
        url: "/Service/BlogService.asmx/CheckBlogArticlePwdAccess",
        success: function(result) {
            if (result.d == 0) {
                _error_msg_show("您输入的密码不正确，请重试!", '', 'sorry', "错误");
            }
            else {
                jQuery("#BlogArticleList_" + result.d).show();
                jQuery("#BlogArticleList_Pwd_" + result.d).hide();
            }
        }
    });
}

//具体显示文章时密码验证处理(与列表中验证有所区别)
function CheckBlogArticlePwdAccess1(articleId, param, dataDivId, commentsId, menuId) {

    var password = jQuery("#AccessPwd").val();
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ pwd: '" + password + "',pkId:'" + articleId + "'}",
        dataType: "json",
        url: "/Service/BlogService.asmx/CheckBlogArticlePwdAccess",
        success: function(result) {
            if (result.d == 0) {
                _error_msg_show("您输入的密码不正确，请重试!", '', 'sorry', "错误");
            }
            else {
                _error_msg_show("重定向中，请稍候...", '', 'succ', "成功");
                location.href = document.location;
            }
        }
    });
}

/******************************************************************/
//个人空间横幅
/******************************************************************/
function InitBannerDiv(param, dataDivId, imgDivId, nameDivId, urlDivId) {

    var aParamValues = new Array();
    InitParams(param, aParamValues);
    aParamValues["DataDivId"] = dataDivId;

    var div = GetContentDiv(aParamValues);
    if (div.id != dataDivId) {
        div.innerHTML = $(dataDivId).innerHTML;
    }
    var pos = GetPosition(div);
    var imgDiv = parent.document.getElementById(imgDivId);
    var nameDiv = parent.document.getElementById(nameDivId);
    var urlDiv = parent.document.getElementById(urlDivId);

    //获取总宽度	
    var width = div.parentNode.parentNode.style.width;
    width = width.replace("px", "");
    var height;

    if (aParamValues["BannerFile"] != null && aParamValues["BannerFile"] != "null" && aParamValues["BannerFile"] != "") {
        height = width * aParamValues["BannerScale"];
        if (navigator.userAgent.indexOf("MSIE") > 0) {
            imgDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/" + aParamValues["BannerFile"] + "', sizingMethod='scale')";
        }
        else {
            imgDiv.style.background = "url(/" + aParamValues["BannerFile"] + ") repeat center";
        }
    }
    else {
        w = GetCssWidth("Banner", "BannerBox");
        h = GetCssHeight("Banner", "BannerBox");
        height = width * (h / w);
    }

    imgDiv.style.height = height + "px";
    imgDiv.style.width = width + "px";

    nameDiv.style.cssText = "position:relative;left:120px;top:" + (height / 2 - 15) + "px;float:left;overflow-x:hidden;white-space:nowrap; z-index:10";
    urlDiv.style.cssText = "position:relative;left:50px;top:" + (height / 2 + 15) + "px;float:left;overflow-x:hidden;white-space:nowrap; z-index:10";

    InitContentDiv(aParamValues, div);
}
function ClipBoard(test) {
    CopyToClipboard(test);

    _error_msg_show("已经把该个人博客网址复制到系统剪贴板，您可以使用（Ctrl+V或鼠标右键）粘贴功能，通过其他软件记录或发送给您的朋友。", '', 'succ', "成功");
}

/******************************************************************/
//加载文章评论
/******************************************************************/
function InitArticleComments(articleId) {
    jQuery("#Comments").html("数据加载中...");
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ articleId: '" + articleId + "'}",
        dataType: "json",
        url: "/Service/BlogService.asmx/GetBlogCommentsByArticleId",
        success: function(result) {
            jQuery("#Comments").html("");
            jQuery.each(result.d, function() {
                var str = "<div>" +
                          "<div class=\"Name\" align=\"left\">昵称：" + this.NickName + "&nbsp;&nbsp;&nbsp;&nbsp;" + this.UserIden + "</div>" +
                          "<div class=\"text-float-right Date\">" + (new Date(parseInt(this.CommentDate.substring(6, this.CommentDate.length - 2))).formatt("yyyy-MM-dd hh:mm:ss")) + "</div>" +
                          "<div class=\"Content\" align=\"left\">" + this.Content + "</div>" +
                          "</div>";
                jQuery("#Comments").append(str);
            });
        }
    });

}

/******************************************************************/
//加载个人空间相册
/******************************************************************/
function InitAlbumListData(param, dataDivId, pageIndex) {
    var aParamValues = new Array();
    InitParams(param, aParamValues);
    aParamValues["DataDivId"] = dataDivId;

    var dataDiv = document.getElementById(dataDivId);
    if (dataDiv.innerHMTL == "") {
        dataDiv.innerText = "数据加载中...";
    }
    if (aParamValues["NewsMenuId"] == null) {
        aParamValues["NewsMenuId"] = 0;
    }
    if (aParamValues["MoreMenuId"] == null) {
        aParamValues["MoreMenuId"] = 0;
    }
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ pageIndex: '" + pageIndex + "',pageSize:'" + aParamValues["PageSize"] + "',blogId:'" + aParamValues["BlogId"] + "',newsMenuId:'" + aParamValues["NewsMenuId"] + "',moreMenuId:'" + aParamValues["MoreMenuId"] + "', dns:'" + aParamValues["ReqDns"] + "'}",
        dataType: "json",
        url: "/Service/BlogService.asmx/GetAlbum",
        success: function(result) {
            var div = GetContentDiv(aParamValues);
            var list = InitFixed(result.d.List, aParamValues["PageSize"], aParamValues["IsFixed"]);
            jQuery(div).html("");
            jQuery(div).addClass("clearfix Box");
            jQuery.each(list, function(i, item) {
                var str = "<div class=\"text-float-left TitleBox\" title=\"" + (item == null ? "&nbsp;" : item.Name) + "\">" +
                          "<div class=\"Photo\" style=\"width:" + aParamValues["ImageWidth"] + ";height:" + aParamValues["ImageHeight"] + ";overflow:hidden;\">" + (item == null ? "&nbsp;" : "<a href=" + item.Url + ">" + item.CoverPhoto + "</a>") + "</div>" +
                          "<div class=\"text-float-left TitleIcon\"></div>" +
                          "<div class=\"Title text-overflow\" style=\"width:100%\">" + (item == null ? "&nbsp;" : "<a href=" + item.Url + ">" + item.Name + "</a>") + "</div>" +
                          "<div class=\"Date\">" + (item == null ? "&nbsp;<br>&nbsp;" : new Date(parseInt(item.CreatTime.substring(6, item.CreatTime.length - 2))).formatt("yyyy-MM-dd") + "<br>" + item.Nums + "张图片") + "</div>" +
                          "</div>";
                jQuery(div).append(str);
            });
            if (aParamValues["IsShowPageNav"] == "1") {
                jQuery(div).append("<div style=\"width:100%\">" + CreatePageNav(pageIndex, result.d.PageCount, "InitAlbumListData('" + param + "','" + dataDivId + "' ,{0})", "PageNav") + "</div>");
            }

            InitContentDiv(aParamValues, div);
        }
    });
}

/******************************************************************/
//访问记录
/******************************************************************/
function LogIndexCount(objectId) {
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ objectId: '" + objectId + "'}",
        dataType: "json",
        url: "/Service/BlogService.asmx/LogIndexCount"
    });
}
function LogArticleCount(articleId, blogId) {
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ articleId: '" + articleId + "',blogId:'" + blogId + "'}",
        dataType: "json",
        url: "/Service/BlogService.asmx/LogArticleCount"
    });
}

/******************************************************************/
//文章搜索模块
/******************************************************************/
function RedirectToSearch(param, txtId, typeId, blogId) {
    var aParamValues = new Array();
    InitParams(param, aParamValues);

    if ($(txtId).value.Trim() == "") {
        _error_msg_show("请输入查询关键字", '', 'smile', "提醒");
    }
    else {
        location.href = "/OperationManage/BlogMoreIndex.aspx?pkId=" + aParamValues["MoreMenuId"] + "&blogId=" + blogId + "&kw=" + $(txtId).value + "&st=" + $(typeId).value + "&t=1";

    }
}

/******************************************************************/
//加载文章搜索
/******************************************************************/
function InitBlogArticleSearchListData(param, dataDivId, pageIndex) {
    var aParamValues = new Array();
    InitParams(param, aParamValues);
    aParamValues["DataDivId"] = dataDivId;
    var dataDiv = document.getElementById(dataDivId);
    if (dataDiv.innerHMTL == "") {
        dataDiv.innerText = "数据加载中...";
    }
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ userId: '" + aParamValues["UserId"] + "',pageIndex:'" + pageIndex + "', pageSize:'" + aParamValues["PageSize"] + "',kw:'" + aParamValues["SearchKeyWord"] + "',type:'" + aParamValues["SearchType"] + "',dns:'" + aParamValues["ReqDns"] + "', blogId: '" + aParamValues["BlogId"] + "'}",
        dataType: "json",
        url: "/Service/BlogService.asmx/GetBlogArticleSearchList",
        success: function(result) {
            var PageCount = result.d.PageCount;
            var div = GetContentDiv(aParamValues);
            var list = InitFixed(result.d.List, aParamValues["PageSize"], aParamValues["IsFixed"]);
            jQuery(div).addClass("clearfix Box");
            jQuery(div).html("");
            jQuery.each(list, function(i, item) {
                jQuery(div).append(CreateArticleList(item, aParamValues));
            });
            if (aParamValues["IsShowPageNav"] == "1") {
                jQuery(div).append(CreatePageNav(pageIndex, PageCount, "InitBlogArticleSearchListData('" + param + "','" + dataDivId + "' ,{0})", "PageNav")); //文章列表分页样式
            }
            InitContentDiv(aParamValues, div);
        }
    });
}

/******************************************************************/
//发布留言
/******************************************************************/
function AddMessageBoard(contentClientId, userId, param, dataDivId, iframeClientId) {
    var l = new Array();
    var content = jQuery("#" + contentClientId).val();
    if (content.Trim() == "") {
        _error_msg_show("请输入留言内容！", '', 'forbid', "输入错误");
    }
    else {
        _error_msg_show("正在提交数据，请稍候...", null, 'smile', "数据提交");
        jQuery.ajax({
            type: "POST",
            contentType: "application/json",
            data: "{ content: '" + content + "',userId:'" + userId + "'}",
            dataType: "json",
            url: "/Service/BlogService.asmx/AddMessageBoard",
            success: function(result) {
                CloseDialog1();
                $(iframeClientId).src = $(iframeClientId).src;
                jQuery("#" + contentClientId).val("");
                InitMessageBoardListData(param, dataDivId, 1);
            }
        });
    }
}

/******************************************************************/
//加载留言板列表
/******************************************************************/
function InitMessageBoardListData(param, dataDivId, pageIndex) {
    var aParamValues = new Array();
    InitParams(param, aParamValues);
    aParamValues["Param"] = param;
    aParamValues["DataDivId"] = dataDivId;
    var dataDiv = document.getElementById(dataDivId);
    if (dataDiv.innerHMTL == "") {
        dataDiv.innerText = "数据加载中...";
    }
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ userId: '" + aParamValues["UserId"] + "',pageIndex:'" + pageIndex + "',pageSize:'" + aParamValues["PageSize"] + "'}",
        dataType: "json",
        url: "/Service/BlogService.asmx/GetMessageBoardList",
        success: function(result) {
            var div = GetContentDiv(aParamValues);
            jQuery(div).addClass("clearfix Box");
            jQuery(div).html("");
            jQuery.each(result.d.List, function(i, item) {
                jQuery(div).append(CreateMessageBoardListForTile(item, aParamValues, dataDivId + "_" + i));
            });
            jQuery(div).append(CreatePageNav(pageIndex, result.d.PageCount, "InitMessageBoardListData('" + param + "','" + dataDivId + "' ,{0})", "PageNav"));
            InitContentDiv(aParamValues, div);
        }
    });
}

//平铺显示
function CreateMessageBoardListForTile(item, aParamValues, clientId) {

    var content = document.createElement("div");
    var photo = document.createElement("div");
    var name = ""
    if (aParamValues["FromBlog"] == "1") {
        name = "<a href='/BlogManage/UserInfo.aspx?pkId=" + item.MessageUserId + "'>" + item.MessageUserName + "</a>";
    }
    else {
        if (item.UserUrl == null || item.UserUrl == "") {
            name = item.MessageUserName;
        }
        else {
            name = "<a href='" + item.UserUrl + "' target='_blank'>" + item.MessageUserName + "</a>";
        }
    }

    if (aParamValues["FromBlog"] == "1") {
        photo.innerHTML = "<a href='/BlogManage/UserInfo.aspx?pkId=" + item.MessageUserId + "'>" + item.UserPhoto + "</a>";
    }
    else {
        if (item.UserUrl == "" || item.UserUrl == null) {
            photo.innerHTML = item.UserPhoto;
        }
        else {
            photo.innerHTML = "<a href=" + item.UserUrl + " target='_blank'>" + item.UserPhoto + "</a>";
        }
    }
    photo.className = "Photo"; //照片样式
    if (photo.document.getElementById("UserPhoto") != null) {
        photo.document.getElementById("UserPhoto").style.width = "100%";
        photo.document.getElementById("UserPhoto").style.height = "100%";
    }
    photo.style.overflow = "hidden";
    InitDivWidthAndHeight(photo, aParamValues["ImageWidth"], aParamValues["ImageHeight"]); //定义在Common.js中
    content.appendChild(photo);

    var action = "";
    if (item.Manage == 1) {
        action = "<a href=\"javascript:\" onclick=\"javascript:DeleteMessageBoard(" + item.PkId + ", '" + aParamValues["Param"] + "','" + aParamValues["DataDivId"] + "');\" >删除</a>";
    }
    if (item.Manage != 0) {
        action += "&nbsp;&nbsp;" + "<a href=\"javascript:\" onclick=\"javascript:ShowReplyDiv('" + clientId + "')\">回复</a>";
    }

    var sendMessageStr = "";
    if (aParamValues["FromBlog"] == "1") {
        sendMessageStr = "<a href=\"/BlogManage/Message/SendMessage.aspx?pkId=" + item.MessageUserId + "&returnUrl=" + aParamValues["ReturnUrl"] + "\">";
    }
    else {
        sendMessageStr = "<a href=\"javascript:\" onclick=\"javascript:openWindow('/OperationManage/SendUserMessage.aspx?pkId=" + item.MessageUserId + "', 500, 350 , '站内信', true)\">";
    }

    var str = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" class=\"TitleBox\" cellpadding=\"0\">"
	        + "<tr>"
	        + "<td style=\"width: 1%\" valign=\"top\" class=\"LeftBox\">"
	        + "<div class=\"Name\">" + name + "</div>"
	        + content.innerHTML;

    if (item.MessageUserId != 0) {
        str = str + "<div style=\"width:100%\" class=\"TipBox\">"
	        + "<div class=\"text-float-right Tip\"><a href=\"javascript:\" onclick=\"javascript:openWindow('/OperationManage/AddFriend.aspx?userId=" + item.MessageUserId + "', 440, 200 , '添加好友', true)\">加好友</a></div>"
	        + "<div class=\"Tip\">" + sendMessageStr + "站内信</a></div>"
	        + "</div>";
    }
    str = str + "</td>"
	        + "<td valign=\"top\" class=\"RightBox\">"
	        + "<div style=\"width:95%\" class=\"TopBox\">"
	        + "<div class=\"text-float-right\">"
	        + action
	        + "</div>"
	        + "<div class=\"Date\">留言时间：" + new Date(parseInt(item.CreateTime.substring(6, item.CreateTime.length - 2))).formatt("yyyy年MM月dd日 hh点mm分") + "</div>"
	        + "</div>"
	        + "<div style=\"width:100%;\" class=\"Content\">" + item.Content + "</div>"
	        + "<div style=\"width: 100%; text-align: left;\" class=\"ReplyContentBox\" id=\"" + clientId + "_ReplyContent\">"
	        + item.ReplyContent
	        + "</div>";
    if (item.Manage != 0) {
        str = str + "<div style=\"display: none;\" class=\"EditorBox\" id=\"" + clientId + "_div\">"
	        + "<div>请输入您的回复：</div>"
	        + "<iframe id=\"" + clientId + "_editor\" src=\"\" frameborder=\"0\" width=\"400\" scrolling=\"no\" height=\"150\"></iframe>"
	        + "<input id=\"" + clientId + "_content\" name=\"" + clientId + "_content\" type=\"hidden\" />"
	        + "<div>"
	        + "<input id=\"btnSubmit\" type=\"button\" value=\"提 交\" class=\"ReplyButton\" onclick=\"javascript:ReplyMessageBoard(" + item.PkId + ", '" + clientId + "')\" />&nbsp;&nbsp;"
	        + "<input id=\"btnCancel\" type=\"button\" value=\"取 消\" class=\"ReplyButton\" onclick=\"javascript:ShowReplyDiv('" + clientId + "')\" />&nbsp;&nbsp;"
	        + "<input id=\"" + clientId + "_check\" type=\"checkbox\" />以站内信方式发送"
	        + "</div>"
	        + "</div>";
    }
    str = str + "<div style=\"width:100%\" class=\"Sign\">" + item.Sign + "</div>"
	        + "</td>"
	        + "</tr>"
	        + "</table>";

    return str;
}

/******************************************************************/
//回复留言
/******************************************************************/
function ReplyMessageBoard(id, containerClientId) {

    $(containerClientId + "_editor").contentWindow.AttachSubmit()
    var content = $(containerClientId + "_content");
    var check = $(containerClientId + "_check");
    if (content.value.Trim() == "") {
        _error_msg_show("请输入回复内容！", '', 'forbid', "输入错误");
    }
    else {
        jQuery.ajax({
            type: "POST",
            contentType: "application/json",
            data: "{ content: '" + content.value + "',id:'" + id + "',isSendForMessage:'" + check.checked + "'}",
            dataType: "json",
            url: "/Service/BlogService.asmx/ReplyMessageBoard",
            success: function(result) {
                var div = $(containerClientId + "_div");
                var editor = $(containerClientId + "_editor");
                var content = $(containerClientId + "_content");
                editor.src = "";
                content.value = "";
                div.style.display = "none";
                $(containerClientId + "_ReplyContent").innerHTML = result.d;
            }
        });
    }
}


/******************************************************************/
//删除留言
/******************************************************************/
function DeleteMessageBoard(id, param, dataDivId) {
    if (confirm("您确定删除这条留言吗？")) {       
        jQuery.ajax({
            type: "POST",
            contentType: "application/json",
            data: "{ id: '" + id + "'}",
            dataType: "json",
            url: "/Service/BlogService.asmx/DeleteMessageBoard",
            success: function(result) {
                InitMessageBoardListData(param, dataDivId, 1);
            }
        });
    }
}


/******************************************************************/
//加载视频列表
/******************************************************************/
function InitVideoListForUserData(param, dataDivId, pageIndex, rankStr, type) {

    var aParamValues = new Array();
    InitParams(param, aParamValues);
    aParamValues["DataDivId"] = dataDivId;
    var newsMenuId = aParamValues["NewsMenuId"];
    if (newsMenuId == null) newsMenuId = "0";
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ pageIndex:'" + pageIndex + "', pageSize:'" + aParamValues["PageSize"] + "',userId:'" + aParamValues["UserId"] + "',rankStr:'" + rankStr + "',type:'" + type + "',newsMenuId:'" + newsMenuId + "'}",
        dataType: "json",
        url: "/Service/VideoService.asmx/GetVideoListForUser",
        success: function(result) {
            var div = GetContentDiv(aParamValues);
            var list = InitFixed(result.d.List, aParamValues["PageSize"], 1);
            jQuery(div).addClass("clearfix VideoListBox");
            jQuery(div).html("");
            jQuery.each(list, function(i, item) {
                jQuery(div).append(CreateVideoListForUser(item, aParamValues, result.d.PlayForPoint));
            });
            jQuery(div).append(CreatePageNav(pageIndex, result.d.PageCount, "InitVideoListForUserData('" + param + "','" + dataDivId + "',{0}, '" + rankStr + "', '" + type + "')", "PageNav")); //文章列表分页样式
            InitContentDiv(aParamValues, div);
            jQuery("#divProgress").hide();
            SetAllVideoDemand();
        }
    });
}

//图片列表显示
function CreateVideoListForUser(item, aParamValues, playForPoint) {
    var str = "<div class=\"text-float-left TitleBox\" title='" + (item == null ? "" : item.Name) + "'>" +
                "<div class=\"VideoImage\" style=\"overflow: hidden; width: 128px; height: 96px;\">" +
                    "<a title='" + (item == null ? "" : "名称：" + item.Name + (playForPoint == 1 ? "\n观看点数：" + (item.Point == "0" ? "免费" : item.Point + "点") : "") + "\n播放：" + item.PlayCount + "\n评分：" + item.AverageScore + "\n评论：" + item.CommentCount + "\n收藏：" + item.FavoriteCount + "\n被顶数：" + item.TopCount + "\n被踩数：" + item.BottomCount + "\n引用：" + item.QuoteCount + "\n播放时间：" + item.PlayTimeStr) + "' href='" + (item == null ? "" : item.VideoUrl) + "' target=\"_blank\" style=\"display: " + (item == null ? "none" : "") + "\"><img src='" + (item == null ? "" : item.CoverImage) + "' width=\"100%\" height=\"100%\" border=\"0\"  /></a>" +
                    "<div style=\"position: relative; display: " + (item == null ? "none" : "") + "\">" +
                        "<img src=\"/Images/Video/qls.gif\" li=\"VideoDemand\" alt=\"添加到点播单\" style=\"cursor: pointer;display: none;\" onclick=\"javascript:SetDemandCookie('" + (item == null ? "" : item.PkId) + "', this)\" v='" + (item == null ? "" : item.PkId) + "' />" +
                    "</div>" +
                "</div>" +
                "<div class=\"text-float-left TitleIcon\" style=\"display: " + (item == null ? "none" : "") + "\"></div>" +
                "<div class=\"Title text-wrap1\" style=\"width: 128px;\">" +
                    "<a title='" + (item == null ? "" : "名称：" + item.Name + (playForPoint == 1 ? "\n观看点数：" + (item.Point == "0" ? "免费" : item.Point + "点") : "") + "\n播放：" + item.PlayCount + "\n评分：" + item.AverageScore + "\n评论：" + item.CommentCount + "\n收藏：" + item.FavoriteCount + "\n被顶数：" + item.TopCount + "\n被踩数：" + item.BottomCount + "\n引用：" + item.QuoteCount + "\n播放时间：" + item.PlayTimeStr) + "' href='" + (item == null ? "" : item.VideoUrl) + "' target=\"_blank\" style=\"display: " + (item == null ? "none" : "") + "\">" + (item == null ? "" : item.Name) + "</a><img src=\"/Images/Video/ico_locked.gif\" border=\"0\" align=\"absmiddle\" style=\"display: " + (item == null ? "none" : "") + "\" title='" + (item == null ? "" : (item.showCtrl == 1 ? "仅对好友公开" : "密码保护")) + "' />&nbsp;" +
                "</div>" +
                "<div class=\"UpLower text-wrap1\" style=\"width: 128px;\">" +
                    "<span style=\"display: " + (item == null ? "none" : "") + "\"><img src=\"/Images/Video/ico_up.gif\" />" + (item == null ? "" : item.TopCount) + "&nbsp;<img src=\"/Images/Video/ico_down.gif\" />" + (item == null ? "" : item.BottomCount) + "</span>&nbsp;" +
                "</div>" +               
                "<div class=\"Date text-wrap1\" style=\"width: 128px;\">" +
                    "<span style=\"display: " + (item == null ? "none" : "") + "\">发布:" + (item == null ? "" : item.DateStr) + "</span>&nbsp;" +
                "</div>" +
                "<div class=\"Play text-wrap1\" style=\"width: 128px;\">" +
                    "<span style=\"display: " + (item == null ? "none" : "") + "\">播放:" + (item == null ? "" : item.PlayCount) + "</span>&nbsp;" +
                "</div>" +
                "<div class=\"Comment text-wrap1\" style=\"width:128px;\">" +
                    "<span style=\"display: " + (item == null ? "none" : "") + "\">评论:" + (item == null ? "" : item.CommentCount) + "</span>&nbsp;" +
                "</div>" +
              "</div>";

    return str;
}



/******************************************************************/
//加载用户视频专辑列表
/******************************************************************/
function InitVideoAlbumListForUserData(param, dataDivId, pageIndex, rankStr, type) {

    var aParamValues = new Array();
    InitParams(param, aParamValues);
    aParamValues["DataDivId"] = dataDivId;
    var newsMenuId = aParamValues["NewsMenuId"];
    if (newsMenuId == null) newsMenuId = "0";
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ pageIndex:'" + pageIndex + "', pageSize:'" + aParamValues["PageSize"] + "',userId:'" + aParamValues["UserId"] + "',rankStr:'" + rankStr + "',type:'" + type + "',newsMenuId:'" + newsMenuId + "'}",
        dataType: "json",
        url: "/Service/VideoService.asmx/GetVideoAlbumListForUser",
        success: function(result) {
            var div = GetContentDiv(aParamValues);
            var list = InitFixed(result.d.List, aParamValues["PageSize"], 1);
            jQuery(div).addClass("clearfix VideoAlbumListBox");
            jQuery(div).html("");
            jQuery.each(list, function(i, item) {
                jQuery(div).append(CreateVideoAlbumListForUser(item, aParamValues));
            });
            jQuery(div).append(CreatePageNav(pageIndex, result.d.PageCount, "InitVideoAlbumListForUserData('" + param + "','" + dataDivId + "',{0}, '" + rankStr + "', '" + type + "')", "PageNav")); //文章列表分页样式
            InitContentDiv(aParamValues, div);
            jQuery("#divProgress").hide();
        }
    });
}

//图片列表显示
function CreateVideoAlbumListForUser(item, aParamValues) {
    var str = "<div class=\"TitleBox\" title='" + (item == null ? "" : item.Name) + "' style=\"clear:both;\">" +
                "<div class=\"VideoAlbumImage\" style=\"overflow: hidden; width: 128px; height: 96px;float:left;\">" +
                    "<a href='" + (item == null ? "" : item.AlbumListUrl) + "' target=\"_blank\" style=\"display: " + (item == null ? "none" : "") + "\"><img src='" + (item == null ? "" : item.CoverImage) + "' width=\"100%\" height=\"100%\" border=\"0\" alt='" + (item == null ? "" : item.Name) + "' onerror=\"javascript:this.src='/Images/Video/icon_video.jpg'\"  /></a>" +
                "</div>" +
                "<div style=\"float:left;\">" +
                    "<div class=\"text-float-left TitleIcon\" style=\"display: " + (item == null ? "none" : "") + "\"></div>" +
                    "<div class=\"Title text-wrap1\">" +
                        "<a href='" + (item == null ? "" : item.AlbumListUrl) + "' target=\"_blank\" style=\"display: " + (item == null ? "none" : "") + "\">" + (item == null ? "" : item.Name) + "</a>&nbsp;" +
                    "</div>" +
                    "<div class=\"Intro text-wrap1\">" +
                        "<span style=\"display: " + (item == null ? "none" : "") + "\">" + (item == null ? "" : item.Intro) + "</span>&nbsp;" +
                    "</div>" +
                    "<div class=\"Info text-wrap1\">" +
                        "<span style=\"display: " + (item == null ? "none" : "") + "\">视频:" + (item == null ? "" : item.VideoCount) + " | 播放:" + (item == null ? "" : item.PlayCount) + "</span>&nbsp;" +
                    "</div>" +
                    "<ul class=\"VideoListBox\">" +
                    (item == null ? "" : CreateAlbumVideoListForUser(item.VideoList)) +
                    "</ul>" +
                    "<div class=\"PlayNav\">" +
                        "<span style=\"display: " + (item == null ? "none" : "") + "\"><a href=\"" + (item == null ? "" : item.AlbumListUrl) + "\" target=\"_blank\">本专辑全部视频列表</a> | <a href=\"" + (item == null ? "" : item.AlbumPlayUrl) + "\" target=\"_blank\">全部播放</a></span>&nbsp;" +
                    "</div>" +
                "</div>" +
              "</div>";

    return str;
}

function CreateAlbumVideoListForUser(list) {
    var str = "";
    jQuery.each(list, function() {
        str += "<li class=\"VideoName\"><a href='" + this.VideoUrl + "' target=\"_blank\">" + this.Name + "</a></li>";
    });
    return str;
}



