<%@ Page Language="C#" MasterPageFile="~/home/main.Master" AutoEventWireup="true"
    Codebehind="myFriend.aspx.cs" Inherits="ZYDN.Web.home.myFriend" Title="我的好友" %>

<%@ MasterType VirtualPath="~/home/main.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="R_BGDIV">
        <div id="R_Top">
        </div>
        <div>
            <div id="R_Left">
                <div style="width: 100%;" class="topOptionList">
                    <div style="width: 5px; float: left;">
                    </div>
                    <div id="mycreateBunch" name="mycreateBunch" class="optionCar">
                        <asp:Label ID="friend" runat="server" Text=""></asp:Label>
                    </div>
                    <div id="mycreateBunch" name="mycreateBunch" class="optionCar_1">
                        <asp:Label ID="bunchCreateType" runat="server" Text="查找好友"></asp:Label></div>
                </div>
                <div class="topOptionListBody">
                    <div id="mycreateBunchBody" name="mycreateBunchBody" style="width: 100%;">
                        <asp:Repeater ID="FriendList" runat="server">
                            <ItemTemplate>
                                <div style="width: 33%; text-align: center; overflow: hidden; float: left;" id="myFriend<%# DataBinder.Eval(Container, "DataItem.id")%>">
                                    <div class="myUserList" style="float: left;"  style="filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);"  id="myFriendDiv<%# DataBinder.Eval(Container, "DataItem.userID")%>">
                                        <img  id="myFriendList" name="myFriendList" alt="<%# DataBinder.Eval(Container, "DataItem.userName")%>" onload="setImgWH(this)" src="<%# DataBinder.Eval(Container, "DataItem.userPhoto")%>">
                                    </div>
                                    <div style="float:left; width:100px; padding-left:5px;" class="bunchInfo">
                                        <div style="color:#000000; font-weight:bold;">
                                        <%# DataBinder.Eval(Container, "DataItem.userName")%>
                                        </div>
                                        <div>
                                         主页热度:
                                            <%# DataBinder.Eval(Container, "DataItem.homeClickCount")%>
                                            </div>
                                        <div>
                                        <a href="index.aspx?user=<%# DataBinder.Eval(Container, "DataItem.userName")%>">
                                           查看主页
                                        </a>
                                        <div id="delFriend" name="delFriend" onclick="delMyFriend(<%# DataBinder.Eval(Container, "DataItem.id")%>)">
                                            删除好友</div>
                                        </div>
                                    </div>
                                </div>
                            </ItemTemplate>
                        </asp:Repeater>
                  <script language="javascript" type="text/javascript">
                          readOnlineFriend();
                        
                    </script>
                    
                    <%--
                        <asp:Repeater ID="FriendList" runat="server">
                            <ItemTemplate>
                                <div style="width: 100%;" id="myFriend<%# DataBinder.Eval(Container, "DataItem.id")%>">
                                    <div style="width: 120px; height: 100px; float: left; overflow: hidden; background-color: #808080;">
                                        <img src=" <%# DataBinder.Eval(Container, "DataItem.userPhoto")%>" onload="setImgWH(this)" /></div>
                                    <div style="width: 340px; height: 100px; float: left; background-color: #C0C0C0;">
                                        <div>
                                            <a href='index.aspx?user=<%# DataBinder.Eval(Container, "DataItem.userName")%>'>
                                                <%# DataBinder.Eval(Container, "DataItem.userName")%>
                                            </a>
                                        </div>
                                        <div>
                                            <%# DataBinder.Eval(Container, "DataItem.idiograph")%>
                                        </div>
                                        <div>
                                            访问数:
                                            <%# DataBinder.Eval(Container, "DataItem.homeClickCount")%>
                                        </div>
                                        <span id="delFriend" name="delFriend" onclick="delMyFriend(<%# DataBinder.Eval(Container, "DataItem.id")%>)">
                                            删除好友</span>
                                    </div>
                                </div>
                            </ItemTemplate>
                        </asp:Repeater>--%>
                    </div>
                    <div id="mycreateBunchBody" name="mycreateBunchBody" style="width: 100%; visibility: hidden; font-size:12px; " class="findFriendBody">
                        按用户名搜索  <input type="text" value="" id="findName" style="width:150px;"><input type="button" value="提交" onclick="findNameUser()"/>
                        <div >
                        <br/>
                        <br/>
                        <br/>
                        匹配我的资料, 查找资料和我相同的.
                        <div  id="findListDiv">
                        </div>
                        
                        <input type="button" value="提交" onclick="loadUser();" />
                        </div>
                        <br/>
                        <br/>
                        <br/>
                        <div id="displayFindList">
                        
                        </div>
                    
                    
                    </div>
                </div>
            </div>
            <div id="R_Right">
            </div>
        </div>
    </div>
    <div id="R_Bottom">
    </div>

    <script language="javascript" type="text/javascript">
    
    
        var nCar =new  carClass();
                nCar.optionDiv="mycreateBunch";
                nCar.bodyDiv="mycreateBunchBody";
                nCar.thisClass="optionCar";
                nCar.className="optionCar_1";
                setTimeout("nCar.Create()",200);
        
        
        
        function loadUser(){ //
            var objs=document.getElementsByTagName("input");
            var fList="";
            for (var i=0;i<objs.length;i++){
                if (objs[i].type=="checkbox" & objs[i].title!="" &objs[i].title !=null & objs[i].checked){
                    fList+=objs[i].value+",";
                }
            }
            if (fList==""){
                alert("请选择一个匹配项目");
                return;
            }
            
            var objResponse=new JHttpResponse();
            objResponse.write("fList",fList);
            var out=objAjax.getText("post","homeServer.aspx?type=findFieldUser",objResponse,null);
            displayUserList(out);
        }
        
        
        function findNameUser(){
            var uName=$("findName").value;
            if (uName.length<1){
                  alert("请输入一个用户名");
                return;
            }
           var objResponse=new JHttpResponse();
            objResponse.write("uName",uName);
            var out=objAjax.getText("post","homeServer.aspx?type=findNameUser",objResponse,null);
            if (out.indexOf(c1)==-1){
               alert(erStr(out)) ;
                return;
            }
            displayUserList(out);  
            
        }
        
        
        function displayUserList(out){
            out=comminute(out,c1,c2);
            // UserName,userPhoto,id,homeClickCount//
            //   0        1        2      3
            if (out.length==1){
                alert("未找到符合条件的用户.")
                return;
            }
            var html="";
            for (var i=0;i<out.length-1;i++){
                
                
                  html+="   <div style=\"width: 33%; text-align: center; overflow: hidden; float: left;\" >\n";
                  html+="  <div class=\"myUserList\" style=\"float: left;\">\n";
                  html+="   <img onload=\"setImgWH(this)\" src=\""+out[i][1]+"\">\n";
                  html+="   </div>\n";
                  html+="   <div style=\"float:left; width:100px; padding-left:5px;\" class=\"bunchInfo\">\n";
                  html+="    <div style=\"color:#000000; font-weight:bold;\">\n";
                  html+="   "+out[i][0]+"\n";
                  html+="    </div>\n";
                  html+="   <div>\n";
                  html+="   主页热度:\n";
                  html+="   "+out[i][3]+"\n";
                  html+="   </div>\n";
                  html+="   <div>\n";
                  html+="   <a  target='_blank'  href=\"index.aspx?user="+out[i][0]+"\">\n";
                  html+="    查看主页\n";
                  html+="   </a>\n";
                  html+="   </div>\n";
                  html+="     </div>\n";
                  html+="    </div>\n";
            }
            $("displayFindList").innerHTML=html;
            
            
            
            
            
        }
        
        
       function loadFindField(){
       
	      var out=objAjax.getText("post","homeServer.aspx?type=readUserFindField",null,null);
	      if (out.indexOf(c1)==-1 ){
	        alert(erStr(out));
	        return;
	      }
	      
	      out= comminute(out,c1,c2)
	      var html="";
	      for (var i=0;i<out.length-1;i++){
	            html+="<input type='checkbox' title='"+out[i][1]+"' value='"+out[i][0]+"' id='f"+out[i][0]+"'><label for='f"+out[i][0]+"'>"+out[i][1]+"</label><br/>"
	      }
	      $("findListDiv").innerHTML=html;
       }
        
        
      function setDelFriend(){
           // alert(isMy);
            if (isMy==0){
                var objs=document.getElementsByName("delFriend");
                var z=objs.length;
                for (var i=0;i<z;i++){
                    objs[0].removeNode(true);
                }
            }
        }
        setDelFriend();
        loadFindField();
    </script>

</asp:Content>
