<%@ page language="C#" autoeventwireup="true" inherits="Contact_ContactList, App_Web_x1qizdpp" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <script src="../Scripts/MyDate.js"></script>
    <script src="../Scripts/UserMsgClass.js"></script>
    <script type="text/javascript">
        //禁止返回键
        javascript:window.history.forward(1);
        
        function PageLoad()
        {
            window.parent.ShowOrHideToolBar(true);
        }
        
        function ShowGroupUserList(msggroupid)
        {
            if(document.getElementById("ProNode-" + msggroupid).style.display == "none")
            {
                document.getElementById("ShowPoint-" + msggroupid).src = "../Images/sppp1.gif";
                document.getElementById("ProNode-" + msggroupid).style.display = "";
                XMLHttpGet(window.parent._UserNo,msggroupid);
            }
            else
            { 
                document.getElementById("ShowPoint-" + msggroupid).src = "../Images/sppp.gif";
                document.getElementById("ProNode-" + msggroupid).style.display = "none";
            }
        }
        
        var xmlHttpRequest = null;
        
        //收到消息，发现没有用户信息，就到服务器端下载用户信息
        function XMLHttpGet(userno,groupid)
        { 
            xmlHttpRequest = new XMLHttpRequest();
            xmlHttpRequest.open("POST", "../SisenMESS-Mobile-WebService.asmx/GetFriendGroupUserList", true);
            // 当发生状态变化时就调用这个回调函数
            xmlHttpRequest.onreadystatechange = ajaxCallBack;
            // 使用post提交时必须加上下面这行代码
            xmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            
            // 向服务器发出一个请求
            xmlHttpRequest.send("userNo=" + userno+"&groupid="+groupid);
        }
        
        function ajaxCallBack()
        {
            if(xmlHttpRequest.readyState == 4)
            {
                if(xmlHttpRequest.status == 200)
                {
                    var content = xmlHttpRequest.responseText;
                    
                    var tempmsg = content.split('\n');
                    
                    showGroupUserList(tempmsg);
                }
            }
        }
        //显示用户列表
        function showGroupUserList(tempmsg)
        {
            var groupid = tempmsg[0];

            var htmltxt = "";
            
            for(var i=1;i<tempmsg.length;i++)
            {
                if(tempmsg[i]=="")
                {
                    continue;
                }
                
                var usinfo = tempmsg[i].split('\t');
                if(i==1)
                {
                    htmltxt += GetUserMsgShowItem(usinfo[0],usinfo[1],usinfo[2],0,"hidden",usinfo[4],"FriendListUserItemTop");
                }
                else
                {
                    htmltxt += GetUserMsgShowItem(usinfo[0],usinfo[1],usinfo[2],0,"hidden",usinfo[4],"FriendListUserItemBottom");
                }
            }
            
            document.getElementById("UserList-" + groupid).innerHTML = htmltxt + "<br>";
        }
        
        //得到用户Item（visible、hidden）
        function GetUserMsgShowItem(userno,username,userdetail,msgCount,isVisible,usericonpath,cssname)
        {
            userdetail += "&nbsp;";
            var htmltxt = "<div id = \"SisenMESSUserItem-" + userno + "\" class ='" + cssname + "' onclick=\"OpenUserMsg('" + userno + "','"+username+"');\" >";
            htmltxt += "<table width=\"100%\" height=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
            htmltxt += "<tr>";
            htmltxt += "<td style=\"width:48px; height:48px;\" align=\"center\"><img id = 'userIcon-" + userno + "' style='border:1px #e0e1e3 solid;background-color:#FFFFFF' src=\"" + usericonpath + "\" width=\"32\" height=\"32\"></td>";
            htmltxt += "<td style='color:#4f5152;'><span id ='UserInfo-UserName-" + userno + "'>" + username  + "</span><br><span class = 'UserDetail' id ='UserInfo-UserDetail-" + userno + "'>" + userdetail + "</span></td>";
            htmltxt += "<td align='right'>";
            htmltxt += " <table id ='MsgCount-" + userno + "' style='height:17px;visibility:" + isVisible + "' border='0' cellspacing='0' cellpadding='0'>";
            htmltxt += " <tr style='height:17px; '>";
            htmltxt += " <td style='width:5px; background-image:url(../Images/y1.gif)'></td>";
            htmltxt += " <td style='width:6px; height:17px; background-image:url(../Images/y2.gif); font-size:10px; color:#FFFFFF;' align='center'>";
            htmltxt += " <div style='margin-top:2px;width:100%;text-align:right;' id ='msg_count_" + userno + "'>" + msgCount + "</div>";
            htmltxt += " </td>";
            htmltxt += " <td style='width:6px; background-image:url(../Images/y3.gif)'></td>";
            htmltxt += " </tr>";
            htmltxt += " </table>";
            htmltxt += "</td>";//<span id ='msg_count_" + tempmsg[0] + "'>1</span>
            htmltxt += "<td style='width:4px;'></td>";                    
            htmltxt += "</tr>";
            htmltxt += "</table>";
            htmltxt += "</div>";
            
            return htmltxt;
        }
        //打开用户聊天窗口
        function OpenUserMsg(userno,username)
        {
            if(!window.parent._IsLogin)
            {
                return;
            }
            //把用户头像的链接记录一下，在聊天窗口里直接使用。
            window.parent._TempMsgUserIconUrl = document.getElementById("userIcon-" + userno).src;

            document.getElementById("msg_count_" + userno).innerText = "0";
            document.getElementById("MsgCount-" + userno).style.visibility = 'hidden';
            
            //window.parent._PageTempName = 
            window.location.href = "../Msg/MsgShow.aspx?UserNo=" + userno+"&UserTName="+username.replace(/&/g,"＆").replace(/=/g,"＝");
        }
    </script>
    <link href="../Css/MsgList.css" rel="stylesheet" />
</head>
<body onload="PageLoad();">
    <form id="form1" runat="server">
    <br />
    <br />
    <br />
    <div id ="MainDiv" runat ="Server"></div>
    </form>
</body>
</html>
