<%@ Page Language="C#" MasterPageFile="~/User/UserCenter/UserView.Master"  AutoEventWireup="true"  Codebehind="UserMessageReceivedBox.aspx.cs" Inherits="PPFOR.User.UserCenter.UserMessageReceivedBox" Title="收件箱" %>
<%@ Register Src="PageBar.ascx" TagName="PageBar" TagPrefix="page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PPFOR_userViewContent" runat="server"> 
<script src="/Admin/JS/gridview.js" type="text/javascript"></script> 
<script src="/Admin/JS/ajax.js" type="text/javascript"></script> 
<script type="text/javascript">
var activeMessagID='';
function openMessage(obj,msgId)
{ 
    var prevTrID="msgBodyRow_";
    var idHasRead="msgHasRead_" + msgId;
    var prevTitleImageID="msgTitleImage_";
        
    if(activeMessagID!=null && activeMessagID!=''){
        var activeMessagRow=docEle(prevTrID + activeMessagID);
        if(activeMessagRow){
            activeMessagRow.style.display='none';
            changeTitleImage(prevTitleImageID + activeMessagID,0);  
            if(msgId==activeMessagID){         
                activeMessagID='';                 
                return;
            } 
        }     
    }
    activeMessagID=msgId;   
    var objTr= docEle(prevTrID + msgId);
    if(!objTr){
        var objNewTd=createMessageRow(obj,prevTrID + msgId);
        DoAjax("Servers.aspx?action=getmessagebody&type=receive&msgid=" + msgId,"GET",null,showMessage,objNewTd,docEle(idHasRead));
    }else{
        objTr.style.display='';             
    }
    if(activeMessagID!=null && activeMessagID!=''){
        changeTitleImage(prevTitleImageID + activeMessagID,1);  
    }
}
function changeTitleImage(idTitleImage,type){
     var objTitleImage=docEle(idTitleImage);
     if(objTitleImage){
        objTitleImage.src="/User/Images/" + (type==1 ? 'move_up' : 'move_down') + ".gif";
     }
}
function createMessageRow(obj,idTr)
{    
    var objTd=obj.parentNode;
    if(objTd!=null){
        var objTr=objTd.parentNode;
        if(objTr!=null){
            var objTable=objTr.parentNode;
            if(objTable!=null){
                objNewTr=objTable.insertRow(objTr.rowIndex+1);                
                if(objNewTr!=null){                    
                    objNewTr.id=idTr;
                    var objNewTd=objNewTr.insertCell(0);
                    if(objNewTd!=null){
                        objNewTd.colSpan=objTr.cells.length;
                        objNewTd.align='center';
                        objNewTd.innerHTML="<img src=\"/User/Images/loading.gif\" alt=\"Loading...\" />"; 
                        return objNewTd;
                    }
                }
            }
        }
    }
    return false;
}
function showMessage(xmlHttp,objNewTd,objHasRead)
{
    if(xmlHttp!=null && xmlHttp.responseText!=null){        
        objNewTd.innerHTML="<p class='msgbody'>" + xmlHttp.responseText + "</p>";  
        if(objHasRead){
            objHasRead.innerHTML='<%=languageMessage.GetMessage("userMsgRead", "已读")%>';
        }
    }else{
        objNewTd.innerHTML='';
    }    
}
</script>
<div class="tableco">
    <h1><%=languageMessage.GetMessage("userReceivedBox", "收件箱")%></h1>   
    <form runat="server" id="form1">
        <asp:GridView ID="PPFOR_showMemberMessageList" CssClass="listtable" runat="server" OnRowDataBound="PPFOR_gridViewRowDataBound" AllowPaging="false" AutoGenerateColumns="False"  DataKeyNames="MsgID"  Width="100%" CellPadding="0" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="0px" >
           <Columns>  
           <asp:TemplateField HeaderStyle-CssClass="wd" HeaderStyle-HorizontalAlign="Center" ItemStyle-CssClass="color1" ShowHeader="False" HeaderText="">                
                 <HeaderTemplate>
                     <asp:CheckBox ID="PPFOR_selectMessage" runat="server"></asp:CheckBox>
                 </HeaderTemplate>
                 <ItemTemplate>
                     <asp:CheckBox ID="PPFOR_selectMessage" runat="server"></asp:CheckBox>
                 </ItemTemplate>
             </asp:TemplateField>
             <asp:BoundField HeaderStyle-CssClass="title" DataField="MsgID" HeaderStyle-Font-Bold="false"/> 
             <asp:TemplateField HeaderStyle-CssClass="title" ItemStyle-CssClass="msgtitle" HeaderStyle-Font-Bold="false">
                <ItemTemplate>
                <a href="#" onclick='openMessage(this,<%# Eval("MsgID") %>);' title="<%=languageMessage.GetMessage("userMsgToLook", "查阅消息")%>"><img id='msgTitleImage_<%# Eval("MsgID") %>' src="/User/Images/move_down.gif" alt=""/><%#PPFOR_getMessageMemberTitle(Eval("MsgBodyID"))%></a>
                </ItemTemplate>
             </asp:TemplateField>        
             <asp:TemplateField HeaderStyle-CssClass="title" HeaderStyle-Font-Bold="false">
                <ItemTemplate>
                <%#PPFOR_getMessageMemberName(Eval("MsgSendMemberID"), Eval("MsgSendIsAdmin"))%>
                </ItemTemplate>
             </asp:TemplateField>    
             <asp:BoundField HeaderStyle-CssClass="title" DataField="MsgSendTime" HeaderStyle-Font-Bold="false"/>   
             <asp:TemplateField HeaderStyle-CssClass="title" HeaderStyle-Font-Bold="false">
                <ItemTemplate>
                <a href="SendMessage.aspx?action=reply&mid=<%# Eval("MsgID") %>"><%=languageMessage.GetMessage("userMsgToReply", "回复")%></a>
                </ItemTemplate>
             </asp:TemplateField>  
             <asp:BoundField HeaderStyle-CssClass="title" DataField="MsgHasRead" HeaderStyle-Font-Bold="false"/>                  
            </Columns>            
             <FooterStyle BackColor="#990000" ForeColor="White" /> 
             <RowStyle Font-Bold="false" BackColor="#ffffff"/> 
             <HeaderStyle BackColor="#F5F5F5" Font-Bold="false" ForeColor="#000000" />
             <AlternatingRowStyle BackColor="#F5F5F5" />
        </asp:GridView> 
        <table width="100%" cellpadding="5px" cellspacing="3px" border="0" style="display:<%=PPFOR_displayRecordOption %>" >
            <tr id="rows1">
              <td align="left">
                  <asp:Button ID="PPFOR_deleteMessage" CssClass="blueinput" runat="server" OnClick="PPFOR_deleteMessageClick"/>            
                  <input type="reset" class="blueinput" value="<%=languageMessage.GetMessage("userResetButton", "重置") %>" onclick="SelectAllRows('<%=form1.ClientID%>',false);"/>      
            </td>
            </tr>
         </table>             
        <page:PageBar ID="PPFOR_pageBar" runat="server" />
    </form>
</div>
</asp:Content>
