﻿/// <reference path="jQuery.js" />

/******************************************************************/
//子网站横幅
/******************************************************************/
function InitSubSiteBannerData(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("SubSiteBanner", "BannerBox");
        h = GetCssHeight("SubSiteBanner", "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 InitSubSiteArticleListData(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["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: "{ subSiteId: '" + aParamValues["SubSiteId"] + "',pageIndex:'" + pageIndex + "', pageSize:'" + aParamValues["PageSize"] + "',subSiteArticleCategoryId:'" + aParamValues["CategoryId"] + "',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"]) + "',linkTarget:'" + (aParamValues["LinkTarget"] == null ? 0 : aParamValues["LinkTarget"]) + "'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/GetSubSiteArticleList",
        success: function(result) {
            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(CreateSubSiteArticleListForPic(item, aParamValues));
                }
                else {
                    switch (aParamValues["PostShowMode"]) {
                        case "0":
                            jQuery(div).append(CreateSubSiteArticleSummaryList(item, aParamValues));
                            if (item != null)
                                jQuery(div).append(CreateFuncNav(item, aParamValues));
                            break;
                        case "1":
                            jQuery(div).append(CreateSubSiteArticleList(item, aParamValues));
                            break;
                    }
                }
            });
            if (aParamValues["IsShowPageNav"] == "1") {
                jQuery(div).append(CreatePageNav(pageIndex, result.d.PageCount, "InitSubSiteArticleListData('" + param + "','" + dataDivId + "',{0})", "PageNav")); //文章列表分页样式
            }
            InitContentDiv(aParamValues, div);
            SetAllVideoArticleImage();
        }
    });
}
/******************************************************************/
//加载子网站文章列表数据(针对专题)
/******************************************************************/
function InitSubSiteSpecialArticleListData(param, dataDivId, isImageArticleCategory, pageIndex) {
    var aParamValues = new Array();
    InitParams(param, aParamValues);
    aParamValues["DataDivId"] = dataDivId;
    aParamValues["IsImageArticleCategory"] = isImageArticleCategory;
    if (aParamValues["IsShowPageNav"] == "1") {
        aParamValues["PageIndex"] = pageIndex;
        aParamValues["PageScript"] = "InitSubSiteSpecialArticleListData('" + param + "','" + dataDivId + "'," + isImageArticleCategory + " ,{0})";
    }
    var dataDiv = document.getElementById(dataDivId);
    if (dataDiv.innerHMTL == "") {
        dataDiv.innerText = "数据加载中...";
    }

    if (aParamValues["MoreMenuId"] == null) {
        aParamValues["MoreMenuId"] = 0;
    }
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ subSiteId: '" + aParamValues["SubSiteId"] + "',pageIndex:'" + pageIndex + "', pageSize:'" + aParamValues["PageSize"] + "',specialId:'" + aParamValues["SpecialId"] + "',dns:'" + aParamValues["ReqDns"] + "',moreMenuId:'" + aParamValues["MoreMenuId"] + "'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/GetSubSiteArticleListForAssociateSearch",
        success: function(result) {
            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(CreateSubSiteArticleList(item, aParamValues));
            });
            if (aParamValues["IsShowPageNav"] == "1") {
                jQuery(div).append(CreatePageNav(pageIndex, result.d.PageCount, "InitSubSiteSpecialArticleListData('" + param + "','" + dataDivId + "'," + isImageArticleCategory + " ,{0})", "PageNav")); //文章列表分页样式
            }
            InitContentDiv(aParamValues, div);
        }
    });
}



//图片列表显示
function CreateSubSiteArticleListForPic(item, aParamValues) {
    var str = "<div class=\"text-float-left TitleBox\" title=\"" + (item == null ? "" : item.OriTitle) + "\">" +
                  "<div class=\"Photo\" style=\"width:" + aParamValues["ImageWidth"] + ";height:" + aParamValues["ImageHeight"] + ";\">" + (item == null ? "" : "<a href=" + item.Url + " target='"+(item.OpenMode==1 ? "_blank" : "_self")+"'>" + 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 CreateSubSiteArticleList(item, aParamValues) {
    var str = "<div class=\"TitleBox\" title=\"" + (item == null ? "" : item.OriTitle) + "\">";
    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='"+(item.OpenMode==1 ? "_blank" : "_self")+"'>" + item.Title + "</a>") + "</div>";
    str += "</div>";
    return str;

}
//文章摘要列表显示
function CreateSubSiteArticleSummaryList(item, aParamValues) {
    var str = "<div class=\"TitleBox\" title=\"" + (item == null ? "" : item.OriTitle) + "\">";
    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='"+(item.OpenMode==1 ? "_blank" : "_self")+"'>" + item.Title + "</a>") + "</div>";
    if (item != null && item.PasswordAccess == 3) {
        str += "<div class='PwdFont' width=\"100%\" align=\"center\" id=\"SubSiteArticleList_Pwd_" + item.ArticleId + "\">" + "请输入访问密码：<input type=\"password\" class='PwdBox' name=\"SubSiteArticleAccessPwd\" onfocus=\"setKeyDown('SubSiteArticleAccessPwd_" + item.ArticleId + "','SubSiteArticleAccessPwd_" + item.ArticleId + "','btnSubSiteArticleAccessPwd" + item.ArticleId + "')\" id=\"SubSiteArticleAccessPwd_" + item.ArticleId + "\"><input id=\"btnSubSiteArticleAccessPwd" + item.ArticleId + "\" class='PwdButton' type=\"button\" onclick=\"javascript:CheckSubSiteArticlePwdAccess(" + item.ArticleId + ");\" value=\"确定\"  />" + "</div>";
        str += "<div class=\"text-wrap Brief\" style=\"display:none;\" id=\"" + (item == null ? "&nbsp;" : "SubSiteArticleList_" + item.ArticleId) + "\">" + (item == null ? "" : item.Brief) + "</div>";
    }
    else {
        str += "<div class=\"text-wrap Brief\" id=\"" + (item == null ? "&nbsp;" : "SubSiteArticleList_" + item.ArticleId) + "\">" + (item == null ? "" : item.Brief) + "</div>";
    }

    str += "<div class=\"View\">" + (item == null ? "&nbsp;" : "<a href=" + item.Url + " target='"+(item.OpenMode==1 ? "_blank" : "_self")+"'>[查看全文]</a>") + "</div></div>";

    return str;

}
//文章密码验证
function CreateSubSiteArticlePwdForRepeater(ArticleId) {
    var str = "";
    str = "<div class='PwdFont' width=\"100%\" align=\"center\" id=\"SubSiteArticleList_Pwd_" + ArticleId + "\">" + "请输入访问密码：<input type=\"password\" class='PwdBox' name=\"SubSiteArticleAccessPwd\" onfocus=\"setKeyDown('SubSiteArticleAccessPwd_" + ArticleId + "','SubSiteArticleAccessPwd_" + ArticleId + "','btnSubSiteArticleAccessPwd" + ArticleId + "')\" id=\"SubSiteArticleAccessPwd_" + ArticleId + "\"><input id=\"btnSubSiteArticleAccessPwd" + ArticleId + "\" class='PwdButton' type=\"button\" onclick=\"javascript:CheckSubSiteArticlePwdAccess(" + ArticleId + ");\" value=\"确定\"  />" + "</div>";

    return str;
}
//功能导航
function CreateFuncNav(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 + ",4,'" + 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 AddGuestBookMessage(guestBookId, objectId) {
    openWindow('../OperationManage/AddGuestBookMessage.aspx?type=3&oid=' + objectId + '&gid=' + guestBookId, '480', '450', '我要留言', false);
}

/******************************************************************/
//查看留言信息
/******************************************************************/
function ViewGuestBookMessage(guestBookMessageId, objectId) {
    openWindow('../OperationManage/ViewGuestBookMessage.aspx?gid=' + guestBookMessageId + '&oid=' + objectId + '&type=3', '500', '410', '查看留言信息', false);
}

/******************************************************************/
//处理留言信息
/******************************************************************/
function DealGuestBookMessage(guestBookMessageId, objectId) {
    openWindow('../SystemManage/DealGuestBookMessage.aspx?gid=' + guestBookMessageId + '&oid=' + objectId + '&type=3', '500', '410', '处理留言信息', false);
}

/******************************************************************/
//查看保密信息
/******************************************************************/
function ViewSecrecyGuestBookMessage(snId, spId, objectId) {
    var sn = $(snId).value;
    var sp = $(spId).value;
    openWindow('../OperationManage/ViewSecrecyGuestBookMessage.aspx?sn=' + sn + '&sp=' + sp + '&oid=' + objectId + '&type=3', '500', '450', '查看保密留言信息', true);
}

/******************************************************************/
//加载网站留言信息
/******************************************************************/
function InitSubSiteGuestBookMessageListData(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["MoreMenuId"] == null) {
        aParamValues["MoreMenuId"] = 0;
    }
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ pageIndex:'" + pageIndex + "', pageSize:'" + aParamValues["PageSize"] + "',guestBookId:'" + aParamValues["GuestBookId"] + "',moreMenuId:'" + aParamValues["MoreMenuId"] + "',subSiteId:'" + aParamValues["SubSiteId"] + "', dns: '" + aParamValues["ReqDns"] + "',guestBookFrom:'" + (aParamValues["GuestBookFrom"] == null ? 0 : aParamValues["GuestBookFrom"]) + "', guestBookGroupId:'" + aParamValues["GuestBookGroupId"] + "',isShowNoReplyMessage:'"+(aParamValues["IsShowNoReplyMessage"] == null ? 0 : aParamValues["IsShowNoReplyMessage"])+"'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/GetSubSiteGuestBookMessageList",
        success: function(result) {
            var div = GetContentDiv(aParamValues);
            var list = InitFixed(result.d.CList, aParamValues["PageSize"], aParamValues["IsFixed"]);
            jQuery(div).addClass("clearfix Box");
            jQuery(div).html("");
            jQuery.each(list, function(i, item) {
                switch (aParamValues["PostShowMode"]) {
                    case "0":
                        jQuery(div).append(CreateSubSiteGuestBookMessageList(item, aParamValues));
                        break;
                    case "1":
                        jQuery(div).append(CreateSubSiteGuestBookMessageListForTile(item, aParamValues));
                        break;
                }
            });
            if (aParamValues["IsShowPageNav"] == "1") {
                jQuery(div).append(CreatePageNav(pageIndex, result.d.PageCount, "InitSubSiteGuestBookMessageListData('" + param + "','" + dataDivId + "' ,{0})", "PageNav")); //文章列表分页样式
            }
            InitContentDiv(aParamValues, div);
        }
    });
}

//列表显示
function CreateSubSiteGuestBookMessageList(item, aParamValues) {
    var str = "<div class=\"TitleBox\" title=\"" + (item == null ? "&nbsp;" : item.Title) + "\">" +
              "<div class=\"text-float-right Time\" title=\"" + (item == null ? "&nbsp;" : "发布时间：" + new Date(parseInt(item.CreateTime.substring(6, item.CreateTime.length - 2))).formatt("yyyy-MM-dd hh:mm:ss")) + "\">" + (item == null ? "&nbsp;" : new Date(parseInt(item.CreateTime.substring(6, item.CreateTime.length - 2))).formatt("yyyy-MM-dd")) + "</div>" +
              "<div class=\"text-float-right ViewCount\" title=\"浏览次数\">" + (item == null ? "&nbsp;" : item.Click) + "</div>";
    if (aParamValues["IsShowUser"] == 1) {
        str += "<div class=\"text-float-right Name\" title=\"发布者\">" + item.UserName + "</div>";
    }
    str += "<div class=\"text-float-left TitleIcon\"></div>";

    if (aParamValues["IsShowGuestBook"] == 1) {
        str += "<div class=\"text-float-left Category\" title=\"所属留言咨询\">" + (item == null ? "&nbsp;" : "<a href=" + item.GuestBookUrl + " target=\"_blank\">" + item.GuestBookName + "</a>") + "</div>";
    }
    
    if (item != null && item.IsReply == 1) {
        str += "<div class=\"text-overflow Title\"><a href='javascript:' onclick='javascript:ViewGuestBookMessage(" + item.PkId + ",1," + aParamValues["SubSiteId"] + ")'>[<font color=red>已回复</font>]" + item.Title + "</a></div>";
    }
    else {
        str += "<div class=\"text-overflow Title\"><a href='javascript:' onclick='javascript:ViewGuestBookMessage(" + item.PkId + ",1," + aParamValues["SubSiteId"] + ")'>" + item.Title + "</a></div>";
    }
    str += "</div>";

    return str;
}

//平铺显示
function CreateSubSiteGuestBookMessageListForTile(item, aParamValues) {
    var content = document.createElement("div");
    var link = document.createElement("div");
    var title = document.createElement("div");


    var sname = document.createElement("div");
    sname.className = 'text-float-right Name'; //回复者名称样式	
    sname.innerHTML = item == null ? "&nbsp;" : item.ReplyUserName;
    sname.style["padding-left"] = "5px";
    sname.title = "回复者";
    link.appendChild(sname);

    var stime = document.createElement("div");
    stime.className = 'text-float-right Time'; //回复时间样式
    stime.innerHTML = item == null ? "&nbsp;" : "回复时间：" + new Date(parseInt(item.ReplyTime.substring(6, item.ReplyTime.length - 2))).formatt("yyyy-MM-dd");
    stime.style["padding-left"] = "5px";
    stime.title = item == null ? "&nbsp;" : "回复时间：" + new Date(parseInt(item.ReplyTime.substring(6, item.ReplyTime.length - 2))).formatt("yyyy-MM-dd hh:mm:ss");
    link.appendChild(stime);

    var sviewcount = document.createElement("div");
    sviewcount.className = 'text-float-right ViewCount'; //浏览次数样式	
    sviewcount.innerHTML = item == null ? "&nbsp;" : "浏览：" + item.Click;
    sviewcount.style["padding-left"] = "5px";
    sviewcount.title = "浏览次数";
    link.appendChild(sviewcount);

    if (aParamValues["IsShowUser"] == 1) {
        var suser = document.createElement("div");
        suser.className = 'text-float-right Name'; //发布者名称样式	    
        suser.innerHTML = "来自：" + item.UserName;
        suser.style["padding-left"] = "5px";
        suser.title = "发布者";
        title.appendChild(suser);
    }

    var supdate = document.createElement("div");
    supdate.className = 'text-float-right Time'; //发布时间样式
    supdate.innerHTML = item == null ? "&nbsp;" : new Date(parseInt(item.CreateTime.substring(6, item.CreateTime.length - 2))).formatt("yyyy-MM-dd");
    supdate.style["padding-left"] = "5px";
    supdate.title = item == null ? "&nbsp;" : "发布时间：" + new Date(parseInt(item.CreateTime.substring(6, item.CreateTime.length - 2))).formatt("yyyy-MM-dd hh:mm:ss");
    title.appendChild(supdate);

    var sicon = document.createElement("div");
    sicon.className = "text-float-left TitleIcon";
    title.appendChild(sicon);

    if (aParamValues["IsShowGuestBook"] == 1) {
        var cate = document.createElement("div");
        cate.className = "text-float-left Category";
        cate.title = "所属留言咨询";
        cate.innerHTML = item == null ? "&nbsp;" : "<a href=" + item.GuestBookUrl + " target=\"_blank\">" + item.GuestBookName + "</a>";
        title.appendChild(cate);
    }

    var s2 = document.createElement("div");
    s2.className = 'text-overflow Title'; //标题样式
    s2.title = item == null ? "&nbsp;" : item.Title;
    s2.style["padding-left"] = "5px";
    if (item != null && item.IsReply == 1) {
        s2.innerHTML = "<a href='javascript:' onclick='javascript:ViewGuestBookMessage(" + item.PkId + ",1," + aParamValues["SubSiteId"] + ")'>[<font color=red>已回复</font>]" + item.Title + "</a>";
    }
    else {
        s2.innerHTML = "<a href='javascript:' onclick='javascript:ViewGuestBookMessage(" + item.PkId + ",1," + aParamValues["SubSiteId"] + ")'>" + item.Title + "</a>";
    }
    title.appendChild(s2);

    var sreport = document.createElement("div");
    sreport.className = "Reply"; //我要举报样式
    sreport.align = "left";
    sreport.innerHTML = item == null ? "&nbsp;" : "<a href='javascript:' onclick=\"javascript:DealGuestBookMessage(" + item.PkId + ",1," + aParamValues["SubSiteId"] + ")\">回复处理</a>";
    link.appendChild(sreport)

    var str = "<table width=\"100%\"  border=\"0\" cellspacing=\"0\" class=TitleBox cellpadding=\"0\"><tr>"
	          + "<td valign=\"top\">" + title.innerHTML + "</td><td width=\"0\"></td>"
	          + "</tr><tr>"
	          + "<td class=Content valign=\"top\" align=left style=\"padding-left:5px\">" + (item == null ? "&nbsp;" : item.Content) + "</td></tr><tr>"
	          + "<td class=ReplyContent valign=\"top\" align=left style=\"padding-left:5px\"><div class=ReplyContentTip>回复内容：</div>" + (item == null ? "&nbsp;" : item.ReplyContent) + "</td>"
	          + "</tr><tr>"
	          + "<td valign=\"top\">" + link.innerHTML + "</td>"
	          + "</tr></table>";

    return str;
}

/******************************************************************/
//子网站文章签收
/******************************************************************/
function LogReceiptData(articleId, userId, userName, isReceipt, subSiteId) {
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ articleId: '" + articleId + "',userId:'" + userId + "',userName:'" + userName + "', isReceipt:'" + isReceipt + "',subSiteId:'" + subSiteId + "'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/LogReceiptData"
    });
}



/******************************************************************/
//加载文章评论
/******************************************************************/
function InitArticleComments(articleId) {
    document.getElementById("Comments").innerText = "数据加载中...";
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ articleId: '" + articleId + "'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/GetSubSiteCommentsByArticleId",
        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 CheckSubSitePwdAccess(subSiteId) {
    var password = jQuery("#AccessPwd").val();
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ pwd: '" + password + "',subSiteId:'" + subSiteId + "'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/CheckSubSitePwdAccess",
        success: function(result) {
            if (result.d == false) {
                _error_msg_show("您输入的密码不正确，请重试!", '', 'sorry', "错误");
            }
            else {
                _error_msg_show("重定向中，请稍候...", '', 'succ', "成功");
                location.href = document.location;
            }
        }
    });
}

/******************************************************************/
//子网站文章密码访问处理
/******************************************************************/
function CheckSubSiteArticlePwdAccess(articleId) {
    var password = jQuery("#SubSiteArticleAccessPwd_" + articleId).val();
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ pwd: '" + password + "',pkId:'" + articleId + "'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/CheckSubSiteArticlePwdAccess",
        success: function(result) {
            if (result.d == 0) {
                _error_msg_show("您输入的密码不正确，请重试!", '', 'sorry', "错误");
            }
            else {
                jQuery("#SubSiteArticleList_" + result.d).show();
                jQuery("#SubSiteArticleList_Pwd_" + result.d).hide();
            }
        }
    });
}

//具体显示文章时密码验证处理(与列表中验证有所区别)
function CheckSubSiteArticlePwdAccess1(articleId, param, dataDivId, commentsId, menuId) {

    var password = jQuery("#SubSiteArticleAccessPwd").val();
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ pwd: '" + password + "',pkId:'" + articleId + "'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/CheckSubSiteArticlePwdAccess",
        success: function(result) {
            if (result.d == 0) {
                _error_msg_show("您输入的密码不正确，请重试!", '', 'sorry', "错误");
            }
            else {
                _error_msg_show("重定向中，请稍候...", '', 'succ', "成功");
                location.href = document.location;
            }
        }
    });
}

/******************************************************************/
//文章搜索模块
/******************************************************************/
function RedirectToSearch(param, txtId, typeId, subSiteId) {
    var aParamValues = new Array();
    InitParams(param, aParamValues);

    if ($(txtId).value.Trim() == "") {
        _error_msg_show("请输入查询关键字", '', 'smile', "提醒");
    }
    else {
        location.href = "/OperationManage/SubSiteMoreIndex.aspx?pkId=" + aParamValues["MoreMenuId"] + "&subSiteId=" + subSiteId + "&kw=" + escape($(txtId).value) + "&st=" + $(typeId).value + "&t=1";

    }
}

/******************************************************************/
//加载子网站文章搜索
/******************************************************************/
function InitSubSiteArticleSearchListData(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: "{ subSiteId: '" + aParamValues["SubSiteId"] + "',pageIndex:'" + pageIndex + "', pageSize:'" + aParamValues["PageSize"] + "',kw:'" + aParamValues["SearchKeyWord"] + "',type:'" + aParamValues["SearchType"] + "',dns:'" + aParamValues["ReqDns"] + "'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/GetSubSiteArticleSearchList",
        success: function(result) {
            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(CreateSubSiteArticleList(item, aParamValues));
            });
            if (aParamValues["IsShowPageNav"] == "1") {
                jQuery(div).append(CreatePageNav(pageIndex, result.d.PageCount, "InitSubSiteArticleSearchListData('" + param + "','" + dataDivId + "' ,{0})", "PageNav")); //文章列表分页样式
            }
            InitContentDiv(aParamValues, div);
        }
    });
}

function LogSubSiteArticleCount(articleId, subSiteId) {
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ articleId: '" + articleId + "',subSiteId:'" + subSiteId + "'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/LogSubSiteArticleCount"
    });
}

/******************************************************************/
//访问记录
/******************************************************************/
function LogSubSiteIndexCount(subSiteId) {
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ subSiteId: '" + subSiteId + "'}",
        dataType: "json",
        url: "/Service/SubSiteService.asmx/LogSubSiteIndexCount"
    });    
}



/******************************************************************/
//频道轮播操作
/******************************************************************/
var PlayItem;
function SetSubSiteChannelPlay(partId, obj, playId, channelId, nameId, subSiteId) {
    jQuery("#" + partId + " li[t=Name]").removeClass().addClass("Name");
    jQuery("#" + partId + " li[t=Image]").hide();
    jQuery(obj).parent().removeClass().addClass("Name").addClass("Selected");
    jQuery(obj).parent().prev().show();
    GetStartSubSitePlayVideo(playId, channelId, nameId, subSiteId);
}
//一个视频播放后自动播放下面一个视频
function GetNextSubSitePlayVideo(playId, nameId, subSiteId) {
    SetCookie("Edjoy_SubSiteVideoChannelPlay_" + PlayItem.ChannelId, PlayItem.ChannelItemId + "@" + PlayItem.VideoId);
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ channelId:'" + PlayItem.ChannelId + "', itemId : '" + PlayItem.ChannelItemId + "', currentVideoId: '" + PlayItem.VideoId + "', subSiteId:'"+subSiteId+"'}",
        dataType: "json",
        url: "/Service/VideoService.asmx/GetNextSubSiteChannelPlayVideo",
        success: function(result) {
            var item = result.d;
            PlaySubSiteChannelVideo(item, playId, nameId);
        }
    });
}

function GetStartSubSitePlayVideo(playId, channelId, nameId, subSiteId) {
    
    if (!PlaySubSiteCookieVideo(channelId, playId, nameId, subSiteId)) {
        jQuery.ajax({
            type: "POST",
            contentType: "application/json",
            data: "{ channelId:'" + channelId + "', subSiteId:'"+subSiteId+"'}",
            dataType: "json",
            url: "/Service/VideoService.asmx/GetNextSubSiteVideoFromStart",
            success: function(result) {
                var item = result.d;
                PlaySubSiteChannelVideo(item, playId, nameId);
            }
        });
    }
}

function PlaySubSiteCookieVideo(channelId, playId, nameId, subSiteId) {

    var cookie = GetCookie("Edjoy_SubSiteVideoChannelPlay_" + channelId);
    if (cookie == null) {
        return false;
    }
    else {
        var ss = cookie.split('@');
        var itemId = parseInt(ss[0], 10);
        var videoId = parseInt(ss[1], 10);
        if (isNaN(itemId) || isNaN(videoId)) {
            return false;
        }
        else {
            jQuery.ajax({
                type: "POST",
                contentType: "application/json",
                data: "{ channelId:'" + channelId + "', itemId : '" + itemId + "', currentVideoId: '" + videoId + "', subSiteId:'"+subSiteId+"'}",
                dataType: "json",
                url: "/Service/VideoService.asmx/GetNextSubSiteChannelPlayVideo",
                success: function(result) {
                    var item = result.d;
                    PlaySubSiteChannelVideo(item, playId, nameId);
                }
            });
            return true;
        }
    }
}

function PlaySubSiteChannelVideo(item, playId, nameId) {
    var flashvars = {
        image: item.ImageUrl,
        file: item.FlvUrl,
        autostart: true,
        skin: "/Tools/Skins/modieus/modieus.swf",
        wmode: "Opaque",
        controlbar: "none",
        displayclick: "fullscreen",
        videoid: item.VideoId,
        isarticlevideo: false,
        servertype: "" + item.ServerType + "",
        serverurl: "" + item.Prex + ""  
    };
    var params = {
        allowfullscreen: true,
        allowscriptaccess: "always",
        wmode: "Opaque"
    };
    parent.swfobject.embedSWF("/Tools/player.swf", playId, "100%", "100%", "9.0.0", "/Tools/expressInstall.swf", flashvars, params);
    if (item.VideoId != "0") {
        jQuery("#" + playId + "Image").hide();
        jQuery("#" + playId).show();
        jQuery("#" + nameId).text(item.ItemName + "-->" + item.VideoName);
        PlayItem = item;
    }
    else {
        jQuery("#" + nameId).text("");
        jQuery("#" + playId).hide();
        jQuery("#" + playId + "Image").show().html("<img src=\"/Images/Video/NochannelVideo.jpg\" align=\"absmiddle\" border=\"0\" width=\"100%\" height=\"100%\" />");
    }
}



/******************************************************************/
//加载视频评论
/******************************************************************/
function InitVideoCommentList(videoId, t, pageIndex) {
    if (t == null) t = 0;
    document.getElementById("Comments").innerText = "数据加载中...";
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ videoId:'" + videoId + "', t:'" + t + "', pageIndex:'" + pageIndex + "'}",
        dataType: "json",
        url: "/Service/SystemService.asmx/GetVideoComments",
        success: function(result) {
            jQuery("#Comments").html("");
            jQuery.each(result.d.List, function(i, item) {
                jQuery("#Comments").append(CreateResourceCommentList(item, i));
            });
            jQuery("#CommentCount").text(result.d.RecordCount);
            jQuery("#Comments").append(CreatePageNav(pageIndex, result.d.PageCount, "InitVideoCommentList('" + videoId + "','" + t + "',{0})", "PageNav"));
        }
    });
}
function CreateResourceCommentList(item, i) {
    var content = document.createElement("div");
    var link = document.createElement("div");
    var photo = document.createElement("div");
    var title = document.createElement("div");
    var user = document.createElement("div");

    var stime = document.createElement("div");
    stime.className = 'text-float-left Date'; //回复时间样式	
    stime.innerHTML = item.UpdateTimeStr;
    stime.style["padding-left"] = "5px";
    stime.title = "评论时间：" + new Date(parseInt(item.CreateTime.substring(6, item.CreateTime.length - 2))).formatt("yyyy-MM-dd hh:mm:ss");
    link.appendChild(stime);

    var suser = document.createElement("div");
    suser.className = 'text-float-left Name'; //发布者名称样式
    if (item.UserUrl == "") {
        suser.innerHTML = item.UserName;
    }
    else {
        suser.innerHTML = "<a href=" + item.UserUrl + " >" + item.UserName + "</a>";
    }
    suser.style["padding-left"] = "5px";
    suser.title = "评论者";
    link.appendChild(suser);



    if (item.UserUrl == "") {
        photo.innerHTML = item.UserPhoto;
    }
    else {
        photo.innerHTML = "<a href=" + item.UserUrl + ">" + 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%";
    }
    content.appendChild(photo);
    var str = "<table width=\"96%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=Table><tr><td rowspan=\"3\" width=\"50px\" valign=\"top\">" + content.innerHTML + "</td>"
	          + "<td valign=\"top\">" + link.innerHTML + "</td><td class=Iden valign=\"top\" align=\"right\">" + item.UserIden + "</td>"
	          + "</tr><tr>"
	          + "<td colspan=\"2\" class=Content valign=\"top\" align=left style=\"padding-left:5px\">" + item.Content + "</td>"
	          + "</tr><tr>"
	          + "<td colspan=\"2\" valign=\"top\" align=right class=Pos><a href=\"#Discuss\" onclick=\"javascript:ResourceComments('@" + item.UserName + "：\\r\\n')\">回复</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#top\" title='回到顶部'><img src='/Images/icon_up_gray.gif' boder=0/></a></td>"
	          + "</tr></table>";

    return str;
}
function ResourceComments(name) {

    document.getElementById("frmResourceComments").contentWindow.SetContent(name);
}



/******************************************************************/
//加载子网站视频列表
/******************************************************************/
function InitSubSiteVideoListData(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"] + "',categoryId:'" + aParamValues["VideoCategoryId"] + "',rankStr:'" + rankStr + "',type:'" + type + "',newsMenuId:'" + newsMenuId + "',subSiteId:'" + aParamValues["SubSiteId"] + "', dns:'" + aParamValues["ReqDns"] + "'}",
        dataType: "json",
        url: "/Service/VideoService.asmx/GetSubSiteVideoList",
        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(CreateSubSiteVideoList(item, aParamValues, result.d.PlayForPoint));
            });
            jQuery(div).append(CreatePageNav(pageIndex, result.d.PageCount, "InitSubSiteVideoListData('" + param + "','" + dataDivId + "',{0}, '" + rankStr + "', '" + type + "')", "PageNav")); //文章列表分页样式
            InitContentDiv(aParamValues, div);
            jQuery("#divProgress").hide();
            SetAllVideoDemand();
        }
    });
}

//图片列表显示
function CreateSubSiteVideoList(item, aParamValues, playForPoint) {
    var str = "<ul class=\"text-float-left TitleBox\" >" +
                "<li class=\"VideoImage\" style=\"overflow: hidden; width:" + aParamValues["ImageWidth"] + ";height:" + aParamValues["ImageHeight"] + ";\">" +
                    "<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>" +
                "</li>" +
                "<li class=\"text-float-left TitleIcon\" style=\"display: " + (item == null ? "none" : "") + "\"></li>" +
                "<li 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" : (item.ShowCtrl == 0 ? "none" : "")) + "\" title='" + (item == null ? "" : (item.ShowCtrl == 1 ? "仅对好友公开" : "密码保护")) + "' />&nbsp;<span class=\"PlayTime\">" + (item == null ? "" : item.PlayTimeStr) + "</span>" +
                "</li>" +
                "<li 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;" +
                "</li>" +
                "<li class=\"User text-wrap1\" style=\"width: 128px;\">" +
                    "<span style=\"display: " + (item == null ? "none" : "") + "\">用户:" + (item == null ? "" : (item.IsSystem == 1 ? "管理员发布" : "<a href='" + (item == null ? "" : item.UserUrl) + "' target='_blank'>" + (item == null ? "" : item.UserName) + "</a>")) + "</span>&nbsp;" +
                "</li>" +
                "<li class=\"Date text-wrap1\" style=\"width: 128px;\">" +
                    "<span style=\"display: " + (item == null ? "none" : "") + "\">发布:" + (item == null ? "" : item.DateStr) + "</span>&nbsp;" +
                "</li>" +
                "<li class=\"Play text-wrap1\" style=\"width: 128px;\">" +
                    "<span style=\"display: " + (item == null ? "none" : "") + "\">播放:" + (item == null ? "" : item.PlayCount) + "</span>&nbsp;" +
                "</li>" +
                "<li class=\"Comment text-wrap1\" style=\"width:128px;\">" +
                    "<span style=\"display: " + (item == null ? "none" : "") + "\">评论:" + (item == null ? "" : item.CommentCount) + "</span>&nbsp;" +
                "</li>" +
              "</ul>";

    return str;
}


/******************************************************************/
//视频以及专辑搜索模块
/******************************************************************/
function RedirectToSubSiteVideoSearch(param, txtId, typeId) {
    var aParamValues = new Array();
    InitParams(param, aParamValues);

    if ($(txtId).value.Trim() == "") {
        _error_msg_show("请输入查询关键字", '', 'smile', "提醒");
    }
    else {
        location.href = "/OperationManage/SubSiteMoreIndex.aspx?pkId=" + aParamValues["MoreMenuId"] + "&subSiteId=" + aParamValues["SubSiteId"] + "&kw=" + escape($(txtId).value) + "&t=" + $(typeId).value + "&st=0";

    }
}


/******************************************************************/
//加载视频搜索列表
/******************************************************************/
function InitSubSiteVideoSearchListData(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"] + "',kw:'" + aParamValues["SearchKeyWord"] + "',rankStr:'" + rankStr + "',type:'" + type + "',newsMenuId:'" + newsMenuId + "', subSiteId:'" + aParamValues["SubSiteId"] + "', dns:'" + aParamValues["ReqDns"] + "'}",
        dataType: "json",
        url: "/Service/VideoService.asmx/GetSubSiteVideoSearchList",
        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(CreateSubSiteVideoList(item, aParamValues, result.d.PlayForPoint));
            });
            jQuery(div).append(CreatePageNav(pageIndex, result.d.PageCount, "InitSubSiteVideoSearchListData('" + param + "','" + dataDivId + "',{0},  '" + rankStr + "','" + type + "')", "PageNav")); //文章列表分页样式
            InitContentDiv(aParamValues, div);
            jQuery("#divProgress").hide();
            SetAllVideoDemand();
        }
    });
}
