var _webIM = null;
function IntWebIM(){
    if (!$("windowContainerBorder")) 
	{
        var WebMqq = new WebIM();
        WebMqq.Initialize();
        return WebMqq;
    }
}
function WebIM()
{
    var _Me = this;
	this.MainHeigth=null;
    this.im = null;
    this.Win = null;
    this.Version = "1.0";
    this.Msgs = new MsgBox();
    this.Parse = new ParseData();
    this.SeachWin = null;
	this.ParseCmdObj=new ParseCmd();
    this.AutoLogin = new AutoLogin();
    this.AutoLogin.parent = this;
    this.PSW = new ProgramPsw();
    this.winfocus = 1;
    this.netWork = new netWorkManage();
    this.netWork.parent = _Me;
	this.ChatHistoryHelper=new ChatHistoryToHtml();
	this.ChatHistoryHelper.Parent=_Me;
	this.SysMessage=new SysMessage();
	this.SysMessage.MsgDomId="SysStauts";
	this.HistoryWin=new ChatWinManage();
	this.HistoryWin.init();
	this.UserViewSeachHelper=new UserViewSeach();
	this.UserViewSeachHelper.Parent=this;
	this.UserViewSeachHelper.ViewDivId="wMainSeachViewDiv";
    SysBar.parent = this;
    UserView.Data = this.Parse;
    this.initIm = function(){
		    this.PSW.imCoreType="Ajax";
            _Me.im = new IMCore("imCore");
            _Me.im.OnReceive = _Me.passData;
            _Me.im.OnConnected = _Me.ConnectOk;
            _Me.im.Init();
    }
	this.initFlashIm=function(){
		    this.PSW.imCoreType="Flash";
			var FlashObj=GetFlashObj("ImCore");
			if (!FlashObj)
			{
				this.initIm();
				return;
			}
		    _Me.im = new SocketImCore("WebIndex.WebIm.im",FlashObj);
			_Me.im.server = document.domain;
		    _Me.im.port = 6009;		
            _Me.im.OnReceive = _Me.passData;
			_Me.im.OnLog = function(msg){
		 	 }
            _Me.im.OnConnected = _Me.ConnectOk;		  
			_Me.im.OnClose = _Me.OnFlashCoreClose;
			_Me.im.Connect();
	}
	this.InitCore=function()
	{
		_Me.im=null;
		_Me.PSW.connect =0;
		_Me.initFlashIm();
        _Me.PSW.InitCoreTimer=window.setTimeout(function(){
		if (_Me.PSW.connect==0)
		{
				_Me.initIm();
		}
		},15000)
	}
	this.OnFlashCoreClose=function()
	{
		_Me.CMD.SetOffLineMode();
		_Me.PSW.connect=0;
		_Me.PSW.isReLogin=1;
	    _Me.PSW.ReLoginI=window.setTimeout(function(){_Me.InitCore();},2000)
	}
    this.ConnectOk = function(){
	    _Me.CMD.SetOnlineMode();
		window.clearTimeout(_Me.PSW.InitCoreTimer);
		if (_Me.PSW.ReLoginI!=null)
		{
			window.clearInterval(_Me.PSW.ReLoginI);
		}
        _Me.PSW.connect = 1;
		if (_Me.PSW.isReLogin==1)
		{
			_Me.SysMessage.ShowMsg("网络连接异常,已经重新登录",3000,true);
			_Me.Data.setUserLogin(_Me.Parse.UserCacheInfo.LoginUserName,_Me.Parse.UserCacheInfo.LoginPassWord,_Me.Parse.UserCacheInfo.LoginStauts,null,1)
		}
		if (_Me.PSW.isAutoLogin==1)
		{
			_Me.AutoLogin.GetUserInfo();	
		}
    }
    this.passData = function(data){
        var TestCount = 0;
	    if (typeof(data) == "object") {
			return false;
		}
        command = _Me.ParseCmdObj.Parse(data);
		data=IMCore.ParseData(data);
        if (_Me.PSW.readMyFriended == 0 && (command == ".Buddy_Msg" || command == ".Buddy_Sts")) {
            var MeetingInRead = window.setInterval(function(){
                if (TestCount == 15) {
                    clearInterval(MeetingInRead);
                    alert('等待好友列表填充超时');
                    return false;
                }
                if (_Me.PSW.readMyFriended == 1) {
					 clearInterval(MeetingInRead);
                    eval("_Me" + command + "(data)");
                }
                TestCount++;
            }, 600)
        }
        else 
		{
            eval("_Me" + command + "(data)");
        } 
    }
	this.Connect=function(Obj)
	{
		return ;		
	}
	this.Message=function(Obj)
	{
		return ;
	}
	this.P2P=function(Obj)
	{
		return;
	}
	this.Parse_Meeting=function(Obj)
	{
		return;
	}
	this.Login=function(Obj)
	{
		if (Obj.Succeed==false)
		{
			   this.SysMessage.ClearMsg();
		        _Me.netWork.delOneProcess("Login")
				_Me.SysMessage.ShowMsg("登录失败","3000",false);
		        _Me.CMD.loginWebIM.DataPass(Obj.Message);
		        _Me.PSW.loginIn = 0;
		}
		if (Obj.Succeed==true&& _Me.PSW.isReLogin==0)
		{
			_Me.Data.SendKeepData();
			_Me.netWork.delOneProcess("Login")
			 this.SysMessage.ClearMsg();
			_Me.Parse.ParseBody(Obj,".Login");
			 _Me.SysMessage.ShowMsg("获取账号信息","3000",false);
			_Me.CMD.GetMyInfo();
		}
		if (Obj.Succeed==true&& _Me.PSW.isReLogin==1)
		{
			_Me.Data.SendKeepData();
			_Me.netWork.delOneProcess("Login")
			 this.SysMessage.ClearMsg();
		}
	}
	this.User_Inf=function(Obj)
	{
		_Me.Parse.ParseBody(Obj,".User_Inf");
		_Me.SysMessage.ShowMsg("登录完成......","3000",true)
		_Me.CMD.loginWebIM.DataPass(1);
	    _Me.PSW.loginIn = 1;
		Other.SetCookie("WEBSJQLOGIN","1");
		Other.SetCookie("WEBSJQCoreType",_Me.PSW.imCoreType);
	},
	this.User_Sav=function(Obj)
	{
		if (Obj.Succeed == true) {
			_Me.SysMessage.ClearMsg();
		}
		if (Obj.Succeed == false) {
			_Me.SysMessage.ClearMsg();
			_Me.Common.showAlert("保存资料时出错,请注意重新保存", "服务器消息", null, null, null, null);
		}
	}
	this.Buddy_Get=function(Obj)
	{
        _Me.netWork.delOneProcess("GetFriendList");
		if (Obj.Succeed == true) {
			if (Obj.Data.Action == "All") {
				_Me.Parse.ParseBody(Obj, ".Buddy_Get");
				_Me.CMD.renderMyFriend();
			}
			if (Obj.Data.Action == "One")
			{
				   _Me.netWork.delOneProcess("GetBuddyInfo");
                   _Me.CMD.showUserCard(Obj);
			}
		}
	}
	this.Buddy_Grp=function(Obj)
	{
		_Me.SysMessage.ClearMsg();
		if (Obj.Succeed==true){
			if (Obj.Data.Action=="Add"){
				     _Me.Parse.addNewGroup(Obj.Data.GroupName);
                     UserView.addNewGroup(Obj.Data.GroupName);
			}
			if (Obj.Data.Action=="Move"){
				var NewGroupId=_Me.Parse.getGroupIdByGroupName(Obj.Data.NewGroupName);
				if (NewGroupId != "false") {
					_Me.Parse.chageUserGroup(Obj.Data.Uin,NewGroupId);
					UserView.Show();
				}
			}
			if (Obj.Data.Action=="Del")
			{
				var GroupId=_Me.Parse.getGroupIdByGroupName(Obj.Data.GroupName);
				_Me.Parse.delOneGroupByGroupId(GroupId);
				UserView.Show();
			}
		}
		else
		{
			_Me.SysMessage.ShowMsg("分组相关操作失败","100000",false)
		}
	}
	this.Buddy_Sts=function(Obj)
	{
		if(_Me.PSW.isAutoLogin==1)
		{
			return false;
		}
        _Me.Parse.ParseBody(Obj,".Buddy_Sts");
        var id = _Me.Win.id;
        var t = _Me.Win.type;
        var obj = $("wMainMainId" + id + "Type" + t);
        UserView.parent = _Me;
        UserView.main = obj;
        UserView.changeItem(Obj);
	}
	this.Buddy_Srh=function(Obj)
	{
		_Me.SysMessage.ClearMsg();
        _Me.netWork.delOneProcess("SeachFriend");
		_Me.Parse.SeachTemp=Obj;
		_Me.CMD.showSeachResult();
	}
	this.Buddy_Rmk=function(Obj)
	{
		if (Obj.Succeed==true)
		{
			_Me.SysMessage.ClearMsg();
			return ;
		}
		else
		{
			_Me.Common.showAlert("保存备注出错,请重新保存<br>", "服务器消息", null, null, null, null);
		}
	} 
	this.Buddy_Del=function(Obj)
	{
		_Me.SysMessage.ClearMsg();
		if (Obj.Succeed==true)
		{
        var RemoveUid = Obj.Data.Uin;
        UserView.Data = _Me.Parse;
        UserView.delOneUserByUid(RemoveUid);
		}
	}
	this.Buddy_Add=function(Obj)
	{
		if (Obj.Action=="Server"&&Obj.Accept==false)
		{
			alert(Obj.Message);
			return false;
		}
		if (Obj.Action=="Response"&&Obj.Accept==true)
		{
        		_Me.Parse.ParseBody(Obj,".Buddy_Add");
		        UserView.Data = _Me.Parse;
		        UserView.addNewUserByData(Obj)
		}
		
	    if (Obj.Action=="Response"&&Obj.Accept==false)
		{
			_Me.Common.showAlert("对方拒绝<br>"+Obj.Message, "服务器消息", null, null, null, null);
		}
	    if (Obj.Action=="Request")
		{
			var FromUin=Obj.From;
			var GroupName=Obj.GroupName;
			var Message=Obj.Message;
             _Me.CMD.ShowFriendRequestWin(FromUin,GroupName,Message,Obj);
		}
	}
	this.Buddy_Ofl=function()
	{
		return ;
	} 
	this.Buddy_Msg=function(Obj)
	{
        if (_Me.winfocus == 0) UserView.FlashTitle();
        _Me.Common.playSound("NewMessage");
		Uid=Obj.From;
		if (_Me.Parse.GetUserStauts(Uid) == 0) {
			_Me.Parse.setUserStauts(Uid, 2);
		}
		SAYUID=Obj.From;
		//标记到程序状态字，供UserView 来使用
		_Me.PSW.LastMsgUser= _Me.Parse.GetUserCommentByUid(SAYUID);
	    var NeedFlash=0;
        MsgBody =Obj.Msg;
		MsgBody =MsgBody.replaceAll("<div>","&nbsp;");
		MsgBody =MsgBody.replaceAll("</div>","");
		MsgBody =MsgBody.replaceAll("<br>","<br>&nbsp;");
		MsgBody = _Me.Common.passImgLink(MsgBody);
		MsgBody=_Me.Common.replaceFaceFromStr(MsgBody);
        if (MsgBody== "[|FlashWin|]") {
			NeedFlash=1;
            MsgBody = "<br>&nbsp;" + _Me.Parse.GetUserCommentByUid(SAYUID) + " <font color=\"#999999\">给您发了一个闪屏震动</font>";
			Obj.Time=new Date();
        }
        var winChat = WinManage.GetWindow(Uid, 1);
        if (winChat) {
            if (winChat.isMin) {
				winChat.win.Minimize();
			_Me.CMD.ScroolMsgBody();
			}
            if (NeedFlash==1) {
                WinManage.FlashWindow(winChat);
				NeedFlash=0;
            }
            mydatas = new myData;
            ShowMsgBody = "<br>&nbsp;<strong><font color=blue>" + _Me.Parse.GetUserCommentByUid(SAYUID) + "&nbsp;&nbsp;说:&nbsp;&nbsp;" + GetStringData(Obj.Time)+ "</font></strong>&nbsp;&nbsp;<br>" + MsgBody;
			ShowMsgBody =_Me.Common.passImgLink(ShowMsgBody);
			ShowMsgBody =_Me.Common.replaceFaceFromStr(ShowMsgBody);
            WebIndex.WebIm.CMD.showChatContent(Uid, ShowMsgBody);
            _Me.CMD.ScroolMsgBody(Uid);
            _Me.Msgs.inMsg(Uid, SAYUID, MsgBody,GetStringData(Obj.Time));
        }
        else {
            UserView.flashView(SAYUID);
            _Me.Msgs.inMsg(Uid, SAYUID, MsgBody,GetStringData(Obj.Time));
            if (Other.GetCookie("UserMsgBox") != "0") {
                _Me.CMD.showMsgBox(SAYUID, _Me.Parse.GetUserCommentByUid(SAYUID), MsgBody, 1);
            }
        }
	}
	this.TmpUins=function(Obj)
	{
		_Me.SysMessage.ClearMsg();
		if (Obj.Succeed == true) {
			var UserUin = Obj.Data.Uin+"";
			var PassWord = Obj.Data.Password;
			_Me.Data.setUserLogin(UserUin, PassWord, 1, "", 1);
			_Me.SysMessage.ShowMsg("验证用户身份",3000,true);
		}
		else
		{
			alert('分配账号时,产生了错误');
		}
	}
    this.MiniWeb = function(Obj){
        _Me.Parse.ParseBody(Obj,".MiniWeb");
    }
	this.User_Out=function(Obj)
	{
		_Me.Data.setUserLogout();
        alert(Obj.Message);
        window.location = "index.htm";
	}
    this.Transmit = function(Obj)
	{
        switch (Obj.Cmd) {
            case "SFW":
			    var msg ="[|FlashWin|]";
                $("debugmsg").value += "\n" + ".msg " +  Obj.Uin + " " +  Obj.Uin + " " + msg + " " + _Me.Parse.uid
				this.Buddy_Msg({From:Obj.Uin,To:_Me.Parse.uid,Time:Obj.Time,Msg:msg});
                break;
            case "BWM":
                objStauts = $("wChatStauts" +  Obj.Uin);
                if (objStauts != null) {
                    objStauts.innerHTML = "对方正在输入";
                }
                break;
            case "EWM":
                objStauts = $("wChatStauts" +  Obj.Uin);
                if (objStauts != null) {
                    objStauts.innerHTML = '';
                }
                break;
            default:
                break;
        }
    }
    this.Initialize = function(){
        if (!Other.TestCookie()) {
            alert("注意：您的浏览器不支持Cookie，部分功能将无法使用!");
        }
		_Me.CMD.intLoginWindow();
        _Me.winfocus = 1;
		_Me.CMD.PassFocusLg();
    }
	this.AutoLoginManInt=function()
	{
		_Me.AutoLogin.PassLogin();
		if (_Me.PSW.isAutoLogin==1)
		{
			if (_Me.im == null) {
				window.setTimeout(function(){
					_Me.InitCore();
					},300)
			}
		}
	}
    this.Common = {
        playSound: function(soundname){
            var oDiv = $("divSound");
            if (!oDiv) 
                return;
            Elem.Value(oDiv, "<embed id=\"sound\" name=\"sound\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" src=\"sound/" + soundname + ".swf\" width=\"1\" height=\"1\" type=\"application/x-shockwave-flash\" autoplay=\"true\" quality=\"high\" loop=\"False\"></embed>");
        },
		WriteUbbImage:function()
		{
			
		},
		passImgLink:function(Str){
			var Arr=Str.split("[/img]");
			for (var i=0;i<Arr.length;i++)
			{
				Str = Str.replace(/\[img\]http:\/\/(\S*)\.jpg\[\/img\]/i, "<img src=\"http://$1.jpg\" Type=\"NetWork\">");
				Str = Str.replace(/\[img\]http:\/\/(\S*)\.gif\[\/img\]/i, "<img src=\"http://$1.gif\" Type=\"NetWork\" >");
			}
			Str = Str.replace(/http:\/\/(\S*)\.(\S{3,4})&nbsp;/ig,"<a href=\"http://$1.$2\" target=\"_blank\">http://$1.$2</a>");
			Str = Str.replace(/http:\/\/(\S*)\.(\S{3,4})\?(\S*)&nbsp;/ig,"<a href=\"http://$1.$2?$3\" target=\"_blank\">http://$1.$2?$3</a>");
			return Str;
		},
        replaceFaceFromStr: function(str){
		var Cmstr="微笑,撇嘴,色,发呆,得意,流泪,害羞,闭嘴,睡,大哭,尴尬,发怒,调皮,呲牙,惊讶,难过,酷,冷汗,抓狂,呕吐,偷笑,可爱,白眼,傲慢,饥饿,困,惊恐,流汗,憨笑,大兵,奋斗,咒骂,疑问,嘘,晕,折磨,衰,骷髅,敲打,再见,擦汗,抠鼻,鼓掌,糗大,坏笑,左哼哼,右哼哼,哈欠,鄙视,委屈,欲哭,阴险,亲亲,吓,可怜,菜刀,西瓜,啤酒,篮球,乒乓,咖啡,米饭,猪头,玫瑰,凋谢,示爱,爱心,心碎,蛋糕,闪电,炸弹,血刀,足球,瓢虫,便便,月亮,太阳,礼物,拥抱,强,弱,握手,胜利,抱拳,勾引,拳头,差劲,爱你,NO,Ok" ;
		Cmarray=Cmstr.split(",");
		    for (var i = 0; i < 90; i++) {
				var NeddReplaceStr="<IMG title="+Cmarray[i]+" type=\"Face\" fn=\""+i+".gif\">";
                str = str.replaceAll(NeddReplaceStr,"<IMG  src=\"/MsnFace/"+i+".gif\">" );
            }
            return str;
        },
		replaceFaceFromInputStr:function(str)
		{
	    var Cmstr="微笑,撇嘴,色,发呆,得意,流泪,害羞,闭嘴,睡,大哭,尴尬,发怒,调皮,呲牙,惊讶,难过,酷,冷汗,抓狂,呕吐,偷笑,可爱,白眼,傲慢,饥饿,困,惊恐,流汗,憨笑,大兵,奋斗,咒骂,疑问,嘘,晕,折磨,衰,骷髅,敲打,再见,擦汗,抠鼻,鼓掌,糗大,坏笑,左哼哼,右哼哼,哈欠,鄙视,委屈,欲哭,阴险,亲亲,吓,可怜,菜刀,西瓜,啤酒,篮球,乒乓,咖啡,米饭,猪头,玫瑰,凋谢,示爱,爱心,心碎,蛋糕,闪电,炸弹,血刀,足球,瓢虫,便便,月亮,太阳,礼物,拥抱,强,弱,握手,胜利,抱拳,勾引,拳头,差劲,爱你,NO,Ok" ;
		Cmarray=Cmstr.split(",");
			    for (var i = 0; i < 90; i++) {
                str = str.replaceAll("[#" + i + "#]", "<IMG title="+Cmarray[i]+" type=\"Face\" fn=\""+i+".gif\">");
            }
            return str;
		},
        getUserStatusStr: function(n){
            return ["离线", "联机", "隐身"][n];
        },
        changeSelItem: function(o, evt){
            var objSel = _Me.Sys["ObjSel"];
            var e = evt || event;
            if (objSel && objSel != o) {
                objSel.style.backgroundColor = "";
            }
            if (Other.Browser() == "opera") {
                if ($("btnOpera")) 
                    Elem.Del("btnOpera");
                var btn = Elem.New("input", "btnOpera");
                btn.type = "button";
                var bs = btn.style;
                bs.zIndex = "9999";
                bs.opacity = "0.01";
                bs.height = "20px";
                bs.width = "20px";
                bs.top = (Evt.Top(e) - 5) + "px";
                bs.left = (Evt.Left(e) - 5) + "px";
                bs.position = "absolute";
                Elem.Add(btn);
            }
            o.style.backgroundColor = "#D2EAF6";
            _Me.Sys["ObjSel"] = o;
        },
        showAlert: function(msg, title, closecb, url, icon, loadedcb){
            if ($("windowCover")) {
                var cs = $("windowCover").style;
                cs.display = "block";
                cs.height = Elem.Height() + "px";
                cs.width = Elem.Width() + "px";
                cs.zIndex = ++window.zIndex;
            }
            var w = new WebForm();
            w.Title = title || "注意";
            w.Icon = icon || "warning.gif";
            w.Type = 3;
            w.UserID = 4;
            w.Height = 120;
            w.Width = 210;
            w.CanControl = !!0;
            w.Resizeable = !!0;
            w.ShowCorner = !!0;
            w.ContentUrl = url || "layout/winalert.htm";
            w.Left = (Elem.Width() - 210) / 2;
            w.Top = (Elem.Height() - 130) / 2;
            w.RepaintMethod = function(w, h, id, t){
                $("wOtherMainId" + id + "Type" + t).style.height = h + "px";
                if ($("divMsgId" + id + "Type" + t)) 
                    Elem.Value("divMsgId" + id + "Type" + t, msg);
            };
            w.CloseCallback = closecb || null;
            w.LoadedCallback = function(id, t){
                $("btnSelId" + id + "Type" + t).focus();
                if (loadedcb) 
                    loadedcb(id, t);
            };
            w.Show();
            w.Focus();
            return w;
        },
        showConfirm: function(msg, title, cb){
            _Me.Common.showAlert(msg, title, cb, "layout/winconfirm.htm", "confirm.gif");
        },
        showPrompt: function(value, title, cb){
            _Me.Common.showAlert(value, title, cb, "layout/winPrompt.htm");
        },
        showSelect: function(title, loadedcb, closecb){
            _Me.Common.showAlert(null, title, closecb, "layout/winSelect.htm", null, loadedcb);
        },
        showLink: function(_w, _h, _t, _l, _id, _title, _url, _icon, _closecb){
            var wLink = WinManage.GetWindow(_id, 3);
            if (wLink) {
                if (wLink.isMin) 
                    wLink.win.Minimize();
                wLink.win.Focus();
                return;
            }
            var w = new WebForm();
            w.Title = _title || "QGYWebIM";
            w.Icon = _icon || "defaulticon.gif";
            w.Type = 3;
            w.UserID = _id;
            w.Height = _h;
            w.Width = _w;
            w.Left = _l;
            w.Top = _t;
            w.Resizeable = !!0;
            w.ShowCorner = !!0;
            w.Content = "<iframe scrolling='auto' id='ifrId[id]Type[type]' frameborder='0' src='" + _url + "'></iframe>";
            w.RepaintMethod = function(w, h, id, t){
                $("ifrId" + id + "Type" + t).style.height = h + "px";
                $("ifrId" + id + "Type" + t).width = w - 2 + "px";
            };
            w.LoadedCallback = function(){
            }
            if (_closecb) 
                w.CloseCallback = _closecb;
            w.Show();
            w.Focus();
        }
    };
    this.Config = {
        MsgSendKey: 2,
		ChatSide:0,
		MqqDownLoadUrl:"http://sjq.sjoem.com"
    };
    this.Data = {
		AddNewGroup:function(GroupName)
		{
			_Me.SysMessage.ShowMsg("正在添加分组","3000",false)
			if (_Me.Parse.CheckGroup(GroupName) == false) {
				var ObjData = {
					Action: "Add",
					GroupName: GroupName
				};
				var SendData = obj2str(ObjData)
				_Me.im.SendData(".Buddy Grp " + SendData);
			}
		},
		MoveGroup:function(Uin,NewGroupId)
		{
			_Me.SysMessage.ShowMsg("正在移动分组","3000",false)
			var OldGroupName=_Me.Parse.GetGroupNameByUid(Uin);
			var NewGroupName=_Me.Parse.GetGroupNameByGroupId(NewGroupId);
			var ObjData={Action:"Move",GroupName:OldGroupName,NewGroupName:NewGroupName,Uin:Uin}
			var SendData=obj2str(ObjData);
			_Me.im.SendData(".Buddy Grp "+SendData);
		},
		DelGroup:function(GroupId)
		{
			_Me.SysMessage.ShowMsg("正在删除分组","3000",false)
			var ToBeDelGroupName=_Me.Parse.Groups[GroupId];
			var ObjData={Action:"Del",GroupName:ToBeDelGroupName};
			var SendData=obj2str(ObjData);
			_Me.im.SendData(".Buddy Grp "+SendData);
		},
		ChangeUserCommentName:function(Uid,Value)
		{
			_Me.SysMessage.ShowMsg("正在更改备注名称","3000",false)
			var ObjData = {
				Uin: Uid,
				RemarkName:Value
			}	
			var SendData=obj2str(ObjData);
			_Me.im.SendData(".Buddy Rmk "+SendData);
		},
		DelUser:function(Uid)
		{
		   _Me.SysMessage.ShowMsg("正在删除用户","3000",false)
			var ObjData={Uin:Uid};
			var SendData=obj2str(ObjData);
			_Me.im.SendData(".Buddy Del "+SendData);
		},
		SendKeepData:function()
		{
			if (_Me.PSW.imCoreType == "Flash"&&_Me.PSW.Keeper==null) {
			_Me.PSW.Keeper=window.setInterval(function(){
					_Me.im.SendData(".Keep");
				}, 270000)
			}
		},
        getMiniWebUrl: function(){
            setTimeout(function(){
                _Me.im.SendData(".MiniWeb");
            }, 3000)
        },
        getMsnFaceInfo: function(){
            ReturnArray = new Array()
            var i = 0;
            for (i = 0; i < 90; i++) {
                ReturnArray[i] = new Array();
                ReturnArray[i][0] = i;
                ReturnArray[i][1] = "";
                ReturnArray[i][2] = "[#" + i + "#]";
            }
            return ReturnArray;
        },
        sendAddFirRequest: function(uid, Group, message){
            if (message == "") {
                message = "未填写";
            }
			var ObjData={Action:"Request",From:_Me.Parse.uid,To:uid,GroupName:Group,Message:message};
			var SendData=obj2str(ObjData);
            _Me.im.SendData(".Buddy Add "+SendData);
        },
        getMyFriendList: function(){
			var Data={Action:"All"};
            _Me.im.SendData(".Buddy Get "+obj2str(Data));
            _Me.netWork.addOneCheck("GetFriendList", 20, "获取好友列表,服务器未响应,请检查网络", 1, null);
        },
        setUserLogin: function(uid, pass, us, cb,hex){
			if (!_Me.im)
			{
				_Me.SysMessage.ShowMsg("正在连接服务器","3000",false)
				_Me.InitCore();
			}
			
		    if (!hex) {
				pass = hex_md5(pass);
			}
			pass = pass.toUpperCase();
            if (us == 0) {
                us = 0;
            }
            else {
                us = us - 1;
            }
            var TestCount = 0;
            var Login = setInterval(function(){
                if (TestCount == 30) {
                    alert('与服务器连接时发生超时');
                    clearInterval(Login)
					WebIndex.WebIm.PSW.LocationReload=1;
                    window.location.reload();
                    return;
                }
                if (_Me.PSW.connect == 1) {
					
			     _Me.Parse.UserCacheInfo.LoginUserName=uid;
				 _Me.Parse.UserCacheInfo.LoginPassWord=pass;
				 _Me.Parse.UserCacheInfo.LoginStauts=us;
				 
				 loginDataObj={Uin:uid,States:us,Password:pass,ClientType:2};
				 loginData=".Login"+" "+obj2str(loginDataObj)
                 _Me.im.SendData(loginData);
				 _Me.SysMessage.ShowMsg("正在验证您账号密码","3000",false)
				 if (_Me.PSW.isReLogin != 1) {
				 	_Me.netWork.addOneCheck("Login", 30, "登陆时,服务器未响应,请检查网络", 1, null);
				 }
                 window.clearInterval(Login);
                }
                else {
                    TestCount++;
                }
            }, 1000)
        },
        setUserLogout: function(){
            if (_Me.im != null) {
                if (_Me.PSW.loginIn == 1) {
				 var ObjData = {Status:"0",Message:""}
				_Me.im.SendData(".Buddy Sts "+obj2str(ObjData));
                _Me.PSW.loginIn = 0;
                }
				if (_Me.im.Disconnect) {
					_Me.im.Disconnect();
					_Me.im = null;
				}
            }
			Other.SetCookie("WEBSJQLOGIN","0");
			Other.SetCookie("WEBSJQCoreType","");
			WebIndex.WebIm.PSW.LocationReload=1;
            top.location = "index.htm";
        },
        changeUserstauts: function(n){
            if (n == 2) {
				var ObjData = {Status:"2",Message:""}
                _Me.im.SendData(".Buddy Sts "+obj2str(ObjData));
            }
            else {
				var ObjData = {Status:"1",Message:""}
				_Me.im.SendData(".Buddy Sts "+obj2str(ObjData));
            }
        }
    }
    this.CMD = {
        initConfig: function(){
            if (Other.GetCookie("MsgSendType") == "Enter") {
                WebIndex.WebIm.Config.MsgSendKey = 2;
            }
            else {
                WebIndex.WebIm.Config.MsgSendKey = 1;
            }
        },
		GetMyInfo:function()
		{
			_Me.im.SendData(".User Inf");
		},
        OnReadFriend: function(){
            _Me.PSW.readMyFriended = 1;
			_Me.SysMessage.ClearMsg();
				_Me.CMD.OpenHistoryWin();
        },
		CheckTransmitChatUin:function()
		{
			window.setInterval(function(){
				var ChatUin=Other.GetCookie("TransmitChatUin");
				if (ChatUin!="")
				{
					_Me.SysMessage.ShowMsg("打开聊天窗口","3000",false)
					_Me.CMD.openChatWindow(ChatUin,1);
					Other.SetCookie("TransmitChatUin","");
				}
			},2000)
		},			
        PassKey: function(e){
            var e = e || event;
            if (e.keyCode == 88) {
                if (e.ctrlKey && e.altKey) {
                    for (var i = 0; i < UserView.falshUsers.length; i++) {
                        _Me.CMD.openChatWindow(UserView.falshUsers[i], true);
                        return;
                    }
                }
            }
        },
		SetOffLineMode:function()
		{
			if (_Me.Win) {
				var id = _Me.Win.id;
				var t = _Me.Win.type;
				_Me.SysMessage.ShowMsg("与服务器的连接已经中断,请检查网络连接,系统正在尝试再次连接");
				 //$("wMainUserFaceId" + id + "Type" + t).src ="/Images/"+ _Me.CMD.passOflFaceByFacenum(_Me.Parse.userInfo.IcoId);
			   
			}
		},
		SetOnlineMode:function()
		{
			if (_Me.Win) {
				var id = _Me.Win.id;
				var t = _Me.Win.type;
				_Me.SysMessage.ClearMsg();
				 //$("wMainUserFaceId" + id + "Type" + t).src ="/Images/"+ _Me.CMD.passFaceByFacenum(_Me.Parse.userInfo.IcoId);
			}
		},
        SendWriteMsg: function(Uin){
            if (_Me.Parse.GetUserStauts(Uin) != 1) 
                return;
            if (_Me.PSW.checkWrite(Uin) == false) {
				var DataObj={Uin:Uin,Cmd:"BWM",Tag:""};
                _Me.im.SendData(".Transmit" + obj2str(DataObj));
            }
            _Me.PSW.addNewWrite(Uin)
        },
        SendNoWriteMsg: function(Uin){
            if (_Me.Parse.GetUserStauts(Uin) != 1) 
                return;
            if (_Me.PSW.checkWrite(Uin) == true) {
				var DataObj={Uin:Uin,Cmd:"EWM",Tag:""};
                _Me.im.SendData(".Transmit" + obj2str(DataObj));
            }
            _Me.PSW.delOneWrite(Uin)
        },
		SaveHistory:function(ToUin)
		{
			var ToUser=_Me.Parse.GetUserNameByUid(ToUin);
			_Me.ChatHistoryHelper.ToUserName=ToUser;
			var Value=_Me.ChatHistoryHelper.ConvertHistoryToHtml(_Me.Parse.uid,_Me.Parse.userInfo.NickName,ToUin);
			Value= _Me.Common.replaceFaceFromStr(Value);
			var FileName="与"+ ToUser+"的聊天记录.html";
			if(navigator.userAgent.indexOf("MSIE")>0) { 
                FileName= encodeURIComponent(FileName);
		    } 
			document.ChatHistoryForm.FileName.value=FileName;
			document.ChatHistoryForm.Content.value=Value;
			document.ChatHistoryForm.submit();
			return;
		},
		SeachFriend:function(Value)
		{
			if (Value=="")
			{
				_Me.CMD.HiddenUserViewDiv();
				return;
			}
			_Me.UserViewSeachHelper.OnReandOk=_Me.CMD.ShowUserViewDiv;
			_Me.UserViewSeachHelper.SeachUser(Value);
		},
		ShowUserViewDiv:function()
		{
			$(_Me.UserViewSeachHelper.ViewDivId).style.display="";
		},
		HiddenUserViewDiv:function()
		{
			$(_Me.UserViewSeachHelper.ViewDivId).style.display="none";
		},
		PassUserViewDivFocus:function(KeyCode)
		{
			_Me.UserViewSeachHelper.PassFocus(KeyCode);
		},
		ClearUserViewDiv:function()
		{
			$(_Me.UserViewSeachHelper.ViewDivId).innerHTML="";
		},
		ShowSJQDownLoad:function(id)
		{
			window.open('http://sjq.sjoem.com');	
		    _Me.CMD.HiddenAlarmDiv(id);
		},
		HiddenAlarmDiv:function(id)
		{
			var AlarmDiv=$("AlarmDiv"+id);
			if (AlarmDiv != null) {
				AlarmDiv.style.display = "none";
			}
		},
        sendFlashWin: function(Uin){
            if (_Me.Parse.GetUserStauts(Uin) == 0) {
				alert('对方不在线或者隐身，不能发送闪屏');
                return false;
            }
            if (_Me.PSW.sendFlashWining == 1) {
                alert('请不要发的太快');
                return false;
            }
			var ObjData={Uin:Uin,Cmd:"SFW",Tag:""}
			var SendData=obj2str(ObjData)
            _Me.im.SendData(".Transmit  "+SendData);
            _Me.PSW.sendFlashWining = 1;
            setTimeout(function(){
                _Me.PSW.sendFlashWining = 0
            }, 10000)
            return true;
        },
        addNewGroup: function(){
            _Me.Common.showPrompt("", "添加新组", function(o, t, v){
                if (v != "") {
					if (_Me.Parse.CheckGroup(v) == true) {
						alert("分组名称已经存在,请重新输入!");
					}
					else {
						var GroupName = v;
						_Me.Data.AddNewGroup(GroupName);
					}
                }
            })
        },
        moveGroup: function(uid){
            var wWin = _Me.Win;
            var winMoveGroup = WinManage.GetWindow("winMoveGroup", 3);
            if (winMoveGroup)
            {
                if (winMoveGroup.isMin) {
                    winMoveGroup.win.Minimize();
                }
                winMoveGroup.win.Focus();
            }
            else {
                var w = new WebForm();
                w.Title = "选择新分组-移动好友 Web 手机Q 1.0";
                w.Icon = "ToolOption.gif";
                w.Type = 3;
                w.UserID = "winMoveGroup";
                w.Height = 150;
                w.Width = 300;
                w.Resizeable = 0;
                var lastChatWin = WinManage.GetLastWindow(1);
                if (!lastChatWin) {
                    w.Left = wWin.win.Left < 425 ? wWin.win.Left + wWin.win.Width + 2 : wWin.win.Left - 422;
                    w.Top = wWin.win.Top;
                }
                else {
                    w.Left = lastChatWin.win.Left + 15;
                    w.Top = lastChatWin.win.Top + 15;
                }
                w.ContentUrl = "Layout/winSelect.html";
                w.LoadedCallback = function(){
                    uid = uid.replace("user_", "");
                    var nowGroupId = _Me.Parse.GetGroupIdByUid(uid);
                    var nowGroup = _Me.Parse.Groups[nowGroupId];
                    $("NowGroup").innerHTML = nowGroup;
                    var tempInnerHTML = "<select id=\"MoveToGroup\">";
					var canMoveGroupCount=0;
                    for (var i = 0; i < _Me.Parse.Groups.length; i++) {
                        if (i != nowGroupId && _Me.Parse.Groups[i]!= "陌生人") {
                            tempInnerHTML += "<option value=\"" + i + "\">" + _Me.Parse.Groups[i] + "</option>"
							canMoveGroupCount++;
						}
                    }
					if (canMoveGroupCount==0)
					{
						tempInnerHTML+="<option value=\"\">--------</option>"
					}
                    tempInnerHTML += "</select>";
                    $("GroupSelectDiv").innerHTML = tempInnerHTML;
                    $("MoveGroupSaveButton").onclick = function(){
                        if ($F("MoveToGroup") == "") {
                            alert('请选择目标组');
                            return false;
                        }
						var Uin=uid;
						var NewGroupId=$F("MoveToGroup")
						_Me.Data.MoveGroup(Uin,NewGroupId);
                        w.Close();
                    }
                }
                w.Show();
            }
        },   
        actionSendMsg: function(uid){ 
            var winChat = WinManage.GetWindow(uid, 1);
            if (winChat) {
                var obj = $("Alert" + uid + "Type1")
                if (obj != null) {
                    if ($("sysmsg" + uid)) {
                        Elem.Del($("sysmsg" + uid))
                    }
                    obj.style.display = "";
                    obj.innerHTML = "<div id='sysmsg" + uid + "' style=\"background-color: #E8F0F9;padding-left:15px\">该好友上线了!</div>" + obj.innerHTML;
                    setTimeout(function(){
                        Elem.Del($("sysmsg" + uid))
                    }, 3000)
                }
            }
        },
        closeSendMsg: function(uid){
            var winChat = WinManage.GetWindow(uid, 1);
            if (winChat) {
                var obj = $("Alert" + uid + "Type1")
                if (obj != null) {
                    if ($("sysmsg" + uid)) {
                        Elem.Del($("sysmsg" + uid))
                    }
                    obj.style.display = "";
                    obj.innerHTML = "<div id='sysmsg" + uid + "' style=\"background-color: #E8F0F9;padding-left:15px;padding-top:2px\">对方不在线或者隐身可能不能立即回复！</div>" + obj.innerHTML;
                }
            }
        },
        editOption: function(){
            var wWin = _Me.Win;
            var winOption = WinManage.GetWindow("option", 3);
            if (winOption)
            {
                if (winOption.isMin) {
                    winOption.win.Minimize();
                }
                winOption.win.Focus();
            }
            else {
                var w = new WebForm();
                w.Title = "选项 Web 手机Q 1.0";
                w.Icon = "nothing.gif";
                w.Type = 3;
                w.UserID = "option";
                w.Height = 140;
                w.Width = 300;
                w.Resizeable = 0;
                var lastChatWin = WinManage.GetLastWindow(1);
                if (!lastChatWin) {
                    w.Left = wWin.win.Left < 425 ? wWin.win.Left + wWin.win.Width + 2 : wWin.win.Left - 422;
                    w.Top = wWin.win.Top;
                }
                else {
                    w.Left = lastChatWin.win.Left + 15;
                    w.Top = lastChatWin.win.Top + 15;
                }
                
                w.ContentUrl = "Layout/winOption.html";
                w.LoadedCallback = function(){
                    if (Other.GetCookie("UserMsgBox") != "") {
                        if (Other.GetCookie("UserMsgBox") == "1") {
                            document.getElementsByName("UserMsgBox")[0].checked = true;
                        }
                        else {
                            document.getElementsByName("UserMsgBox")[1].checked = true;
                        }
                    }
                    if (Other.GetCookie("MsgSendType") != "") {
                        if (Other.GetCookie("MsgSendType") == "Enter") {
                            document.getElementsByName("MsgSendType")[1].checked = true;
                        }
                        else {
                            document.getElementsByName("MsgSendType")[0].checked = true;
                        }
                    }
                    $("OptionSaveButton").onclick = function(){
                        for (var i = 0; i < document.getElementsByName("UserMsgBox").length; i++) {
                            if (document.getElementsByName("UserMsgBox")[i].checked == true) {
                                var UserMsgBox = document.getElementsByName("UserMsgBox")[i].value;
                            }
                        }
                        for (var i = 0; i < document.getElementsByName("MsgSendType").length; i++) {
                            if (document.getElementsByName("MsgSendType")[i].checked == true) {
                                var MsgSendType = document.getElementsByName("MsgSendType")[i].value;
                            }
                        }
                        Other.SetCookie("UserMsgBox", UserMsgBox);
                        Other.SetCookie("MsgSendType", MsgSendType);
                        w.Close();
                    }
                }
                w.Show();
                w.Focus();
            }
        },
        closeImCore: function(){
            if (_Me.im) {
                _Me.Data.setUserLogout();
            }
        },
		PassFocusLg:function()
		{
				document.onblur = function(){
		            _Me.winfocus = 0;
					return;
		        }
				document.onfocus=function()
				{
				   _Me.winfocus = 1;
				   return;
				}
				window.onblur = function(){
		            _Me.winfocus = 0;
		            return;
		        }
		        window.onfocus = function(){
		            _Me.winfocus = 1;
		            return
		        }
				window.onclick=function()
				{
					_Me.winfocus = 1;
		            return
				}
				document.onclick=function()
				{
					_Me.winfocus = 1;
					return;
				}
		},
        showMsgBox: function(uid, title, body, type){
            var mydatas = new myData
            var windbox = WinManage.GetWindow(uid + "_msgbox", 3);
            if (windbox)
            {
                if (windbox.isMin) {
                    windbox.win.Minimize();
                }
                if ($("msgBox" + uid + "_msgbox") != null) {
                    var msg = $("msgBox" + uid + "_msgbox").innerHTML + "<br>" + mydatas.GetAll() + ":<br>" + body;
                    msg = _Me.Common.replaceFaceFromStr(msg)
                    if (windbox != null && $("msgBox" + uid + "_msgbox") != null) {
                        $("msgBox" + uid + "_msgbox").innerHTML = msg;
                    }
                }
            }
            else {
                var w = new WebForm();
                w.Title = "Web 手机Q 1.0";
                w.Icon = "ArrowDown.gif";
                w.Type = 3;
                w.UserID = uid + "_msgbox";
                w.Height = 200;
                w.Width = 300;
                w.Resizeable = 0;
                w.Left = document.documentElement.clientWidth - 315;
                w.Top = document.documentElement.clientHeight - 235;
                w.ContentUrl = "Layout/msgbox.html";
                w.LoadedCallback = function(){
                    var msgclose = setTimeout(function(){
                        w.Close()
                    }, 6000)
                    if (type == 1) {
                        ;
                        var msg = title + "(" + uid + ") 说:   " + mydatas.GetAll() + "<br><br>" + body
                        msg = _Me.Common.replaceFaceFromStr(msg)
                        $("msgBox" + uid + "_msgbox").innerHTML = msg;
                        $("msgBox" + uid + "_msgbox").onclick = function(){
                            _Me.CMD.openChatWindow(uid, true);
                            w.Close();
                        }
                    }
                    else {
                        $("msgBox" + uid + "_msgbox").innerHTML = body;
                        $("msgBox" + uid + "_msgbox").onclick = function(){
                            w.Close();
                        }
                    }
                    if ($("msgBox" + uid + "_msgbox") != null) {
                        $("msgBox" + uid + "_msgbox").onmouseover = function(){
                            if (msgclose) {
                                clearTimeout(msgclose)
                                if ($("msgBox" + uid + "_msgbox")) {
                                    $("msgBox" + uid + "_msgbox").onmouseout = function(){
                                        w.Close();
                                    }
                                }
                            }
                        }
                    }
                }
                w.Show();
            }
        },
        addFirend: function(){
            _Me.Parse.SeachTemp = new Array();
            var wWin = _Me.Win;
            var winSeach = WinManage.GetWindow(8, 3);
            
            if (winSeach)
            {
                if (winSeach.isMin) {
                    winSeach.win.Minimize();
                }
                winSeach.win.Focus();
            }
            else {
                var w = new WebForm();
                w.Title = "添加好友";
                w.Icon = "nothing.gif";
                w.Type = 3;
                w.UserID = 8;
                w.Height = 247;
                w.Width = 358;
                w.Resizeable = 0;
                var lastChatWin = WinManage.GetLastWindow(1);
                if (!lastChatWin) {
                    w.Left = wWin.win.Left < 425 ? wWin.win.Left + wWin.win.Width + 2 : wWin.win.Left - 422;
                    w.Top = wWin.win.Top;
                }
                else {
                    w.Left = lastChatWin.win.Left + 15;
                    w.Top = lastChatWin.win.Top + 15;
                }
                w.ContentUrl = "Layout/winSeachUser.html";
                w.LoadedCallback = function(){
                    $("SeachType").onchange = function(){
                        if ($F("SeachType") != "ID") {
                        }
                    }
                    $("SeachButton").onclick = function(e){
                        var AddType = $F("SeachType");
                        for (var i = 0; i < document.getElementsByName("SeachType").length; i++) {
                            if (document.getElementsByName("SeachType")[i].checked) {
                                var AddType = document.getElementsByName("SeachType")[i].value;
                            }
                        }
                        if (AddType == "ID") {
                            if ($F("Uid") == "" && $F("NickName") == "") {
							var ObjData={Exact:0,Uin:"",Keyword:""}
							_Me.im.SendData(".Buddy Srh "+obj2str(ObjData));
							_Me.netWork.addOneCheck("SeachFriend", 5, "搜索用户时候发生超时,服务器未响应", 0, null);
                            }
                            else {
								 var ObjData={Exact:1,Uin:$F("Uid"),Keyword:$F("NickName")}
								_Me.im.SendData(".Buddy Srh "+obj2str(ObjData));
								_Me.netWork.addOneCheck("SeachFriend", 5, "搜索用户时候发生超时,服务器未响应", 0, null);
                            }
                        }
                        else {
                          var ObjData={Exact:0,Uin:"",Keyword:""}
						  _Me.im.SendData(".Buddy Srh "+obj2str(ObjData));
						  _Me.netWork.addOneCheck("SeachFriend", 5, "搜索用户时候发生超时,服务器未响应", 0, null);
                        }
					_Me.SysMessage.ShowMsg("正在查询","5000",false);
					w.Close();
                    }
                }
                _Me.SeachWin = w;
                w.Show();
                w.Focus();
            }
        },
        showSeachResult: function(w){
            if (_Me.Parse.SeachTemp.length == 0) {
                alert('没有搜索结果')
                return;
            }
            var wWin = _Me.Win;
            var winSeach = WinManage.GetWindow(8, 3);
            if (winSeach) {
                _Me.SeachWin.Close();
            }
            var wWin = _Me.Win;
            var winSeachResult = WinManage.GetWindow(9, 3);
            if (winSeachResult)
            {
                if (winSeachResult.isMin) {
                    winSeachResult.win.Minimize();
                }
                winSeachResult.win.Focus();
            }
            else {
                var w = new WebForm();
                w.Title = "搜索结果";
                w.Icon = "nothing.gif";
                w.Type = 3;
                w.UserID = 9;
                w.Height = 312;
                w.Width = 600;
                w.Resizeable = 0;
                var lastChatWin = WinManage.GetLastWindow(1);
                if (!lastChatWin) {
                    w.Left = wWin.win.Left < 425 ? wWin.win.Left + wWin.win.Width + 2 : wWin.win.Left - 422;
                    w.Top = wWin.win.Top;
                }
                else {
                    w.Left = lastChatWin.win.Left + 15;
                    w.Top = lastChatWin.win.Top + 15;
                }
                w.ContentUrl = "Layout/winSeachResult.html";
                w.LoadedCallback = function(){
                    SeachRowPage = 1;
                    SeachRowPageSize = 6;
                    record = _Me.Parse.SeachTemp.Data;
                    recordCount = record.length;
                    writeButtonFalg = 0;
                    if (recordCount / SeachRowPageSize == 0) {
                        SeachRowPageCount = recordCount / SeachRowPageSize;
                    }
                    else {
                        SeachRowPageCount = Math.floor(recordCount / SeachRowPageSize) + 1;
                    }
                    
                    function WriteTable(){
                        var record = _Me.Parse.SeachTemp.Data;
						if (typeof(record)=="undefined")
						{
							alert('搜索记录为空!');
							w.Close();
							return false;
						}
                        var recordCount = record.length;
                        var StartNum = SeachRowPage * SeachRowPageSize - SeachRowPageSize
                        if (StartNum > recordCount || StartNum < 0) {
                            return;
                        }
                        var endNum = StartNum + SeachRowPageSize;
                        var innerHTML = "<table width=588 height=240 border=0 cellpadding=0 cellspacing=0 ><tr><td valign=\"top\" style=\"padding-left:5px;padding-top:3px;\">"
                        innerHTML += '<table width=588 cellpadding=0 cellspacing=0 style="padding-left:10px">'
                        innerHTML += '<tr><td height=\"34\" >选择</td><td><strong>头像</strong></td><td width="100px"><strong>UID</strong></td><td width="100px"><strong>昵称</strong></td><td><strong>性别</strong></td><td><strong>来自</strong></td><td><strong>状态</strong></td></tr>';
                        for (var i = StartNum; i < endNum; i++) {
                            if (i >= record.length) {
                                continue;
                            }
                            innerHTML += '<tr class="SeachResultTable">'
                            var UserUid = record[i].Uin;
                            var UserFace = record[i].IconId;
                            var UserName = record[i].Nickname;
                            if ( record[i].Sex== 1) {
                                var UserSex = "男";
                            }
                            else {
                                var UserSex = "女";
                            }
							if (record[i].City) {
								var UserProvince = record[i].City;
							}
							else
							{
								var UserProvince="-";
							}
							if (typeof(UserProvince)=="undefined"||!UserProvince)
							{
								var UserProvince="-";
							}
                            if (record[i].Status == 1) {
                                UserStauts = "在线";
                            }
                            else {
                                UserStauts = "离线";
                            }
                            innerHTML += "<td height=\"34\"><input type=radio id=SelectUser name=SelectUser value='" + UserUid + "' /></td><td><img src=" + _Me.CMD.passFaceByFacenum(UserFace) + "><td>" + UserUid + "</td>" + "<td>" + UserName + "</td>" + "<td>" + UserSex + "</td>" + "<td>" + UserProvince + "</td>" + "<td>" + UserStauts + "</td>"
                            innerHTML += '</tr>';
                        }
                        innerHTML += '</table>';
                        innerHTML += '</td></tr></table>';
                        $("SeachResultShow").innerHTML = innerHTML;
                    }
                    function WriteButton(){
                        var innerButtonHTML = "<br>";
                        innerButtonHTML += "&nbsp;&nbsp;<input type=button id=addbutton name=addbutton value=添加 class=button1>";
                        innerButtonHTML += "&nbsp;<input type=button value=上页 id=upPage class=button1>&nbsp;<input type=button value=下页 id=downPage class=button1>"
                        $("SeachResultShow").innerHTML += innerButtonHTML;
                    }
                    function Bup(){
                        if (SeachRowPage != 1) {
                            SeachRowPage = SeachRowPage - 1
                            WriteTable();
                            WriteButton();
                            $("upPage").onclick = Bup;
                            $("downPage").onclick = Bdown;
                            $("addbutton").onclick = Badd;
                        }
                        
                    }
                    function Bdown(){
                        if (SeachRowPage < SeachRowPageCount) {
                            SeachRowPage = SeachRowPage + 1;
                            WriteTable();
                            WriteButton();
                            $("upPage").onclick = Bup;
                            $("downPage").onclick = Bdown;
                            $("addbutton").onclick = Badd;
                        }
                    }
                    function Badd(){
                        var SelectUid = "";
                        for (var i = 0; i < document.getElementsByName("SelectUser").length; i++) {
                            if (document.getElementsByName("SelectUser")[i].checked) {
                                var SelectUid = document.getElementsByName("SelectUser")[i].value;
                            }
                        }
                        if (SelectUid == "") {
                            alert('请先选择一个用户');
                        }
                        else {
                            _Me.CMD.showAddFirendPop(SelectUid);
                        }
                    }
                    WriteTable();
                    WriteButton();
                    $("upPage").onclick = Bup;
                    $("downPage").onclick = Bdown;
                    $("addbutton").onclick = Badd;
                    _Me.SeachWin = w;
                }
                w.Show();
                w.Focus();
            }
        },
        showAddFirendPop: function(Ruid){
            var Ruid = Ruid.replaceAll("user_", "");
            if (_Me.SeachWin) {
                _Me.SeachWin.Close();
            }
            var wWin = _Me.Win;
            var addRequestPop = WinManage.GetWindow("addRequestPop", 3);
            if (addRequestPop)
            {
                if (addRequestPop.isMin) {
                    addRequestPop.win.Minimize();
                }
                addRequestPop.win.Focus();
            }
            else {
                var w = new WebForm();
                w.Title = "添加好友";
                w.Icon = "nothing.gif";
                w.Type = 3;
                w.UserID = "addRequestPop";
                w.Height = 250;
                w.Width = 300;
                w.Resizeable = 0;
                var lastChatWin = WinManage.GetLastWindow(1);
                if (!lastChatWin) {
                    w.Left = wWin.win.Left < 425 ? wWin.win.Left + wWin.win.Width + 2 : wWin.win.Left - 422;
                    w.Top = wWin.win.Top;
                }
                else {
                    w.Left = lastChatWin.win.Left + 15;
                    w.Top = lastChatWin.win.Top + 15;
                }
                w.ContentUrl = "Layout/addFirend.html";
                w.LoadedCallback = function(){
                    var innerHTML = "<select id=toGroup name=toGroup>";
                    innerHTML += '<option value="" >请选择组</option>';
                    for (i = 0; i < _Me.Parse.Groups.length; i++) {
						if(_Me.Parse.Groups[i].trim()=="陌生人") continue;
                        innerHTML += '<option value="' + i + '" >' + _Me.Parse.Groups[i].trim() + '</option>';
                    }
                    innerHTML += "</select>"
                    $("select_div").innerHTML = innerHTML;
                    $("ButtonAdd").onclick = function(){
                        if ($F("toGroup") == "") {
                            alert('请选择要添加到的组');
                            return;
                        }
						var GroupIndex=$("toGroup").value
						if (GroupIndex==null)
						{
							var GroupIndex=0;
						}
                        _Me.Data.sendAddFirRequest(Ruid, _Me.Parse.Groups[GroupIndex], $F("message"));
                        w.Close();
                    }
                    $("CloseButton").onclick = function(){
                        w.Close();
                    }
                }
                w.Show();
                w.Focus();
            }
        },
        editMyinfo: function(){
            var wWin = _Me.Win;
            var winMyinfo = WinManage.GetWindow("myinfo", 3);
            
            if (winMyinfo)
            {
                if (winMyinfo.isMin) {
                    winMyinfo.win.Minimize();
                }
                winMyinfo.win.Focus();
            }
            else {
                var w = new WebForm();
                w.Title = "我的资料";
                w.Icon = "DefaultIcon.gif";
                w.Type = 3;
                w.UserID = "myinfo";
                w.Height = 500;
                w.Width = 500;
                w.Resizeable = 0;
                var lastChatWin = WinManage.GetLastWindow(1);
                if (!lastChatWin) {
                    w.Left = wWin.win.Left < 425 ? wWin.win.Left + wWin.win.Width + 2 : wWin.win.Left - 422;
                    w.Top = wWin.win.Top;
                }
                else {
                    w.Left = lastChatWin.win.Left + 15;
                    w.Top = lastChatWin.win.Top + 15;
                }
                w.ContentUrl = "Layout/winMyinfo.html";
                w.LoadedCallback = function(){
                    $("UserFace").src = ReturnHtml(_Me.CMD.passFaceByFacenum(_Me.Parse.userInfo.IcoId));
                    $("GUID").value = ReturnHtml(_Me.Parse.uid+"");
                    $("NickName").value = ReturnHtml(_Me.Parse.userInfo.NickName);
                    $("age").value = ReturnHtml(_Me.Parse.userInfo.Age+"");
                    $("Country").value = ReturnHtml(_Me.Parse.userInfo.Country);
                    $("Address").value = ReturnHtml(_Me.Parse.userInfo.Address);
                    $("Email").value = ReturnHtml(_Me.Parse.userInfo.Email);
                    $("Sign").value = ReturnHtml(_Me.Parse.userInfo.Sign);
                    $("WebSite").value = ReturnHtml(_Me.Parse.userInfo.WebSite);
                    $("Comment").value = ReturnHtml(_Me.Parse.userInfo.Comment);
                    $("Job").value = ReturnHtml(_Me.Parse.userInfo.Job);
                    Sex = ReturnHtml(_Me.Parse.userInfo.Sex+"")
                    if (Sex == "1") {
                        document.getElementsByName("sex")[0].checked = "checked"
                    }
                    else {
                        document.getElementsByName("sex")[1].checked = "checked"
                    }
                    var FaceSelectInnerHTML = "<input id=\"FaceSelect\" type=\"hidden\" value=\"" + _Me.Parse.userInfo.IcoId + "\"";
                    FaceSelectInnerHTML += ">";
                    $("FaceSelect_div").innerHTML = FaceSelectInnerHTML;
                    $("SHOWFaceWin").onclick = function(){
                        _Me.CMD.showFaceWindow();
                    }
                    $("saveButton").onclick = function(){
                        for (var i = 0; i < document.getElementsByName("sex").length; i++) {
                            if (document.getElementsByName("sex")[i].checked) {
                                var SexValue = document.getElementsByName("sex")[i].value;
                            }
                        }               				
				var ObjData = {
					Detail: {
						Address: encodeHTML($("Address").value.trim()),
						Job: encodeHTML($("Job").value.trim()),
						WebSite: encodeHTML($("WebSite").value.trim()),
						Comment: encodeHTML($("Comment").value)
					},
					Brief: {
						Country: encodeHTML($("Country").value.trim()),
						City: encodeHTML($("Address").value.trim()),
						Age: parseInt(encodeHTML($("age").value)),
						Sex: parseInt(SexValue),
						Nickname: encodeHTML($("NickName").value.trim()),
						Sign: encodeHTML($("Sign").value.trim()),
						IconId: parseInt(encodeHTML($("FaceSelect").value.trim())),
						Email: encodeHTML($("Email").value.trim())
						}
				}
				_Me.SysMessage.ShowMsg("正在保存信息","10000",true);
				 var SaveMsg=obj2str(ObjData);
				_Me.im.SendData(".User Sav "+SaveMsg);
                _Me.Parse.userInfo.IcoId = encodeHTML($("FaceSelect").value);
                _Me.Parse.userInfo.NickName = encodeHTML($("NickName").value);
                _Me.Parse.userInfo.Sign = encodeHTML($("Sign").value);
                _Me.Parse.userInfo.Country = encodeHTML($("Country").value.trim());
                _Me.Parse.userInfo.Age = encodeHTML($("age").value);
                _Me.Parse.userInfo.Sex = encodeHTML(SexValue);
                _Me.Parse.userInfo.Address = encodeHTML($("Address").value);
                _Me.Parse.userInfo.Comment = encodeHTML($("Comment").value);
                _Me.Parse.userInfo.Job = encodeHTML($("Job").value);
                _Me.Parse.userInfo.IcoId = encodeHTML($("FaceSelect").value);
                _Me.Parse.userInfo.Email = encodeHTML($("Email").value);
                _Me.Parse.userInfo.WebSite = encodeHTML($("WebSite").value);
                _Me.CMD.renderMyUserInfo();
                w.Close();
                 }
                $("CloseButton").onclick = function(){
                        w.Close();
                }
                }
                w.CloseCallback = function(){
                    var wWin = _Me.Win;
                    var winFaceselect = WinManage.GetWindow("myinfo_faceSelect", 3);
                    if (winFaceselect)
                    {
                        winFaceselect.win.Close();
                    }
                }
                w.Show();
                w.Focus();
            }
        },
        showFaceWindow: function(){
            var wWin = _Me.Win;
            var winMyinfo = WinManage.GetWindow("myinfo_faceSelect", 3);
            
            if (winMyinfo)
            {
                if (winMyinfo.isMin) {
                    winMyinfo.win.Minimize();
                }
                winMyinfo.win.Focus();
            }
            else {
                var w = new WebForm();
                w.Title = "选择头像";
                w.Icon = "nothing.gif";
                w.Type = 3;
                w.UserID = "myinfo_faceSelect";
                w.Height = 300;
                w.Width = 300;
                w.Resizeable = 0;
                var lastChatWin = WinManage.GetLastWindow(1);
                if (!lastChatWin) {
                    w.Left = wWin.win.Left < 425 ? wWin.win.Left + wWin.win.Width + 2 : wWin.win.Left - 422;
                    w.Top = wWin.win.Top;
                }
                else {
                    w.Left = lastChatWin.win.Left + 15;
                    w.Top = lastChatWin.win.Top + 15;
                }
                w.ContentUrl = "Layout/winFaceSelect.html";
                w.LoadedCallback = function(){
                    var faceHTML = "";
                    for (var i = 1; i < 49; i++) {
                        faceHTML += "<img id='cface_" + i + "' src='Images/UserFace/online/" + i + ".jpg' style=\"margin-left:3px; padding-left:3px; margin-top:3px;cursor:pointer;\" border='1'>";
                    }
                    $("FaceSELECTDIV").innerHTML = faceHTML;
                    for (var i = 1; i < 49; i++) {
                        $("cface_" + i).onclick = function(){
                            selectFace(this.id);
                        }
                        
                    }
                    function selectFace(faceName){
                        faceName = faceName.replace("cface_", "");
                        
                        if (!$("FaceSelect")) {
                            w.Close;
                        }
                        $("FaceSelect").value = faceName;
                        $("UserFace").src = _Me.CMD.passFaceByFacenum($("FaceSelect").value);
                        w.Close();
                        
                    }
                }
                
                w.Show();
                w.Focus();
            }
        },
        clearHistory: function(uid){
            if (!uid) {
                return;
            }
            _Me.Msgs.delMsgByuid(uid);
            var objChat = $("wChatViewId" + uid + "Type1");
            objChat.innerHTML = "";
        },
        chageComment: function(uid){
            uid = uid.replace("user_", "");
            _Me.Common.showPrompt(ReturnHtml(_Me.Parse.GetUserCommentByUid(uid)), "[" + _Me.Parse.GetUserNameByUid(uid)+ "]的备注名称", function(o, t, v, b){
                if (v != "") {
					_Me.Data.ChangeUserCommentName(uid,v);
                    _Me.Parse.SetUserComment(uid, v);
                    UserView.chageCommentData(uid, v);
                }
                if (v == "") {
					_Me.Data.ChangeUserCommentName(uid,_Me.Parse.GetUserNameByUid(uid));
                    _Me.Parse.SetUserComment(uid, _Me.Parse.GetUserNameByUid(uid));
                    UserView.chageCommentData(uid, _Me.Parse.GetUserNameByUid(uid));
                }
            });
            
        },
		GetObjValue:function(Obj,Ag)
		{
			eval("var Value=Obj."+Ag);
			if (typeof(Value)=="undefined"||!Value)
			{
				return "";
			}
			return Value;
		},
        showUserCard: function(Obj){
			_Me.SysMessage.ClearMsg();
            var Country =_Me.CMD.GetObjValue(Obj.Data.Result,'Country');
            var Age = _Me.CMD.GetObjValue(Obj.Data.Result,'Age');
            var Sex = _Me.CMD.GetObjValue(Obj.Data.Result,'Sex');
            var NickName =_Me.CMD.GetObjValue(Obj.Data.Result,'Nickname');
            var Sign =_Me.CMD.GetObjValue(Obj.Data.Result,'Sign');
            var Address = _Me.CMD.GetObjValue(Obj.Data.Result,'City');
            var Comment = _Me.CMD.GetObjValue(Obj.Data.Result,'Comment');
            var Job =_Me.CMD.GetObjValue(Obj.Data.Result,'Job');
            var IcoId =_Me.CMD.GetObjValue(Obj.Data.Result,'IconId');
            var Email =_Me.CMD.GetObjValue(Obj.Data.Result,'Email');
            var WebSite = _Me.CMD.GetObjValue(Obj.Data.Result,'WebSite');
            var GUID = Obj.Data.Uin;
			
            var wWin = _Me.Win;
            var winMyinfo = WinManage.GetWindow("userCard", 3);
            if (winMyinfo)
            {
                if (winMyinfo.isMin) {
                    winMyinfo.win.Minimize();
                }
                winMyinfo.win.Focus();
            }
            else {
                var w = new WebForm();
                w.Title = "用户资料";
                w.Icon = "DefaultIcon.gif";
                w.Type = 3;
                w.UserID = "userCard";
                w.Height = 450;
                w.Width = 500;
                w.Resizeable = 0;
                var lastChatWin = WinManage.GetLastWindow(1);
                if (!lastChatWin) {
                    w.Left = wWin.win.Left < 425 ? wWin.win.Left + wWin.win.Width + 2 : wWin.win.Left - 422;
                    w.Top = wWin.win.Top;
                }
                else {
                    w.Left = lastChatWin.win.Left + 15;
                    w.Top = lastChatWin.win.Top + 15;
                }
                w.ContentUrl = "Layout/userInfo.html";
                w.LoadedCallback = function(){
                    if (Sex == 1) {
                        Sex = "男";
                    }
                    else {
                        Sex = "女";
                    }
                    $("UserFace").src = _Me.CMD.passFaceByFacenum(IcoId);
                    $("NickName").innerHTML = NickName;
                    $("Sex").innerHTML = Sex;
                    $("age").innerHTML = Age;
                    $("Job").innerHTML = Job;
                    $("Country").innerHTML = Country;
                    $("Address").innerHTML = Address;
                    $("Sign").innerHTML = Sign;
                    $("Email").innerHTML = Email;
                    $("WebSite").innerHTML = WebSite;
                    $("Comment").innerHTML = Comment;
                }
                w.Show();
                w.Focus();
            }
        },
		ShowFriendRequestWin:function(FromUin,GroupName,Message,Obj)
		{
	        var RequestUin = FromUin;
	        var RequestClass =GroupName;
	        var RequestInfo = Message;
	        if (RequestInfo == "") {
	            RequestInfo = UrlEncode("未填写");
	        }
	        var wWin = _Me.Win;
	        var Confirm = WinManage.GetWindow("Confirm_" + RequestUin, 3);
        
	        if (Confirm)
	        {
	            if (Confirm.isMin) {
	                Confirm.win.Minimize();
	            }
	            Confirm.win.Focus();
	        }
	        else {
	            var w = new WebForm();
	            w.Title = "好友申请";
	            w.Icon = "ToolAddFriend.gif";
	            w.Type = 3;
	            w.UserID = "Confirm_" + RequestUin;
	            w.Height = 250;
	            w.Width = 300;
	            w.Resizeable = 0;
	            var lastChatWin = WinManage.GetLastWindow(1);
	            if (!lastChatWin) {
	                w.Left = wWin.win.Left < 425 ? wWin.win.Left + wWin.win.Width + 2 : wWin.win.Left - 422;
	                w.Top = wWin.win.Top;
	            }
	            else {
	                w.Left = lastChatWin.win.Left + 15;
	                w.Top = lastChatWin.win.Top + 15;
	            }
	            w.ContentUrl = "Layout/FriendConfirm.html";
	            w.LoadedCallback = function(){
	                $("RequestUid").innerHTML = RequestUin+"          查看资料";
	                $("RequestUid").onclick = function(){
	                     UserView.parent.CMD.ViewUserInfo(RequestUin);
	                    _Me.netWork.addOneCheck("GetBuddyInfo", 5, "获取用户信息时,发生网络超时", 0, null);
	                }
	                if (RequestInfo == String.fromCharCode(0)) {
	                    $("AUTOADD").checked = false;
	                    $("AUTOADD_DIV").style.display = "none";
						RequestInfo="对方已经通过了你的请求,并且请求加你为好友,请选择是否通过!"
	                }
					 $("message").value =RequestInfo
	                $("AccpButton").onclick = function(){
					    var ObjData={Action:"Response",From:Obj.From,To:Obj.To,GroupName:RequestClass,Accept:true,Message:" "};
						var SendData=obj2str(ObjData);
	                    _Me.im.SendData(".Buddy Add "+SendData);
	                    if ($("AUTOADD").checked) {
							var ObjData={Action:"Request",From:_Me.Parse.uid,To:RequestUin,GroupName:_Me.Parse.Groups[0],Message:"对方通过了你的申请,并且请求加您为好友"};
	                        var SendData=obj2str(ObjData);
							_Me.im.SendData(".Buddy Add "+SendData)
	                    }
	                    w.Close();
	                }
	                $("DisButton").onclick = function(){
	                    var dismessage = $("DisMessage").value;
						var ObjData={Action:"Response",From:_Me.Parse.uid,To:RequestUin,GroupName:RequestClass,Accept:false,Message:dismessage};
						var SendData=obj2str(ObjData);
	                    _Me.im.SendData(".Buddy Add "+SendData);
	                    w.Close();
	                }
	            }
	            w.Show();
	            w.Focus();
	        }
		},
        deleteUser: function(uid){
            uid = uid.replace("user_", " ").trim();
            DelUserName = _Me.Parse.GetUserNameByUid(uid);
            _Me.Common.showConfirm("确定要删除[" + DelUserName + "]么?", "删除用户", function(id, t, v){
                if (v) {
					_Me.SysMessage.ShowMsg("正在删除好友","5000",false)
					_Me.Data.DelUser(uid);
                }
            })
        },
        ScroolMsgBody: function(uid){
			window.setTimeout(function(){
				            var objChat = $("wChatViewId" + uid + "Type1");
            if (objChat) {
                objChat.scrollTop = 1000000;
            }
			},100)
        },
        GetMsgBox: function(Uid){
            msgs = _Me.Msgs.getMsgByuid(Uid);
            for (var is = 0; is < msgs.length; is++) {
                SayUid =msgs[is].SayUin;
                if (SayUid == _Me.Parse.uid) {
                    color = "#008040";
                }
                else {
                    color = "blue";
                }
                MsgData = msgs[is].Time;
                MsgBody =msgs[is].Msg;
                var Uname = _Me.Parse.GetUserCommentByUid(SayUid);
                showMsgs = "<br>&nbsp;<font color='" + color + "'><strong>" + Uname + "&nbsp;说:&nbsp;&nbsp;" + MsgData + "</strong></font><br>" + MsgBody;
                _Me.CMD.showChatContent(Uid, showMsgs);
            }
        },
        delGroup: function(gid){
            gid = gid.replace("UserViewGroup_", "");
            if (gid == 0 || gid == _Me.Parse.Groups.length - 1) {
                alert('不能删除默认分组');
                return;
            }
			if (_Me.Parse.Gusers[gid].length>0)
			{
				alert('该组好友不为空,不能删除!');
				return;
			}
            _Me.Common.showConfirm("确定删除[" + _Me.Parse.Groups[gid] + "]?", "删除分组", function(o, id, v){
                if (v == true) {
					_Me.SysMessage.ShowMsg("正在删除分组","5000",false)
					_Me.Data.DelGroup(gid);
                }
            })
        },
        ViewUserInfo: function(uid){
			if (uid.replace) {
				var uid = uid.replace("user_", "");
			}
			else
			{
				var uid=uid
			}
            _Me.netWork.addOneCheck("GetBuddyInfo", 5, "获取用户信息时,发生网络超时", 0, null);
			_Me.SysMessage.ShowMsg("正在获取好友的信息","3000",false)
			var ObjData={Action:"One",Uin:uid};
			var SendData=obj2str(ObjData);
            _Me.im.SendData(".Buddy Get " + SendData);
        },
        eidtUserGroup: function(uid){
            var u = _Me.Common.getUserFromArr(uid, _Me.Friend);
            if (!u) 
                return;
            _Me.Common.showSelect("请选择分组", function(id, t){
                var oSel = $("divSelectId" + id + "Type" + t);
                for (var i = 0; i < _Me.Group.length; i++) {
                    var g = _Me.Group[i];
                    var opt = Elem.New("option");
                    opt.value = g.ID;
                    opt.text = g.Name;
                    oSel.options.add(opt);
                }
                Elem.Value(oSel, u.GroupID);
            }, function(){
                var gid = arguments[2];
                if (gid == "" || gid == u.GroupID) 
                    return;
                _Me.Data.editUserGroup(uid, gid);
                u.GroupID = gid;
                _Me.CMD.renderMyFriend(null, null, !0);
            });
        },
        showRegWindow: function(){
            var wLogin = WinManage.GetWindow(6, 3);
            if (wLogin != null) {
				//wLogin.win.Minimize();
			}
            _Me.Common.showLink(800, 600, 50, 10, 7, "注册新帐号", "http://sjq.sjoem.com/sign_up.aspx", null, function(){
                if (wLogin.isMin) {
				// wLogin.win.Minimize();
				}
            });
        },
        showForgotPasswordWindow: function(){
            var wLogin = WinManage.GetWindow(6, 3);
            if (wLogin != null) {
				//wLogin.win.Minimize();
			}
            _Me.Common.showLink(800, 600, 50, 10, 7, "找回密码", "http://sjq.sjoem.com/forgot_password.aspx", null, function(){
                if (wLogin.isMin) {
					//wLogin.win.Minimize();
				}
            });
        },
        intLoginWindow: function(){
            var wMain = WinManage.GetWindow(0, 2);
            if (wMain) {
                if (wMain.isMin) 
                    wMain.win.Minimize();
                wMain.win.Focus();
                return;
            }
            var wLogin = WinManage.GetWindow(6, 3);
            if (wLogin) {
                if (wLogin.isMin) 
                    wLogin.win.Minimize();
                wLogin.win.Focus();
                return;
            }
            var w = new WebForm();
            w.Title = "Web手机Q 1.0";
            w.Icon = "nothing.gif";
            w.Type = 3;
            w.UserID = 6;
            w.Height = 516;
            w.Width = 214;
			w.Left = 68;
            w.Top = 90;
            w.ContentUrl = "layout/winlogin.htm";
			w.CanControl=!!0;
            w.Resizeable = !!0;
            w.RepaintMethod = function(w, h, id, t){
                $("wOtherMainId" + id + "Type" + t).style.height = h + "px";
            };
            w.LoadedCallback = function(id, t)
			{

                $("divStatusId6Type3").onclick = function(e){
                    var m = new SysMenu("menuLoginStatus6Type3");
                    m.Data = ["联机|WebIndex.WebIm.CMD.changeLoginStatus(1)|images/m0.gif", "隐身|WebIndex.WebIm.CMD.changeLoginStatus(2)|images/m1.gif"];
                    m.E = e;
                    m.HasIcon = true;
                    m.Width = 120;
                    m.Show();
                };
                Elem.Value("tbEmailId6Type3", Other.GetCookie("stremail"));
                Elem.Value("tbPassId6Type3", Other.GetCookie("strpass"));
                $("cbSaveUserId6Type3").checked = Other.GetCookie("saveemail") == "1";
                $("cbSavePassId6Type3").checked = Other.GetCookie("savepass") == "1";
                $("cbAutoLoginId6Type3").checked = Other.GetCookie("autologin") == "1";
                if (Other.GetCookie("loginstatus").trim() != ""&&WebIndex.WebIm) {
					WebIndex.WebIm.CMD.changeLoginStatus(1);
				}
                new CheckBox("cbSaveUserId6Type3", "保存我的信息(B)").Render();
                new CheckBox("cbSavePassId6Type3", "记住我的密码(R)").Render();
                new CheckBox("cbAutoLoginId6Type3", "自动为我登陆(N)").Render();
                $("tbPassId6Type3").onkeydown = function(e){
                    var e = e || event;
                    if (e.keyCode == 13)
                    {
                        _Me.CMD.loginWebIM.df();
                    }
                }
                $("btnLoginId6Type3").onclick = _Me.CMD.loginWebIM.df;
                $("linkDelCookieId6Type3").onclick = function(){
                    Other.SetCookie("stremail", "");
                    Other.SetCookie("strpass", "");
                    Other.SetCookie("saveemail", "2");
                    Other.SetCookie("savepass", "2");
                    Other.SetCookie("autologin", "2");
                    Other.SetCookie("loginstatus", "1");
                    _Me.CMD.destroyMainWindow();
					WebIndex.WebIm.PSW.LocationReload=1;
					window.location.reload();
                };
                if (Other.GetCookie("autologin") == "1") {
                    _Me.CMD.loginWebIM.df();
                }
            };
            w.CloseCallback = _Me.CMD.destroyMainWindow;
            w.Show();
            w.Focus();
			if (_Me.AutoLogin.GetLoginType() == true) {
				_Me.SysMessage.ShowMsg("连接服务器中.....",5000,true);
				Elem.Hid("winOther6");
			}
        },
        loginWebIM: {
            df: function(){
                var w = WinManage.GetWindow(6, 3).win;
                var user = $F("tbEmailId6Type3").trim();
                var pass = $F("tbPassId6Type3").trim();
                if (user == "") {
                    _Me.Common.showAlert("请输入你的账号!", "提示", function(){
                        w.Focus();
                        $("tbEmailId6Type3").focus();
                    });
                    return;
                }
                if (pass == "") {
                    _Me.Common.showAlert("请输入你的密码!", "提示", function(){
                        w.Focus();
                        $("tbPassId6Type3").focus();
                    });
                    return;
                }   
				$("btnLoginId6Type3").disabled = "disabled";
                Elem.Toggle("divLoginId6Type3", "divLoginingId6Type3");
				Elem.Toggle("USERNAMEDIV");
		        Elem.Toggle("PASSWORDDIV");
				Elem.Toggle("btnLoginId6Type3");
				
				 var us = $("divStatusId6Type3").getAttribute("us");
                _Me.Data.setUserLogin(user, pass, us, null);
            },
            DataPass: function(o){
                var w = WinManage.GetWindow(6, 3).win;
                var us = $("divStatusId6Type3").getAttribute("us");
                var user = $F("tbEmailId6Type3").trim();
                _Me.Parse.uid = user.trim();
                var pass = $F("tbPassId6Type3").trim();
                if (o == 1) {
                    Other.SetCookie("stremail", $("cbSaveUserId6Type3").checked ? user : "");
                    Other.SetCookie("strpass", $("cbSavePassId6Type3").checked ? pass : "");
                    Other.SetCookie("saveemail", $("cbSaveUserId6Type3").checked ? "1" : "2");
                    Other.SetCookie("savepass", $("cbSavePassId6Type3").checked ? "1" : "2");
                    Other.SetCookie("autologin", $("cbAutoLoginId6Type3").checked ? "1" : "2");
                    Other.SetCookie("loginstatus", us);
                    if (us == 0) {
                        us = 1;
                    }
                    _Me.Parse.userStauts = us;
                    w.Close();
					_Me.SysMessage.ShowMsg("初始化主窗口","3000",false)
                    _Me.CMD.intMainWindow(w.Top, w.Left);
                }
                else {
					w.Focus();
					if (_Me.PSW.imCoreType == "Flash") {
						window.alert("登陆失败,原因如下:" + o + "!", "提示");
					}
					else
					{
						_Me.Common.showAlert("登陆失败,原因如下:" + o + "!", "提示");
					}
                    Elem.Toggle("divLoginId6Type3", "divLoginingId6Type3");
					Elem.Toggle("USERNAMEDIV");
		            Elem.Toggle("PASSWORDDIV");
					Elem.Toggle("btnLoginId6Type3");
                    $("btnLoginId6Type3").disabled = "";
					if (_Me.PSW.imCoreType=="Flash")
					{
						WebIndex.WebIm.PSW.LocationReload=1;
						window.location.reload()
					}
					if (typeof( _Me.im.Disconnect)=="function")
					{
						_Me.im.Disconnect();
					}
                    _Me.im = null;
                    return;
                }
            }
        },
        intMainWindow: function(top, left){
            document.title = "WEB 手机Q  " + _Me.Parse.userInfo.NickName;
            var w = new WebForm();
            w.Title = "<span style='color:#000'>" + _Me.Parse.uid + " 手机Q</span>";
            w.Icon = "nothing.gif";
            w.Type = 2;
            w.Height = 520;
            w.Width = 210;
            w.Top = top || null;
            w.Left = left || 260;
            w.MinHeight = 250;
            w.RepaintMethod = function(w, h, id, t){
				_Me.MainHeigth=h;
                $("wMainMainId" + id + "Type" + t).style.height = (h - 199) + "px";
                $("wMainUserInfoRightId" + id + "Type" + t).style.width = (w - 82) + "px";
                $("txtUserSignId" + id + "Type" + t).style.width = (w - 85) + "px";
            };
            w.ClosingCallback = function(){
                _Me.Common.showConfirm("真的要退出？", "提示", function(){
                    if (arguments[2]) {
                        _Me.CMD.closeImCore();
						  w.ClosingCallback=null;
                        _Me.Win.win.Close();
                    }
                });
            };
            w.CloseCallback = function(){
                _Me.CMD.destroyMainWindow();
            };
            w.LoadedCallback = function(id, t){
				WebIndex.WebIm.PSW.LocationReload=0;
				_Me.SysMessage.ClearMsg();
                document.body.onkeydown = function(e){
                    _Me.CMD.PassKey(e);
                }
                window.onkeydown = function(e){
                    _Me.CMD.PassKey(e);
                }
                w.ShowLoading();
                _Me.Win = WinManage.GetWindow(id, t);
                _Me.CMD.renderMyUserInfo();
                _Me.Data.getMiniWebUrl();
                _Me.Data.getMyFriendList();
				_Me.SysMessage.ShowMsg("获取好友信息......","30000",false)
							
				if (_Me.PSW.isAutoLogin == 1) {
					 _Me.CMD.CheckTransmitChatUin();
					 _Me.SysMessage.ShowMsg("打开聊天窗口","3000",false)
					_Me.CMD.openChatWindow(_Me.AutoLogin.ChatId, 1);
					
				}
                $("wMainUserNameId" + id + "Type" + t).parentNode.onclick = function(e)
                {
                    var m = new SysMenu("menuUserNameId" + id + "Type" + t);
                    m.Data = ["联机|WebIndex.WebIm.CMD.changeUserStatus(1)|images/state1.gif", "隐身|WebIndex.WebIm.CMD.changeUserStatus(2)|images/state2.gif", "", "注销|WebIndex.WebIm.CMD.logoutWebIM()|images/state3.gif"];
                    m.E = e;
                    m.HasIcon = true;
                    m.Width = 120;
                    m.Top = w.Top + 59;
                    m.Left = w.Left + 80;
                    m.Show();
                };
				$("inputSearchId" + id + "Type" + t).onkeyup = function(e)
                {
					var e = e || event;
					if (e.keyCode==13)
					{
						_Me.UserViewSeachHelper.OpenFocusObj();
						return;
					}
                    if  (e.keyCode==40||e.keyCode==38)
					{
						_Me.CMD.PassUserViewDivFocus(e.keyCode);
						return;
					}
					var Value=$("inputSearchId" + id + "Type" + t).value;
					if (Value=="")
					{
						_Me.CMD.ClearUserViewDiv();
						_Me.CMD.HiddenUserViewDiv();
					}
					if (Value!="")
                    {
						var SeachInputObj=$("inputSearchId" + id + "Type" + t);
                        _Me.CMD.SeachFriend(SeachInputObj.value);
                    }
                };
				$("inputSearchId" + id + "Type" + t).onclick = function(e)
                {
					var Value=$("inputSearchId" + id + "Type" + t).value;
					if (Value!="")
                    {
						var SeachInputObj=$("inputSearchId" + id + "Type" + t);
                        _Me.CMD.SeachFriend(SeachInputObj.value);
                    }
                };
                $("wMainAddFriendId" + id + "Type" + t).onclick = function()
                {
                    _Me.CMD.addFirend();
                };
				//$("inputSearchId" + id + "Type" + t).onblur=function()
				//{
					//_Me.CMD.HiddenUserViewDiv()
				//}
                $("wMainShowFocusId" + id + "Type" + t).onclick = function()
                {
                    if (_Me.Parse.MiniWebUrl != null) {
                        _Me.Common.showLink(590, 450, w.Top, w.Left < 405 ? w.Left + w.Width + 2 : w.Left - 402, 2, "今日焦点", _Me.Parse.MiniWebUrl, "toolshowfocus.gif");
                    }
                    else {
                        alert('迷你网页地址尚未加载.')
                    }
                };
                $("wMainUserFaceId" + id + "Type" + t).onclick = function()
                {
                    _Me.CMD.editMyinfo();
                }
                $("wMainManageId" + id + "Type" + t).onclick = function(){
                    _Me.CMD.editOption();
                }
                if (!$("divFaceList"))
                {
                    var oDiv = Elem.New("div", "divFaceList", "wChatFaceContainer");
                    var faces = [];
                    faces = _Me.Data.getMsnFaceInfo();
                    for (var i = 0; i < faces.length; i++) {
                        var face = faces[i];
                        var oItem = Elem.New("div", "", "wChatFaceItem", "<img f='" + face[2] + "' src='msnface/" + face[0] + ".gif' title='" + face[1] + " " + face[2] + "'/>");
                        oItem.onmouseover = function(){
                            this.className = "wChatFaceItem wChatFaceItemHover";
                        };
                        oItem.onmouseout = function(){
                            this.className = "wChatFaceItem";
                        };
                        oItem.onclick = function(){
                            var chatid = parseInt(window.cWindow.replace("winChat", ""));
                            if (!chatid) 
                                return;
                            Elem.Append("wChatInputId" + chatid + "Type1", $T(this, "img")[0].getAttribute("f"));
                            var Uid = chatid;
                            if ($("wChatInputId" + Uid + "Type1") != null) {
                                $("wChatInputId" + Uid + "Type1").focus();
                            }
                            Elem.Hid("divFaceList");
                        };
                        Elem.Add(oDiv, oItem);
                    }
                    Elem.Add("windowContainer", oDiv);
                }
                
                w.HideLoading();
            }
            w.Show();
			if (_Me.PSW.isAutoLogin==1)
			{
				Elem.Hid("winMain0");
			}
        },
        logoutWebIM: function(){
            Other.SetCookie("autologin", "2");
            _Me.Data.setUserLogout();
            _Me.Win.win.ClosingCallback = null;
            _Me.Win.win.RepaintMethod = null;
            _Me.Win.win.ClosingCallback = null;
            _Me.Win.win.CloseCallback = null; 
            _Me.Win.win.LoadedCallback = null;
            _Me.Win.win.Close();
        },
        renderMyUserInfo: function(){
            var id = _Me.Win.id;
            var t = _Me.Win.type;
            $("wMainUserFaceId" + id + "Type" + t).src = _Me.CMD.passFaceByFacenum(_Me.Parse.userInfo.IcoId);
            $("wMainUserNameId" + id + "Type" + t).innerHTML = _Me.Parse.userInfo.NickName + " <span style=\"font-size:12px;color:#000000\">(" + _Me.Common.getUserStatusStr(_Me.Parse.userStauts) + ")</span>";
            $("wMainUserSignId" + id + "Type" + t).innerHTML = _Me.Parse.userInfo.Sign;
            $("wMainUserSignId" + id + "Type" + t).title = _Me.Parse.userInfo.Sign
        },
        passFaceByFacenum: function(Num){
            Rooturl = "UserFace/online/";
            if (!Num || Num < 1 || Num > 48) {
                return Rooturl + "def.jpg";
            }
            else {
                return Rooturl + Num + ".jpg";
            }
        },
		passOflFaceByFacenum: function(Num){
            Rooturl = "UserFace/offline/";
            if (!Num || Num < 1 || Num > 48) {
                return Rooturl + "def.jpg";
            }
            else {
                return Rooturl + Num + ".jpg";
            }
        },
        passFaceByUid: function(uid){
            var UserInfo = _Me.Parse.Gusers;
            for (var i = 0; i <  _Me.Parse.Gusers.length; i++) {
                for (var ii = 0; ii < _Me.Parse.Gusers[i].length; ii++) {
					var NowUin = _Me.Parse.Gusers[i][ii].Uin
					if (parseInt(NowUin) == parseInt(uid)) {
						return _Me.CMD.passFaceByFacenum(_Me.Parse.Gusers[i][ii].IconId)
					}
				}
            }
            return "";
        },
		OpenHistoryWin:function()
		{
			var HistoryWinList=_Me.HistoryWin.GetHistoryWin();
			for (var i=0;i<HistoryWinList.length;i++)
			{
				var UserId=HistoryWinList[i];
				if (UserId!="")
				{
				_Me.CMD.openChatWindow(UserId,true);
				}
			}
		},
        changeUserStatus: function(n){
            _Me.Data.changeUserstauts(n);
            _Me.Parse.userStauts = n;
            _Me.CMD.renderMyUserInfo();
        },
        changeLoginStatus: function(n){
            $("divStatusId6Type3").innerHTML = _Me.Common.getUserStatusStr(n);
            $("divStatusId6Type3").setAttribute("us", n);
        },
        destroyMainWindow: function(){
            clearInterval(WinManage.WinListInteralID);
            for (var f = 0; f < WinManage.WindowsList.length; f++) {
                var w = WinManage.WindowsList[f];
                Elem.Del(WinManage.GetObjByWindow(w));
            }
            WinManage.WindowsList.clear();
            Elem.Del("windowContainerBorder");
            window.onscroll = window.onresize = null;
        },
        renderMyFriend: function(){
            var id = _Me.Win.id;
            var t = _Me.Win.type;
            var searchKey = $F("inputSearchId" + id + "Type" + t);
            var obj = $("wMainMainId" + id + "Type" + t);
            UserView.parent = _Me;
            UserView.Data = _Me.Parse;
            UserView.Main = obj;
            UserView.Show();
			_Me.CMD.OnReadFriend()
			_Me.im.SendData(".Buddy Ofl");
		},
        showChatContent: function(uid, msg){
            var objChat = $("wChatViewId" + uid + "Type1");
            msg = _Me.Common.replaceFaceFromStr(msg)
			if (objChat != null) {
				objChat.innerHTML += msg;
			}
        },
        sendMessage: function(uid){
            var objContent = $("wChatInputId" + uid + "Type1");
            var msg = "";
            if ($F(objContent).trim() == "") {
                msg = "不能发送空消息!";
            }
            if ($F(objContent).trim().CountFormStr() > 1000) {
                msg = "你发送的消息太长(超过500)!";
            }
            if (_Me.PSW.msgIng != 0) {
                msg = "不能发的太快."
            }
            if (msg != "") {
                _Me.Common.showAlert(msg, "提示", function(){
                    objContent.focus();
                });
                return;
            }
            webMsgBody = $F(objContent)
			webMsgBody = encodeHTML(webMsgBody)
			webMsgBody = webMsgBody.replaceAll("\n", "<br>");
			webMsgBody=_Me.Common.passImgLink(webMsgBody)
			webMsgBody =_Me.Common.replaceFaceFromInputStr(webMsgBody);
            webMsgBody = "<div>"+webMsgBody+"</div>";
            mydatas = new myData;
			ShowMsgBody=encodeHTML($F(objContent));
			ShowMsgBody=ShowMsgBody.replaceAll("\n", "<br>&nbsp;");
            showMsg = "<br>&nbsp;<font color=\#008040\><strong>" + _Me.Parse.userInfo.NickName + "&nbsp;说:&nbsp;&nbsp;" + mydatas.GetAll() + "</strong></font><br>&nbsp;" + ShowMsgBody;
			showMsg =_Me.Common.passImgLink(showMsg);
			showMsg =_Me.Common.replaceFaceFromInputStr(showMsg)
			var Inmsg=$F(objContent).replaceAll("\n", "<br>&nbsp;&nbsp;");
			Inmsg=_Me.Common.passImgLink(Inmsg)
			Inmsg=_Me.Common.replaceFaceFromInputStr(Inmsg)
            _Me.Msgs.inMsg(uid,_Me.Parse.uid,Inmsg,mydatas.GetAll());
            WebIndex.WebIm.CMD.showChatContent(uid, showMsg);
            _Me.CMD.ScroolMsgBody(uid);
		    var DataObj={To:parseInt(uid),Msg:webMsgBody};
            _Me.im.SendData(".Buddy Msg "+obj2str(DataObj));
            _Me.PSW.msgIng = 1;
            var Msging = setTimeout(function(){
                _Me.PSW.msgIng = 0;
            }, 600)
            objContent.focus();
            Elem.Value(objContent);
        },
        showFaceList: function(id, e){
            Elem.Show("divFaceList");
            var wChat = WinManage.GetWindow(id, 1);
            var os = $("divFaceList").style;
            os.top = (wChat.win.Top + wChat.win.Height - 344 - parseInt($("wChatInputId" + id + "Type1").style.height)) + "px";
            os.left = (wChat.win.Left + 9) + "px";
            os.width = "315px";
            os.height = "285px";
            document.onmousedown = function(e){
                var ex = Evt.Left(e);
                var ey = Evt.Top(e);
                if (!(ex > parseInt(os.left) && ex < parseInt(os.left) + parseInt(os.width) + 2 && ey > parseInt(os.top) && ey < parseInt(os.top) + parseInt(os.height) + 2)) {
                    Elem.Hid("divFaceList");
                    document.onmousedown = null;
                }
            };
        },
        openChatWindow: function(uid, isfocus){
            UserView.flashViewDel(uid);
            var winChat = WinManage.GetWindow(uid, 1);
            var wWin = _Me.Win;
            if (winChat)
            {
                if (winChat.isMin) 
				{
                    winChat.win.Minimize();
                }
                winChat.win.Focus();
            }
            else
            {
                var w = new WebForm();
                _Me.Parse.GetUserClientByUid(uid)
				if (_Me.PSW.isAutoLogin != 1) {
					w.Title = _Me.Parse.GetUserCommentByUid(uid) +"("+uid+")";
				}
				else
				{
					w.Title ="与"+uid +" 聊天中--你当前使用的是临时会话功能，您下线后，消息可能无法回复到您！";
				}
				w.Icon = "DefaultIcon.gif";
                w.Type = 1;
                w.UserID = uid;
                w.Height = 520;
                w.Width = 480;
				if (_Me.PSW.isAutoLogin==1)
				{
					w.Height =520;
					w.Width = 480;
				}
                w.MinWidth = 330;
                w.MinHeight = 350;
                var lastChatWin = WinManage.GetLastWindow(1);
                if (!lastChatWin) {
                    w.Left = wWin.win.Left < 425 ? wWin.win.Left + wWin.win.Width + 2 : wWin.win.Left - 422;
                    w.Top = wWin.win.Top;
                }
                else {
                    w.Left = lastChatWin.win.Left + 15;
                    w.Top = lastChatWin.win.Top + 15;
                }
				if (_Me.PSW.isAutoLogin==1)
				{
					w.Left=Elem.Width()/2-250;
					w.Top=80;
				}
                w.RepaintMethod = function(w, h, id, t){
                    $("wChatMainId" + id + "Type" + t).style.height = (h - 68) + "px";
                    $("wChatSideId" + id + "Type" + t).style.height = (h - 60) + "px";
                    $("wChatSideBarId" + id + "Type" + t).style.height = (h - 70) + "px";
					_Me.Config.ChatSide==1?Elem.Show($("wChatSideId"+id+"Type"+t)):Elem.Hid($("wChatSideId"+id+"Type"+t));
					$("wChatMainId"+id+"Type"+t).style.width = _Me.Config.ChatSide==1?(w-205)+"px":(w-20)+"px";
					$("wChatResizeBarId"+id+"Type"+t).style.width = _Me.Config.ChatSide==1?(w-205)+"px":(w-20)+"px";
					$("wChatInputId"+id+"Type"+t).style.width = _Me.Config.ChatSide==1?(w-210)+"px":(w-25)+"px";
                    $("wChatSignHolderId" + id + "Type" + t).style.width = (w - 60) + "px";
                    
                    var viewHeight = (h - parseInt($("wChatInputId" + id + "Type" + t).style.height) - 141);
                    if (viewHeight < 10) {
                        $("wChatInputId" + id + "Type" + t).style.height = (h - parseInt($("wChatViewId" + id + "Type" + t).style.height) - 141) + "px";
                    }
                    else {
                        $("wChatViewId" + id + "Type" + t).style.height = viewHeight - 18 + "px";
                    }
                };
                w.CloseCallback=function(id)
				{
					_Me.HistoryWin.DelOneWin(id);
				}
                w.LoadedCallback = function(id, t){
				var sideBtn = $T("wChatSideBarId"+id+"Type"+t,"img")[0];
						sideBtn.src=_Me.Config.ChatSide==1?"images/chatsidebutton.gif":"images/chatsidebutton1.gif";
						sideBtn.title = _Me.Config.ChatSide==1?"隐藏名片侧边":"显示名片侧边栏";
						sideBtn.onclick = function()
						{
							_Me.Config.ChatSide=_Me.Config.ChatSide==1?2:1;
							w.RepaintMethod(w.Width,w.Height-24,w.UserID,w.Type);
							this.src=_Me.Config.ChatSide==1?"images/chatsidebutton.gif":"images/chatsidebutton1.gif";
							this.title = _Me.Config.ChatSide==1?"隐藏名片侧边":"显示名片侧边栏";
					};
					_Me.SysMessage.ClearMsg();
					$("winChatText"+id).onclick=function()
					{
						_Me.CMD.ViewUserInfo(id);
					}
					$("FriendCardFrame"+ id + "Type" + t).src="http://sjq.zjynet.com/card/view/?Uin="+uid+"&Color=C4E7F7&tmp="+_Me.Parse.userInfo.GUID;
					$("MeCardFrame"+ id + "Type" + t).src="http://sjq.zjynet.com/card/view/?Uin="+_Me.Parse.uid+"&Color=C4E7F7&tmp="+_Me.Parse.userInfo.GUID;
					if (_Me.AutoLogin != 1) {
						_Me.HistoryWin.AddNewWin(id);
					}
                    $("wChatSignId" + id + "Type" + t).innerHTML = _Me.Parse.GetUserSignByuid(uid);
                    _Me.CMD.GetMsgBox(uid);
                    $("wChatButtonHistoryId" + id + "Type" + t).onclick = function(){
                        _Me.CMD.clearHistory(uid);
                    }
					$("wChatButtonHistorySaveId" + id + "Type" + t).onclick = function(){
                        _Me.CMD.SaveHistory(uid);
                    }
					$("wChatFaceButtonNetImageId" + id + "Type" + t).onclick = function(){
						_Me.Common.showPrompt("http://","输入网络图片地址("+uid+")",function(o,t,v)
						{
							var Sure=false;
							if (v!="")
							{
								var Reg= RegExp(/http:\/\/(\S{1,1000})\.jpg/i)
								if (Reg.test(v))
								{
									Sure=true;
								}
								var Reg= RegExp(/http:\/\/(\S{1,1000})\.gif/i)
								if (Reg.test(v)) 
								{
									Sure = true;
								}
								if (Sure==true)
								{
									var ImageValue="[img]"+v+"[/img]";
									var InputObj=$("wChatInputId"+uid+"Type1");
									InputObj.value += ImageValue;
								}
								else
								{
									alert('输入的连接不是有效的gif，或者jpg图片');
								}
							}
							else
							{
								return;
							}
						})
					}
					
					$("wChatButtonCamera" + id + "Type" + t).onclick = function(){
						$("AlarmDiv"+id).style.display="";
						$("AlarmDiv"+id).className="alarm_1";
                    }
					$("wChatButtonMicphone" + id + "Type" + t).onclick = function(){
						$("AlarmDiv"+id).style.display="";
						$("AlarmDiv"+id).className="alarm_2";
                    }
					$("wChatButtonSendFile" + id + "Type" + t).onclick = function(){
						$("AlarmDiv"+id).style.display="";
						$("AlarmDiv"+id).className="alarm_3";
                    }
					
					if (_Me.PSW.isAutoLogin==1)
					{
						window.setTimeout(function(){
							_Me.SysMessage.ShowMsg("您当前使用的是手机Q临时聊天功能，如想使用更多好友及互动、视频等功能请<a href='http://sjq.sjoem.com/sign_up.aspx' target='_blank'>注册帐号</a>并<a href='http://im.zjynet.com' target='_blank'>登陆Web手机Q</a>，或者<a href='http://sjq.sjoem.com' target='_blank'>下载手机Q客户端软件</a>",3000,false);
						},10000)
					}
                    var Uid = uid;
					var input=$("wChatInputId" + Uid + "Type1");
                    if (input != null) {
						if (input.focus) {
							input.focus();
						}
                    }
                    $("wChatResizeId" + id + "Type" + t).onmousedown = function(){
                        var resizeBar = $("wChatResizeBarId" + id + "Type" + t);
                        var rs = resizeBar.style;
                        rs.top = (90 + parseInt($("wChatViewId" + id + "Type" + t).style.height)) + "px";
                        Elem.Show(resizeBar);
                        document.onmousemove = function(e){
                            var _top = parseInt(rs.top) + (Evt.Top(e) - (parseInt(rs.top) + w.Top + 5));
                            _top = _top < 140 ? 140 : _top;
                            _top = _top > w.Height - 100 ? w.Height - 100 : _top;
                            rs.top = _top + "px";
                        };
                        document.onmouseup = function(e){
                            $("wChatViewId" + id + "Type" + t).style.height = (parseInt(rs.top) - 90) + "px";
                            $("wChatInputId" + id + "Type" + t).style.height = (w.Height - parseInt(rs.top) - 75) + "px";
                            document.onmousemove = document.onmouseup = null;
                            Elem.Hid(resizeBar);
                        };
                    };
                    if (_Me.Parse.inFriend(uid) == true) {
                        if (_Me.Parse.GetUserStauts(uid) != 1 && _Me.Parse.passIshidden(uid) != true) {
                            _Me.CMD.closeSendMsg(uid);
                        }
                    }
                    else {
                        var objChat = $("wChatViewId" + uid + "Type1");
                        objChat.innerHTML = "&nbsp;对方为临时会话用户,对方下线后可能会无法回复到您<br>" + objChat.innerHTML;
                    }
                    $("wChatBtnCloseId" + id + "Type" + t).onclick = function(){
                        w.Close();
                        _Me.CMD.SendNoWriteMsg(uid);
                    }
                    $("wChatFaceButtonFlashId" + id + "Type" + t).onclick = function(){
                        var winChat = WinManage.GetWindow(uid, 1);
                        if (_Me.CMD.sendFlashWin(uid)) {
                            var Uid = uid;
                            if ($("wChatInputId" + Uid + "Type1") != null) {
                                $("wChatInputId" + Uid + "Type1").focus();
                            }
                            WinManage.FlashWindow(winChat);
                        }
                    }
                    $("wChatInputId" + id + "Type" + t).onblur = function(){
                        if (_Me.PSW.checkWrite(uid) == true) {
                            _Me.CMD.SendNoWriteMsg(uid);
                        }
                    }
                    $("wChatInputId" + id + "Type" + t).onkeydown = function(e){
                        var e = e || event;
                        if ($("wChatInputId" + id + "Type" + t).value.length > 1) {
                            _Me.CMD.SendWriteMsg(uid);
                        }
                        if (e.keyCode == 27) {
                            var objChat = $("winChat" + uid);
                            _Me.CMD.SendNoWriteMsg(uid);
                            w.Close();
                        }
                        if (e.keyCode == 13)
                        {
                            if (Other.GetCookie("MsgSendType") == "Enter")
                            {
                                if (!e.ctrlKey && !e.shiftKey)
                                {
                                    _Me.CMD.sendMessage(id);
                                    _Me.CMD.SendNoWriteMsg(uid);
                                    return false;
                                }
                                if (e.ctrlKey)
                                {
                                    $("wChatInputId" + id + "Type" + t).value = $("wChatInputId" + id + "Type" + t).value + "\n";
                                    return false;
                                }
                            }
                            else
                            {
                                if (e.ctrlKey)
                                {
                                    _Me.CMD.sendMessage(id);
                                    _Me.CMD.SendNoWriteMsg(uid);
                                    return false;
                                }
                            }
                        }
                        if (Other.GetCookie("MsgSendType") == "Enter" && (!e.ctrlKey && e.keyCode == 13)) {
                            _Me.CMD.sendMessage(id);
                            _Me.CMD.SendNoWriteMsg(uid);
                            return false;
                        }
                        else 
                            if (Other.GetCookie("MsgSendType") == "Enter" && (e.ctrlKey && e.keyCode == 13)) {
                                _Me.CMD.sendMessage(id);
                                _Me.CMD.SendNoWriteMsg(uid);
                                return false;
                            }
                    };
                    $("wChatBtnSendId" + id + "Type" + t).onclick = function(){
                        _Me.CMD.SendNoWriteMsg(uid);
                        _Me.CMD.sendMessage(id);
                    };
                    $("wChatFaceButtonFaceId" + id + "Type" + t).onclick = function(e){
                        _Me.CMD.showFaceList(id, e);
                    };
                    $("wChatBtnOptionId" + id + "Type" + t).onclick = function(e){
                        var m = new SysMenu("menuMsgSendKey" + id + "Type" + t);
                        m.Data = ["哦|Elem.Value('wChatInputId" + id + "Type" + t + "','哦');WebIndex.WebIm.CMD.sendMessage(" + id + ")", "好吧|Elem.Value('wChatInputId" + id + "Type" + t + "','好吧');WebIndex.WebIm.CMD.sendMessage(" + id + ")", "我得下了，拜拜!|Elem.Value('wChatInputId" + id + "Type" + t + "','我得下了，拜拜!');WebIndex.WebIm.CMD.sendMessage(" + id + ")", "", "Enter 发送消息|Other.SetCookie('MsgSendType','Enter')", "Ctrl+Enter 发送消息|Other.SetCookie('MsgSendType','Ctrl+Enter')"];
                        if (Other.GetCookie("MsgSendType") == "Enter") {
                            var selectAdd = 1;
                        }
                        else {
                            var selectAdd = 2;
                        }
                        m.Data[selectAdd + 3] += "|images/selected.gif|images/selectedhover.gif";
                        m.E = e;
                        m.HasIcon = true;
                        m.Width = 175;
                        m.Show();
                    };
                    _Me.CMD.ScroolMsgBody(uid);
                };
                w.Show();
                w.Focus();
            }
        }
    }
}