<%@ page language="C#" autoeventwireup="true" inherits="FindUser_FindUsers, App_Web_lflzhrc8" %>
<!DOCTYPE html>
<html>
<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); 
        
        var xmlHttpRequest = null;
        //收到消息，发现没有用户信息，就到服务器端下载用户信息
        function XMLHttpGet(txt)
        { 
            xmlHttpRequest = new XMLHttpRequest();
            xmlHttpRequest.open("POST", "../SisenMESS-Mobile-WebService.asmx/SearchUser", true);
            // 当发生状态变化时就调用这个回调函数
            xmlHttpRequest.onreadystatechange = ajaxCallBack;
            // 使用post提交时必须加上下面这行代码
            xmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            
            // 向服务器发出一个请求
            xmlHttpRequest.send("searchtxt=" + txt);
        }
        
        function ajaxCallBack()
        {
            if(xmlHttpRequest.readyState == 4)
            {
                if(xmlHttpRequest.status == 200)
                {
                    var content = xmlHttpRequest.responseText;
                    
                    var tempmsg = content.split('\n');
                    
                    var htmltxt = "";
                    
                    for(var i=0;i<tempmsg.length;i++)
                    {
                        if(tempmsg[i]=="")
                        {
                            continue;
                        }
                        
                        var usinfo = tempmsg[i].split('\t');
                        
                        if(usinfo == window.parent._UserNo)
                        {
                            continue;
                        }
                        
                        if(i==0)
                        {
                            htmltxt += GetUserMsgShowItem(usinfo[0],usinfo[1],"",0,"hidden","../UserIcon/SisenMESS-User-None-Icon.gif","FriendListUserItemTop");
                        }
                        else
                        {
                            htmltxt += GetUserMsgShowItem(usinfo[0],usinfo[1],"",0,"hidden","../UserIcon/SisenMESS-User-None-Icon.gif","FriendListUserItemBottom");
                        }
                    }
                    
                    document.getElementById("MsgUserList").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.CloseFindBar();
            
            window.parent.frames[0].location.href = "../Msg/MsgShow.aspx?UserNo=" + userno+"&UserTName="+username.replace(/&/g,"＆").replace(/=/g,"＝");
            
        }
        
        //进行查找
        function DoFind()
        {
            var txt = document.getElementById("txt_SerachFriend").value;
            if(txt=="")
            {
                return;
            }
            
            XMLHttpGet(txt);
        }
    </script>
    <link href="../Css/MsgList.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <div style=" vertical-align:middle;height:24px;padding-left: 16px;">
    <br />
    <br />
    <br />
        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td style="width:50px; text-align:center; color:#74a5ce;">查找:</td>
            <td><input type="text" name="txt_SerachFriend" id ="txt_SerachFriend" style ="width:98%; border:1px solid #74a5ce;height:24px;font-size:16px;color:#2a3f6d " ></td>
            <td style="width:50px; text-align:left; "><img alt="" src="../Images/go.gif" onclick="DoFind();" width="24" height="24" /></td>
          </tr>
        </table>
    </div>
    <br />
    <br />
    <br />
    <br />
    <div id = "MsgUserList"></div> 
    </form>
</body>
</html>
