<%@ Page Language="C#" MasterPageFile="~/User/Main.Master" EnableViewState="true"
    Theme="Default" AutoEventWireup="true" CodeBehind="CustomerServiceView.aspx.cs"
    Inherits="OAWeb.User.CustomerServiceView" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register Src="/UserControls/UserLeft.ascx" TagName="TaskNav" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlace" runat="server">
    <div class="w main">
        <div class="right">
            <table class="data_title" cellspacing="3">
                <tr>
                    <td class="data_caption">
                        咨询详细
                    </td>
                </tr>
            </table>
            <style>
                .TableBorder tr td
                {
                    height: 20px;
                }
            </style>
            <style>
                .FileList
                {
                    margin-left: 10px;
                    margin-right: 10px;
                    text-align: left;
                    padding-top: 5px;
                    padding-bottom: 5px;
                    margin-top: 5px;
                }
                
                .FileList table
                {
                    width: 100%;
                }
                
                .FileList table tr td
                {
                    line-height: 25px;
                    font-size: 13px;
                }
                
                .HoverFileList
                {
                    
                    margin-left: 10px;
                    margin-right: 10px;
                    text-align: left;
                    padding-top: 5px;
                    padding-bottom: 5px;
                    margin-top: 5px;
                }
                
                .pubreply_fed
                {
                    margin-left: 10px;
                    margin-right: 10px;
                    background: #F9F9F9 none repeat scroll 0 0;
                    border: 1px solid #E9E9E9;
                }
                .reply
                {
                    color: #2889A8;
                    margin-right: 15px;
                }
                .reply a
                {
                    color: #aaaaaa;
                }
                .HoverFileList .reply
                {
                    margin-right: 15px;
                }
                
                
                .ReplyList
                {
                    margin-left: 10px;
                    margin-right: 10px;
                    text-align: left;
                }
                
                .ReplyList table
                {
                    width: 100%;
                    margin-top: 5px;
                }
                
                .ReplyList table tr td
                {
                    line-height: 20px;
                    font-size: 13px;
                }
                .pub_aptaskt
                {
                    background-color: #1797C0;
                    border: 1px solid #2182A1;
                    display: inline-block;
                    font-family: '宋体' , '新宋体' ,sans-serif;
                    font-size: 14px;
                    font-size-adjust: none;
                    font-stretch: normal;
                    font-style: normal;
                    font-variant: normal;
                    font-weight: normal;
                    line-height: 16px;
                    text-decoration: none;
                    vertical-align: middle;
                }
                .pub_aptaskt i
                {
                    color: #FFFFFF;
                    cursor: pointer;
                    display: block;
                    font-style: normal;
                    font-weight: 700;
                    padding: 4px 15px;
                }
            </style>
            <div class="pubreply_fed" id="CommentBox" style="display: none">
                <div id="divAddCom" style="margin: 10px;">
                    <input style="width: 95%" value="添加分享" onclick="ShowComment()" />
                </div>
                <div style="margin: 15px; display: none;" id="divComment">
                    <div style="margin-top: 5px;">
                        <asp:TextBox ID="txtContent" TextMode="MultiLine" runat="server" Height="54px" CssClass="text_multiLine"></asp:TextBox>
                        <br />
                        <div style="margin-top: 10px; display: none" id="DivSendUser">
                            <asp:DropDownList ID="ddlSendUser" runat="server">
                            </asp:DropDownList>
                            <span style="margin-left: 30px;">
                                <asp:DropDownList ID="ddlIsPublic" runat="server" Visible="false">
                                    <asp:ListItem Value="1">公开</asp:ListItem>
                                    <asp:ListItem Value="2">私密</asp:ListItem>
                                </asp:DropDownList>
                            </span>
                        </div>
                        <div style="margin-top: 10px; position: relative;">
                            <span>
                                <asp:FileUpload ID="FileUpload1" runat="server" /></span> <span style="position: absolute;
                                    right: 0px">
                                    <asp:LinkButton CssClass="pub_aptaskt" ID="LinkButton1" runat="server" OnClientClick="return CheckComment()"
                                        OnClick="LinkButton1_Click"><b><i id="IbtnAdd">回复</i></b></asp:LinkButton><a href="javascript:void(0)"
                                            onclick="HideComment()" style="color: #AAAAAA; margin-left: 10px;"> 取消</a>
                                </span>
                        </div>
                    </div>
                </div>
            </div>
            <asp:Repeater ID="rpGeneralComment" runat="server" OnItemDataBound="rpGeneralComment_ItemDataBound"
                OnItemCommand="rpGeneralComment_ItemCommand">
                <ItemTemplate>
                    <div class="FileList" id="Comment<%# Eval("Id") %>">
                        <table>
                            <tr>
                                <td style="vertical-align: top; padding-top: 12px; width: 60px;">
                                    <img width="50" runat="server" id="UserImg" alt="图片" src="/images/default_middle.jpg" /><br />
                                    <div style="margin-top: 8px;" id="divFollow" runat="server">
                                    </div>
                                </td>
                                <td style="vertical-align: top; padding-top: 5px;">
                                    <table>
                                        <tr id="trFrom" runat="server">
                                            <td id="tdFrom" runat="server">
                                                renya 发起的任务 (来自项目：发沙发哦该方法)
                                            </td>
                                        </tr>
                                        <tr id="trIssueInfo" runat="server">
                                            <td id="tdIssueInfo" runat="server">
                                            </td>
                                        </tr>
                                        <tr id="trIssue" runat="server">
                                            <td id="tdIssue" runat="server">
                                            </td>
                                        </tr>
                                        <tr runat="server" id="trContent">
                                            <td>
                                                <span>
                                                    <%# Eval("UserName") %></span>
                                                <asp:Label ID="lblToUserName" runat="server" Text=''></asp:Label>： <span id="lblContent"
                                                    runat="server">
                                                    <%# Eval("Content") %></span>
                                            </td>
                                        </tr>
                                        <tr id="trFile" runat="server">
                                            <td>
                                                <div style="float: left; margin-top: 6px; margin-right: 10px">
                                                    <a target="_blank" id="ImgLink" runat="server"></a>
                                                </div>
                                                <a target="_blank" id="FileLink" runat="server" style="color: #2889a8;"></a>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="">
                                                <span style="float: left">
                                                    <%# Eval("CreateDate") %>
                                                    <span style="margin: 20px;" id="spType" runat="server" visible="false">( 私密 ) </span>
                                                </span><span class="reply" style="float: right"><a href="#" id="LinkMore" runat="server">
                                                    更多</a>
                                                    <asp:LinkButton ID="lbtnDel" runat="server" CommandName="del" CommandArgument='<%# Eval("Id") %>'
                                                        Visible="false" OnClientClick="return confirm('确定删除？')">删除</asp:LinkButton>
                                                    <a href="javascript:void(0)" style="" onclick="SetComment(<%# Eval("UserId") %>,'','<%# Eval("UserName") %>',<%# Eval("Id") %>)">
                                                        回复</a></span>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <asp:Repeater ID="rpReply" runat="server" OnItemDataBound="rpReply_ItemDataBound"
                        OnItemCommand="rpReply_ItemCommand">
                        <ItemTemplate>
                            <div class="ReplyList" style="padding-left: 65px;" id="Reply<%# Eval("Id") %>">
                                <table style="border-top: 1px solid #E7E7E7;">
                                    <tr>
                                        <td style="width: 40px; vertical-align: top; padding-top: 8px;">
                                            <img width="30" runat="server" id="ReplyUserImg" alt="图片" src="/images/default_small.jpg" />
                                        </td>
                                        <td>
                                            <table>
                                                <tr>
                                                    <td>
                                                        <span>
                                                            <%# ObjToInt( Eval("UserId"))==0?"我":"客服" %></span>
                                                        <asp:Label ID="lblReplyName" runat="server" Text='' Visible="false"></asp:Label>： <span id="lblContent"
                                                            runat="server">
                                                            <%# Eval("Content") %></span>
                                                    </td>
                                                </tr>
                                                <tr id="trFile" runat="server">
                                                    <td>
                                                        <div style="float: left; margin-top: 6px; margin-right: 10px">
                                                            <a target="_blank" id="ImgLink" runat="server"></a>
                                                        </div>
                                                        <a target="_blank" id="FileLink" runat="server" style="color: #2889a8;"></a>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="">
                                                        <span style="float: left">
                                                            <%# Eval("CreateDate") %></span> <span class="reply" style="float: right; margin-right: 15px;">
                                                                <asp:LinkButton ID="lbtnDel" runat="server" CommandName="del" CommandArgument='<%# Eval("Id") %>'
                                                                    Visible="false" OnClientClick="return confirm('确定删除？')">删除</asp:LinkButton>
                                                                <a href="javascript:void(0)" onclick="SetComment(<%# Eval("UserId") %>,<%# Eval("Id") %>,'<%# Eval("UserName") %>',<%# Eval("CommentId") %>)">
                                                                    回复</a></span>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </ItemTemplate>
                    </asp:Repeater>
                </ItemTemplate>
            </asp:Repeater>
            <input type="hidden" id="GeneralCommentId" name="GeneralCommentId" />
            <input type="hidden" id="ReplyId" name="ReplyId" />
            <input type="hidden" id="ReplyUserId" name="ReplyUserId" />
            <div class="pager-bar" style="margin-top: 10px;">
                <webdiyer:AspNetPager ID="pager" runat="server" Width="100%" PageSize="10" OnPageChanged="pager_PageChanged"
                    HorizontalAlign="Right" Direction="LeftToRight" ShowCustomInfoSection="Never"
                    PagingButtonSpacing="10px" CssClass="anpager" currentpagebuttonclass="cpb" AlwaysShow="true"
                    FirstPageText="首页" NextPageText="下一页" PrevPageText="上一页" LastPageText="末尾">
                </webdiyer:AspNetPager>
            </div>
            <script>
                function ShowComment() {
                    InitComentDiv()

                    $("#ReplyUserId").val("");
                    $("#ReplyId").val("");
                    $("#GeneralCommentId").val("");
                    var objSelect = document.getElementById("<%=ddlSendUser.ClientID  %>");
                    objSelect.options[0].selected = true;

                    $("#divComment").show();
                    $("#divAddCom").hide();
                    $("#DivSendUser").show();
                    $("#IbtnAdd").html("发布");
                }

                function HideComment() {
                    InitComentDiv()

                    $("#ReplyUserId").val("");
                    $("#ReplyId").val("");
                    $("#GeneralCommentId").val("");
                    var objSelect = document.getElementById("<%=ddlSendUser.ClientID  %>");
                    objSelect.options[0].selected = true;

                    $("#divComment").hide();
                    $("#divAddCom").show();
                    $("#DivSendUser").hide();

                }

                function SetComment(ReplyUserId, ReplyId, UserName, GeneralCommentId) {
                    var DivTemple = $("#divComment");
                    $("#divComment").remove();
                    if (ReplyId == "")
                        $("#Comment" + GeneralCommentId).append(DivTemple);
                    else
                        $("#Reply" + ReplyId).append(DivTemple);
                    $("#divComment").attr("class", "pubreply_fed");
                    $("#divComment").css("padding", "15px");

                    $("#divComment").show();
                    $("#divAddCom").show();
                    $("#ReplyUserId").val(ReplyUserId);
                    $("#ReplyId").val(ReplyId);
                    $("#GeneralCommentId").val(GeneralCommentId);
                    $("#DivSendUser").hide();

                    $("#IbtnAdd").html("回复");

                    var objSelect = document.getElementById("<%=ddlSendUser.ClientID  %>");
                    for (var i = 0; i < objSelect.options.length; i++) {

                        if (objSelect.options[i].value == ReplyUserId) {
                            objSelect.options[i].selected = true;

                        }
                    }

                    if (document.getElementById("MainCommnet") != null) {
                        ChangeTopDiv("MainCommnet");
                    }

                    //$("html,body").animate({ scrollTop: $("#divComment").offset().top }, 500);

                }

                //还原回复层位置
                function InitComentDiv() {
                    var DivTemple = $("#divComment");
                    $("#divComment").remove();
                    $("#CommentBox").append(DivTemple);
                    $("#divComment").removeClass("pubreply_fed");
                    $("#divComment").css("padding", "0px");
                }

                function CheckComment() {
                    if ($("#<%=txtContent.ClientID  %>").val() == "") {
                        alert("请输入内容");
                        return false;
                    }
                    var strContent = $("#<%=txtContent.ClientID  %>").val();
                    if (len(strContent) > 280) {
                        alert("请不要超过140个汉字");
                        return false;
                    }
                    return true;
                }

                function len(s) { var l = 0; var a = s.split(""); for (var i = 0; i < a.length; i++) { if (a[i].charCodeAt(0) < 299) { l++; } else { l += 2; } } return l; }


                $(".FileList").each(function (i) {


                    $(this).mouseover(function () {
                        $(this).addClass("HoverFileList");
                    });

                    $(this).mouseout(function () {
                        $(this).removeClass("HoverFileList");
                    });

                });

                function AddFollow(link, AddFollowId) {

                    if ($(link).html().indexOf("+") >= 0) {
                        $.ajax({
                            type: "POST",
                            url: "/NewProject/ProjectAjax.aspx",
                            data: "AddFollowId=" + AddFollowId,
                            //ajax提交成功回调事件
                            success: function (returnMsg) {
                                if (returnMsg != "ok") {
                                    alert("操作错误");
                                    return;
                                }

                                $("a[name='LinkFollow" + AddFollowId + "']").each(function (i) {
                                    $(this).removeClass("addattention");
                                    $(this).addClass("attention");
                                    $(this).html("<i>已关注</i>");
                                });

                                alert("你已经关注了该用户");
                                InitLink();

                            }
                        });
                    } else {

                        $.ajax({
                            type: "POST",
                            url: "/NewProject/ProjectAjax.aspx",
                            data: "DelFollowId=" + AddFollowId,
                            //ajax提交成功回调事件
                            success: function (returnMsg) {
                                if (returnMsg != "ok") {
                                    alert("操作错误");
                                    return;
                                }

                                $("a[name='LinkFollow" + AddFollowId + "']").each(function (i) {
                                    $(this).unbind("mouseover");
                                    $(this).unbind("mouseout");
                                    $(this).removeClass("attention");
                                    $(this).removeClass("delattention");
                                    $(this).addClass("addattention");
                                    $(this).html("<i><b>+</b> 关注</i>");
                                });

                                alert("你已经取消了该用户的关注");

                            }
                        });

                    }

                }

                function InitLink() {
                    $(".attention").each(function (i) {
                        $(this).mouseover(function () {

                            $(this).removeClass("attention");
                            $(this).addClass("delattention");
                            $(this).html("&nbsp;&nbsp;&nbsp;取 消 ");
                        });

                        $(this).mouseout(function () {
                            $(this).removeClass("delattention");
                            $(this).addClass("attention");
                            $(this).html("<i>已关注</i>");
                        });

                    });
                }

                InitLink();


            </script>
        </div>
        <div class="left">
            <uc1:TaskNav ID="TaskNav1" runat="server" />
        </div>
    </div>
</asp:Content>
