using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace JuSNS.Web.inc.Ajax.index
{
    public partial class online : JuSNS.UI.Page.BasePage
    {
        protected static string[] GetOnlineSet = null;
        protected static int KouM;
        protected void Page_Load(object sender, EventArgs e)
        {
            string ResultStr = string.Empty;
            if (this.GetUserID() > 0)
            {
                JuSNS.Home.JUser ju = new JuSNS.Home.JUser();
                int FNum = 0;
                int TNum = 0;
                DataTable dt = ju.GetOnlineNumber(this.GetUserID());
                bool isMore = false;
                if (dt != null && dt.Rows.Count > 0)
                {
                    FNum = dt.Rows.Count;
                    TNum = Convert.ToInt32(dt.Rows[0]["TotelNumber"].ToString());
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string pokeStr = " onclick=\"SendPoke('" + dt.Rows[i]["UserID"].ToString() + "','" + dt.Rows[i]["UserName"].ToString() + "','" + GetHeadImage(Convert.ToInt32(dt.Rows[i]["UserID"].ToString()), 2) + "','')\"";
                        ResultStr += "<li><img src=\"" + rooDir + "/template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/chat/friendhead.gif\" align=\"absmiddle\" /> <a href=\"" + rooDir + "/user/" + JuSNS.Common.Public.URLWrite("", "r", dt.Rows[i]["UserID"].ToString()) + "\">" + dt.Rows[i]["UserName"].ToString() + "</a><a href=\"javascript:void(0);\" " + pokeStr + " title=\"给他招呼\"><img src=\"" + rooDir + "/template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/site/ico/poke1.gif\" align=\"absmiddle\"></a></li>\r\n";
                    }
                    if (dt.Rows.Count == 20)
                    {
                        isMore = true;
                    }
                }
                dt.Clear(); dt.Dispose();
                if (isMore)
                {
                    ResultStr += "<li style=\"text-align:right;\"><a href=\"" + rooDir + "+home/friend/online.aspx\">更多...</a></li>";
                }
                GetOnlineSet = JuSNS.Common.Public.GetXMLValue("onlinebase").Split(',');
                Random r = new Random();
                KouM = r.Next(Convert.ToInt32(GetOnlineSet[0]), Convert.ToInt32(GetOnlineSet[1]));
                Response.Write("<a href=\"javascript:void(0);\" onclick=\"showSetMenu('online_menu_div');\"  onmouseout=\"delayhidemenu('online_menu_div')\">好友在线<span class=\"font11\">(" + FNum + ")</span> 总在线<span class=\"font11\">(" + (TNum + KouM) + ")</a></span> &nbsp; <div onmouseover=\"clearhidemenu()\"  onmouseout=\"delayhidemenu('online_menu_div')\" class=\"divstyle-online\" style=\"display:none;\" id=\"online_menu_div\"><ul>" + ResultStr + "</ul></div>");
                Response.End();
            }
        }
    }
}
