﻿if(typeof(top.__setting)!="object") 
{ 
	top.__setting = {};
	top.__setting._values = new Array();
	top.__setting.getValue = function(AName, ADefault) { var v =this._values[AName]; if (! v) v = ADefault; return v;}
	top.__setting.setValue = function(AName, AValue) { this._values[AName] = AValue;}
	top.__setting.initValue = function(AName, AValue) {if (! this._values[AName]) this._values[AName] = AValue;}
};
var _setting = top.__setting;

var AllIMDlgs=_setting.getValue("All_IM_Dlg_Array",null);
if (AllIMDlgs==null)
{
    AllIMDlgs={};
    _setting.setValue("All_IM_Dlg_Array",AllIMDlgs);
}

var AllUserStateArray=_setting.getValue("All_User_State_Array",null);
if (AllUserStateArray==null)
{
    AllUserStateArray=[];
    _setting.setValue("All_User_State_Array",AllUserStateArray);
}

var AllUserNickNameArray=_setting.getValue("All_User_NickName_Array",null);
if (AllUserNickNameArray==null)
{
    AllUserNickNameArray=[];
    _setting.setValue("All_User_NickName_Array",AllUserNickNameArray);
}

var AllIMDlgPopWindowMap=_setting.getValue("All_IM_Dlg_PopWindow_Map",null);
if (AllIMDlgPopWindowMap==null)
{
    AllIMDlgPopWindowMap={};
    _setting.setValue("All_IM_Dlg_PopWindow_Map",AllIMDlgPopWindowMap);
}

var AllIMTalkMembers=_setting.getValue("All_IM_Talk_Members",null);
if (AllIMTalkMembers==null)
{
    AllIMTalkMembers={};
    _setting.setValue("All_IM_Talk_Members",AllIMTalkMembers);
}

var AllIMMsgSequence=_setting.getValue("All_IM_Msg_Sequence",null);
if (AllIMMsgSequence==null)
{
    AllIMMsgSequence={};
    _setting.setValue("All_IM_Msg_Sequence",AllIMMsgSequence);
}

var AllUserArray = _setting.getValue("All_User_Array", null);
if (AllUserArray == null)
{
    AllUserArray = new Array();
    _setting.setValue("All_User_Array", AllUserArray);
}

var AllUserNickArray = _setting.getValue("All_Nick__Array", null);
if (AllUserNickArray == null)
{
    AllUserNickArray = new Array();
    _setting.setValue("All_Nick__Array", AllUserNickArray);
}

var StaffID_UserIDArray = _setting.getValue("All_StaffID_UserID__Array", null);
if (StaffID_UserIDArray == null)
{
    StaffID_UserIDArray = new Array();
    _setting.setValue("All_StaffID_UserID__Array", StaffID_UserIDArray);
}

var isFinished = true;
var MYisFinished = true;
var maxTimeInterval = 100000;
var timeInterval = 1000;
var MYcurrentTimePeriod=0;
var currentTimePeriod = 0;
var currentGUID;

function $(_sId){return document.getElementById(_sId);}

function ShowLocalNavigateBar(idPrefex){
    ResizeWindow();
    ShowNavigateBar(idPrefex, partNavigateTd);
}
function OpenSysChatWindow(thisPopWindowId)
{
    if(top.popWindowObj.getPopWindow(thisPopWindowId)!=null)
    {
        if(top.popWindowObj.getPopWindow(thisPopWindowId).style.display=='none'){
            top.popWindowObj.showPopWindow(thisPopWindowId);
        
        }else if(top.popWindowObj.getPopWindow(thisPopWindowId).showsize=="min"){
            top.popWindowObj.restorePopWindow(thisPopWindowId);
        }
//        window.focus();        
        return 1;    
    }
    else
    {
        var popWindow = top.popWindowObj.createPopWindow(thisPopWindowId);        
        var chatFrame = top.document.createElement('IFRAME');
        
        chatFrame.id='ChatFrame'+thisPopWindowId;
        chatFrame.name='ChatFrame'+thisPopWindowId;
        chatFrame.style.width="100%";
        chatFrame.style.height="405px";
        chatFrame.style.display="";
        chatFrame.frameBorder ="0";
        
        //var touser =  users[0]== userId? users[1]:users[0];
        chatFrame.src = "NewIMFrame/SystemAlert.aspx?popWindowId="+thisPopWindowId;

        popWindow.appendChild(chatFrame);
         
       
        popWindow.resizePopWindow = function(width,height){
             width = width ;
             height = height;
             chatFrame.style.width =width;
             chatFrame.style.height =height;
             //top.document.frames['ChatFrame'+thisPopWindowId].Sys_DlgObj.resize(width,height);
             //edit by crazy7 2008-02-25
             var topFrame = document.frames ? top.document.frames['ChatFrame'+thisPopWindowId] : top.document.getElementById('ChatFrame'+thisPopWindowId).contentWindow;
             topFrame.Sys_DlgObj.resize(width,height);
             //end edit
        }
        
        top.popWindowObj.divInit(thisPopWindowId,0,0);
        top.popWindowObj.setTitle(thisPopWindowId,'系统消息');
        
//        window.focus();
        return 2;
        }
    
}
function OpenChatWindowById(toUserId,thisPopWindowId,personListStr,setFocus)
{
    var pLArray=personListStr.split("_");  
    if(top.popWindowObj.getPopWindow(thisPopWindowId)!=null)
    {        
        if(top.popWindowObj.getPopWindow(thisPopWindowId).style.display=='none'){
            top.popWindowObj.showPopWindow(thisPopWindowId);
        
        }else if(top.popWindowObj.getPopWindow(thisPopWindowId).showsize=="min"){
            top.popWindowObj.restorePopWindow(thisPopWindowId);
        }
                
        if (setFocus && top.document.hasFocus && !top.document.hasFocus())
        {            
//            window.focus();
            //document.getElementById("ChatFrame" + thisPopWindowId).document.body.focus();
        }
        if (setFocus) top.popWindowObj.getPopWindow(thisPopWindowId).setActive();
        return 1;
    
    }
    else
    {        
        var popWindow = top.popWindowObj.createPopWindow(thisPopWindowId);
        
        var chatFrame = top.document.createElement('IFRAME');
        
        chatFrame.id='ChatFrame'+thisPopWindowId;
        chatFrame.name='ChatFrame'+thisPopWindowId;
        chatFrame.style.width="100%";
        chatFrame.style.height="405px";
        chatFrame.style.display="";
        chatFrame.frameBorder ="0";

        chatFrame.src = "NewIMFrame/Chat.aspx?fromuser=" + top.currentUserID + "&touser=" + toUserId + "&popWindowId=" + thisPopWindowId + "&toPersonListStr=" + personListStr;
        
        popWindow.appendChild(chatFrame);

        //IE6不自动刷新
        if (MyBrowser.ie=="6.0")
            window.frames['ChatFrame' + thisPopWindowId].location.reload();

        popWindow.resizePopWindow = function(width, height)
        {
            width = width;
            height = height;
            chatFrame.style.width = width;
            chatFrame.style.height = height;
            var frameId = 'ChatFrame' + thisPopWindowId;
            var frame = top.document.frames ? top.document.frames[frameId] : top.document.getElementById(frameId).contentWindow;
            //top.document.frames['ChatFrame'+thisPopWindowId].Msg_DlgObj.resize(width,height);
            frame.Msg_DlgObj.resize(width, height);
        }
        popWindow.ClosePopWindow = function()
        {
            //清空session计数器
            if (Project && Project.UserStatisticsAjax)
                Project.UserStatisticsAjax.ClearSessionDoc(pLArray[1]);
                
            var curUser = AllUserArray[top.currentUserID];
            //只能普通用户给医生评价
            if (curUser && curUser.IsDoctor == 0)// if (curUser && curUser.Department == "")
            {//普通用户
                var tempDocID = pLArray[0];
                if (tempDocID == top.currentUserID)
                    tempDocID = pLArray[1];
                if (AllUserArray[tempDocID] && AllUserArray[tempDocID].IsDoctor == 1)
                    OpenPopWindow('Grade' + personListStr, 'UserGradeScore.aspx?docID=' + tempDocID, '请对本次谈话进行评分，谢谢！', 370, 240);
            }
            return true;
        }
        top.popWindowObj.divInit(thisPopWindowId,0,0);
        top.popWindowObj.setTitle(thisPopWindowId, '与' + getMultiNickName(pLArray, top.currentUserID) + '交谈中…');
//        debugger;
        if (setFocus && document.hasFocus && !document.hasFocus())
        {
//            window.focus();
//            chatFrame.document.body.focus();
        }
        if (setFocus) popWindow.setActive();
//        var time="";
//        if(arguments.length>2){
//            time= arguments[2];
//        }
     
        //ShowRecentMessage(thisPopWindowId, time);
//            ShowRecentMessage(thisPopWindowId);
        
        return 2;
        
    }
}

function OpenChatWindow(toUserId,personListStr, setFocus)
{
    var thisPopWindowId = "";
    var pLArray=personListStr.split("_");        
    if(AllIMDlgPopWindowMap[toUserId])
    {
        thisPopWindowId=AllIMDlgPopWindowMap[toUserId];
    }
    else
    {        
        pLArray.sort(function (a,b){return a-b;});
        var idForCompare=pLArray.join("_");
        if (!toUserId && toUserId.length>2) 
        {
            for(var key in AllIMDlgs)
            {
                //不可能两个E的人员会相等
                //两个U的人员可能相等，但是不可取
                
                if(AllIMDlgs[key].theDlgGuid!="SystemAlert"&&toUserId.substr(0,1)!=AllIMDlgs[key].theDlgGuid.substr(0,1)&&idForCompare==AllIMTalkMembers[key].MyMembers.join("_"))
                {
                    thisPopWindowId=AllIMDlgPopWindowMap[key];
                    if (toUserId.substr(0,1)=="U")
                    {                    
                        AllIMDlgs[key].ChangeMyDlgId(toUserId);                    
                    }
                    else
                    {
                        if (toUserId.substr(0,1)=="E")    
                            toUserId=AllIMDlgs[key].theDlgGuid;                    
                        break;
                    }                
                }
            }
        }
    }
    if(!AllIMTalkMembers[toUserId])
    {                            
        AllIMTalkMembers[toUserId]=new TalkMembers();
        AllIMTalkMembers[toUserId].TalkMembersInit(personListStr);
        //AllIMTalkMembers[toUserId].MyMembers=personListStr.split("_");
    }
    if(!AllIMMsgSequence[toUserId])
    {                            
        AllIMMsgSequence[toUserId]=[];                            
    }  
    if (thisPopWindowId=="")
    { 
        thisPopWindowId=GenerateGUID();
        AllIMDlgPopWindowMap[toUserId]=thisPopWindowId;
    }
    OpenChatWindowById(toUserId,thisPopWindowId,personListStr,true);
}


function OpenSysWindow(PMsgFiledArray,theMessage)
{
    var thisPopWindowId="";
    if(AllIMDlgPopWindowMap["SystemAlert"])
    {
       thisPopWindowId=AllIMDlgPopWindowMap["SystemAlert"];
    }
    else
    {
            thisPopWindowId=GenerateGUID();
            AllIMDlgPopWindowMap["SystemAlert"]=thisPopWindowId;
    }
    if(!AllIMMsgSequence["SystemAlert"])
    {                            
        AllIMMsgSequence["SystemAlert"]=[];                           
    }
    OpenSysChatWindow(thisPopWindowId);
   
    AllIMMsgSequence["SystemAlert"].push(PMsgFiledArray);
//    AllIMMsgSequence["SystemAlert"].push(PMsgFiledArray[0]);
    
    transferMessageNew("SystemAlert", PMsgFiledArray[0]);
}

function OpenChatWindowAndTransferMessage(toUserId,PMsgFiledArray,theMessage,setFocus,StrongOpen)
{
    var personListStr=PMsgFiledArray[9];
    var thisPopWindowId="";
    var pLArray=personListStr.split("_");        
    if(AllIMDlgPopWindowMap[toUserId])
    {
       thisPopWindowId=AllIMDlgPopWindowMap[toUserId];
    }
    else
    {        
        pLArray.sort(function (a,b){return a-b;});
        var idForCompare=pLArray.join("_");
        for(var key in AllIMDlgs)
        {
            //不可能两个E的人员会相等
            //两个U的人员可能相等，但是不可取
            
            if(AllIMTalkMembers[key]&&toUserId.substr(0,1)!=AllIMDlgs[key].theDlgGuid.substr(0,1)&&idForCompare==AllIMTalkMembers[key].MyMembers.join("_"))
            {
                thisPopWindowId=AllIMDlgPopWindowMap[key];
                if (toUserId.substr(0,1)=="U")
                {                    
                    AllIMDlgs[key].ChangeMyDlgId(toUserId);                    
                }
                else
                {
                    if (toUserId.substr(0,1)=="E")    
                        toUserId=AllIMDlgs[key].theDlgGuid;                    
                    break;
                }                
            }
        }
    }
    if(!AllIMTalkMembers[toUserId])
    {                            
        AllIMTalkMembers[toUserId]=new TalkMembers();
        AllIMTalkMembers[toUserId].TalkMembersInit(personListStr);
        //AllIMTalkMembers[toUserId].MyMembers=personListStr.split("_");
    }
    if(!AllIMMsgSequence[toUserId])
    {                            
        AllIMMsgSequence[toUserId]=[];                           
    }  
    if (thisPopWindowId=="")
    {
        if(StrongOpen)
        {
            thisPopWindowId=GenerateGUID();
            AllIMDlgPopWindowMap[toUserId]=thisPopWindowId;
        }
        else
        {
            //AllIMMsgSequence[toUserId].push(PMsgFiledArray[0]);
            return -1;
        }
    }                      
     OpenChatWindowById(toUserId,thisPopWindowId,personListStr,setFocus);    
     AllIMMsgSequence[toUserId].push(PMsgFiledArray);
     //AllIMMsgSequence[toUserId].push(PMsgFiledArray[0]);     
     transferMessageNew(toUserId, PMsgFiledArray[0]);
}

	function ChangeDlgId(oldId,newId)
    {
        if (oldId==newId) return;
        var theDlg=AllIMDlgs[oldId];
        var theTalkMembers=AllIMTalkMembers[oldId];
        var theDlgPopWindowMap=AllIMDlgPopWindowMap[oldId];
        var theIMMsgSequence=AllIMMsgSequence[oldId];
        
        if (!theDlg||!theTalkMembers||!theDlgPopWindowMap||!theIMMsgSequence) return;
        theDlg.theDlgGuid=newId;
        theDlg.MessageInputIFrame.id="Editor"+theDlg.theDlgGuid;
        delete AllIMDlgs[oldId];
        AllIMDlgs[newId]=theDlg;
        
        delete AllIMTalkMembers[oldId];
        AllIMTalkMembers[newId]=theTalkMembers;
        
        delete AllIMDlgPopWindowMap[oldId];
        AllIMDlgPopWindowMap[newId]=theDlgPopWindowMap;   
        
        delete AllIMMsgSequence[oldId];
        AllIMMsgSequence[newId]=theIMMsgSequence;
        
        //top.popWindowObj.popRename(oldId,newId);
    }

    function ShowRecentMessage(id,time)
    {    
        if(!checkLoaded(id)){
	         setTimeout("ShowRecentMessage("+id+",'"+time+"')", 500);

	     } else
	     {
	         var topFrame = document.frames ? parent.document.frames['ChatFrame' + id] : parent.document.getElementById('ChatFrame' + id).contentWindow;
	         topFrame.ShowRecentMessage(id, time);	            
	     }
    }
	
	function Now(){
	    var Timer=new Date();
        var hours=Timer.getHours();
        var minutes=Timer.getMinutes();
        var seconds=Timer.getSeconds();
        return hours+"_"+minutes+"_"+seconds;
	}
	
	

		
	function getNickName(aUserId){	
	
	    var nick = top.userNickArray['_'+aUserId];
	
	    return nick;
	}
	
	function getMultiNickName(toUList,fromId)
	{
	    var ret="";
	    var j=0;
	    for(var i=0;i<toUList.length;i++)
	    {
	        if(toUList[i]!=fromId)
	        {	            
	            if (j>0) ret+=",";
	            ret+=getNickName(toUList[i]);	            
	            j++;
	        }
	    }	
	    return ret;    
	}
	
	
	function checkLoaded(id){
	    var topFrame = document.frames ? parent.document.frames['ChatFrame' + id] : parent.document.getElementById('ChatFrame' + id).contentWindow;
	    if (topFrame && topFrame.isLoaded)
	    {
	             return true;  
	     }else
	     {      
	        return false;
	     }
	
	
	}

	function pause(numberMillis) { 
	    var now = new Date(); 
	    var exitTime = now.getTime() + numberMillis; 
	    while (true) { 
		    now = new Date(); 
		    if (now.getTime() > exitTime) 
		    return; 
	    } 
    } 

    
    function changeNickName(nktext){
       
        if(event.keyCode==13){
            
            if(trim(nktext.value)==""){
                alert('昵称不能为空');
                $('NickName').value=$('PreNickName').value;
                return false;
            }
        
          //调用ajax方法更新昵称
          QDOA.Chat.QdChatManageAjax.ChangeNickName(nktext.value,changeNickNameReturn);
        
          //使该窗口失去焦点
          nktext.style.border='none 0px #FFFFFF';
          return false;
        }
    }
    
    function changeNickNameReturn(r){
    
        
    if(r!=null&&r.value!=null&&parseInt(r.value,10)==1){
            alert("昵称更改成功！");
            $('PreNickName').value=$('NickName').value;
            $('NickName').title=$('NickName').value;
            document.body.focus();
        
        }else{
            alert("昵称更改失败！");
            $('NickName').value=$('PreNickName').value;
        } 
    }
    
function SortPerson(sortType){
    if(sortType=="S"){
        var head = document.getElementById("FriendHead");
        head.style.display='none';
        var body = document.getElementById("FriendBody");
        body.style.display='none';
        var head2 = document.getElementById("PersonHead");
        head2.style.display='none';
        var body2 = document.getElementById("PersonBody");
        body2.style.display='none';
        
        
        var head3 = document.getElementById("OnlinePersonHead");
        head3.style.display='';
        var body3 = document.getElementById("OnlinePersonBody");
        body3.style.display='';
        var head4 = document.getElementById("OfflinePersonHead");
        head4.style.display='';
        
            
        partNavigateTd[0]= "OnlinePerson";
        partNavigateTd[1]= "OfflinePerson";
        
    }else if(sortType=="G"){
        
        var head = document.getElementById("OnlinePersonHead");
        head.style.display='none';
        body = document.getElementById("OnlinePersonBody");
        body.style.display='none';
        head2 = document.getElementById("OfflinePersonHead");
        head2.style.display='none';
        body2 = document.getElementById("OfflinePersonBody");
        body2.style.display='none';
        
        
        head3 = document.getElementById("FriendHead");
        head3.style.display='';
        body3 = document.getElementById("FriendBody");
        body3.style.display='';
        head4 = document.getElementById("PersonHead");
        head4.style.display='';
        
        
        partNavigateTd[0]= "Person";
        partNavigateTd[1]= "Friend";
    }
}





//////////-----------------------ROOM AND OTHER--------------------------------------------------------



function InitializeIdNickStatus()
{
    // 空实现，为了保持旧代码兼容性
}

function InitializeIdNickStatus2(aAllPersonIdNickStatusString)
{
    AllUserArray.splice(0, AllUserArray.length);
    AllUserNickArray.splice(0, AllUserNickArray.length);
    StaffID_UserIDArray.splice(0, StaffID_UserIDArray.length);
    
    top.userNickArray = AllUserNickArray;
    top.StaffID_UserIDArray = StaffID_UserIDArray;
    
    var allPersonIdNickStatus = aAllPersonIdNickStatusString;
    var array = allPersonIdNickStatus.split('\x1D');

    var i = 0;
    for (; array != null && i < array.length; i++)
    {
        var value = array[i].split('\x1C');
        var newUser = new Object();
        newUser.UserID = value[0];
        newUser.StaffName = value[1];
        newUser.StaffID = value[2];
        newUser.LoginName = value[3];
        newUser.NickName = value[4];
        newUser.Status = value[5];
        newUser.Photo = value[6];
        newUser.Department =value[7] ;
        newUser.Position = value[8];
        newUser.Phone = value[9];
        newUser.IsDoctor = value[10];

        AllUserArray[value[0]] = newUser;
        top.userNickArray['_'+value[0]] = value[1];
        top.StaffID_UserIDArray[value[2]] = value[0];
    }
    top.userIdCount = i;     
}
function AddIdNickStatus(userID,ReloadIfNew)
{
    if (!AllUserArray[userID] || ReloadIfNew == true)
    {
        var userString = QDOA.Chat.QdChatManageAjax.GetIMUserInfoByIMUserId(userID).value;

        var allPersonIdNickStatus = userString;
        var array = allPersonIdNickStatus.split('\x1D');
        var i = 0;
        for (; array != null && i < array.length; i++)
        {
            var value = array[i].split('\x1C');
            var newUser = new Object();
            newUser.UserID = value[0];
            newUser.StaffName = value[1];
            newUser.StaffID = value[2];
            newUser.LoginName = value[3];
            newUser.NickName = value[4];
            newUser.Status = value[5];
            newUser.Photo = value[6];
            newUser.Position = value[7];
            newUser.Department = value[8];
            newUser.Phone = value[9];
            newUser.IsDoctor = value[10];

            AllUserArray[value[0]] = newUser;
            top.userNickArray['_' + value[0]] = value[1];
            top.StaffID_UserIDArray[value[2]] = value[0];
        }
        top.userIdCount += i;
    }
}

function CreateChatRoom(){
   //调用ajax方法创建聊天室，返回聊天室ID   
   toUserIDCharRoom = top.currentUserID;
   //QDOA.Chat.ChatAjax.CreateRoom(String(userId), CreateRoomReturn);  
  // var roomId = GenerateGUID();
   //OpenChatRoomWindow(toUserId,personListStr, setFocus)
    top.ShowTopDlg("NewIMFrame/EditRoomInfo.aspx?userid="+toUserIDCharRoom);	
}


function CreateRoomReturn(r){
    if(r!=null&&r.value!=null&&r.value!=''){
        var roomId = r.value;
        top.chatRoomOwnerIdArray['_' + roomId] = top.currentUserID; 
        OpenChatRoom(roomId);
        //var inituserlist = userId + '\x1D' + toUserIDCharRoom;
        //SetRoomMemberList(roomId, inituserlist);
        
    }else{
        alert('多人聊天失败');
        
    }
}
//function CreateChatRoom(){
//       var inituserlist = id.replace(/_/gi,'\x1D');
//       OpenChatRoom(fromUserId,id);
//       SetRoomMemberList(id,inituserlist);
//       //SelectRoomMemberList(id);      
//}



function IsChatRoomOpen(chatRoomId){
    if(parent.popWindowObj.getPopWindow(chatRoomId)!=null){
        return true;
    }else{
        return false;
    }

}

	  //用于NewIM
    function transferMessageNew(id, messageId){
        //msgArray=message.split("\x1C");
        
        if (AllIMMsgSequence[id]&&AllIMMsgSequence[id][0]&&AllIMMsgSequence[id][0][0]!=messageId)//不是序列中的第一个元素
        {            
            return;
        }

        if (!AllIMDlgs[id] || !parent.frames['ChatFrame' + AllIMDlgs[id].popWindowId].isLoaded)
        {
            //message = message.replace(/(\\)/gi,"\\\\");	
	        //message = message.replace(/(\")/gi,"\\\"");
            setTimeout("transferMessageNew(\""+id+"\","+messageId+")", 500);
        }
        else
        {            
            while(AllIMMsgSequence[id][0])
            {
                var topFrame = document.frames ? parent.document.frames['ChatFrame' + AllIMDlgs[id].popWindowId] : parent.document.getElementById('ChatFrame' + AllIMDlgs[id].popWindowId).contentWindow;
                topFrame.ShowMessageNew(AllIMDlgs[id].popWindowId, id, AllIMMsgSequence[id][0].join("\x1C")); 
                AllIMMsgSequence[id].splice(0,1);
            }
	    }
    }
    function OpenChatRoomWindow(toUserId,notStrongOpen)
    {
        var thisPopWindowId="";
        
        if(AllIMDlgPopWindowMap[toUserId])
        {
            thisPopWindowId=AllIMDlgPopWindowMap[toUserId];
        }  
        
        if(!AllIMMsgSequence[toUserId])
        {                            
            AllIMMsgSequence[toUserId]=[];                            
        }  
        
        if (thisPopWindowId=="")
        { 
            thisPopWindowId=toUserId;
            AllIMDlgPopWindowMap[toUserId]=thisPopWindowId;
        }
        OpenChatRoom(thisPopWindowId,notStrongOpen);
    }
    
    function ReloadMembers(meetingRoomId)
    {
        var topFrame = document.frames ? parent.document.frames['ChatFrame' + meetingRoomId] : parent.document.getElementById('ChatFrame' + meetingRoomId).contentWindow;
        if (CheckChatRoomExist(meetingRoomId) && topFrame.isLoaded)
            topFrame.MsgDlgRoomMemberReload();         
    }
    
    function CheckChatRoomExist(chatRoomId)
    {
        var thisPopWindowId="";
        
        if(AllIMDlgPopWindowMap[chatRoomId])
        {
            thisPopWindowId=AllIMDlgPopWindowMap[chatRoomId];
        }  
        else
        {
            thisPopWindowId=chatRoomId;
        }  
        if (parent.popWindowObj.getPopWindow(chatRoomId)!=null)
            return true;
        return false;
             
    }
    
 function OpenChatRoom(chatRoomId,notStrongOpen){
 
      if(parent.popWindowObj.getPopWindow(chatRoomId)!=null){
             if(notStrongOpen) return 1;
             if(parent.popWindowObj.getPopWindow(chatRoomId).style.display=='none'){
                 parent.popWindowObj.showPopWindow(chatRoomId);
             
             }else if(parent.popWindowObj.getPopWindow(chatRoomId).showsize=="min"){
                 parent.popWindowObj.restorePopWindow(chatRoomId);
             }
             
//             if(window.document.hasFocus && !window.document.hasFocus()){
//                 window.focus();
//             }
             return 1;
         
      }else{
     
         var popWindow;
         if (notStrongOpen) 
            popWindow = parent.popWindowObj.createPopWindow(chatRoomId,true,"600px");
         else 
            popWindow = parent.popWindowObj.createPopWindow(chatRoomId,false,"600px");
         
         var chatFrame = parent.document.createElement('IFRAME');
         
         chatFrame.id='ChatFrame'+chatRoomId;
         chatFrame.name='ChatFrame'+chatRoomId;
         chatFrame.style.width="100%";
         chatFrame.style.height="496px";
         chatFrame.style.display="block";
         chatFrame.frameBorder ="0";           
        
         chatFrame.src = "NewIMFrame/ChatRoom.aspx?MeetingID="+chatRoomId;
         
         popWindow.appendChild(chatFrame);
         parent.popWindowObj.divInit(chatRoomId,0,0);
         parent.popWindowObj.setTitle(chatRoomId,'会议室'+chatRoomId);
         
         popWindow.resizePopWindow = function(width,height){
             width = width;
             height =height;
              chatFrame.style.width =width;
              chatFrame.style.height =height;
            // top.document.frames['ChatFrame'+chatRoomId].Msg_DlgObj.resize(width,height);         
             //edit by crazy7 2008-02-25
             var topFrame = document.frames ? top.document.frames['ChatFrame'+chatRoomId] : top.document.getElementById('ChatFrame'+chatRoomId).contentWindow;
             topFrame.Msg_DlgObj.resize(width,height);
             //end edit
         }
         popWindow.closePopWindow = function(){
              var ret = confirm('您真的要退出会议室吗？');
              return ret;
         }
         if(notStrongOpen) return 2;
//         if(window.document.hasFocus && !window.document.hasFocus()){
//                 window.focus();
//         }
         return 2;     
     }
    
 }

function CloseChatRoom(chatRoomId){
    if(parent.popWindowObj.getPopWindow(chatRoomId)!=null){
        parent.popWindowObj.closePopWindow(chatRoomId);
    }
}


function TalkMembers()
{
    var selfTalkMember=this;
     this.TalkMembersInit=function(initPersonStr)
     {        
         selfTalkMember.MyMembers=initPersonStr.split("_");
     }
     this.addAMember = function(newMemberId)
     {        
        selfTalkMember.MyMembers.push(newMemberId); 
     }     
    this.delAMember = function(theMemberId)
    {       
        for(var i=0;i<selfTalkMember.MyMembers.length;i++)
            if (selfTalkMember.MyMembers[i]==theMemberId)
                selfTalkMember.MyMembers.splice(i,1);
    }       
}

function BroadMessage(id)
{
   OpenBroadCastWindow(id);
  
}
    function OpenBroadCastWindow(id)
    {
        var thisPopWindowId="";
        
        if(!AllIMDlgPopWindowMap["BroadCast"])
        {
            AllIMDlgPopWindowMap["BroadCast"]="BroadCast";
        }
  
        if(!AllIMMsgSequence["BroadCast"])
        {                            
            AllIMMsgSequence["BroadCast"]=[];                            
        }  
        OpenBroadCastWindow1(id);
    }
 function OpenBroadCastWindow1(id){
 
       var chatRoomId = "BroadCast";
      if(parent.popWindowObj.getPopWindow(chatRoomId)!=null){
             if(parent.popWindowObj.getPopWindow(chatRoomId).style.display=='none'){
                 parent.popWindowObj.showPopWindow(chatRoomId);
             
             }else if(parent.popWindowObj.getPopWindow(chatRoomId).showsize=="min"){
                 parent.popWindowObj.restorePopWindow(chatRoomId);
             }
             
//             if(window.document.hasFocus && !window.document.hasFocus()){
//                 window.focus();
//             }
             return 1;
         
      }else{
     
         var popWindow = parent.popWindowObj.createPopWindow(chatRoomId);
         
         var chatFrame = parent.document.createElement('IFRAME');
         
         chatFrame.id='ChatFrame'+chatRoomId;
         chatFrame.name='ChatFrame'+chatRoomId;
         chatFrame.style.width="100%";
         chatFrame.style.height="393px";
         chatFrame.style.display="block";
         chatFrame.frameBorder ="0";           
         chatFrame.src = "NewIMFrame/BroadCastMessage.aspx?id="+id;
         
         popWindow.appendChild(chatFrame);
         parent.popWindowObj.divInit(chatRoomId,0,0);
         parent.popWindowObj.setTitle(chatRoomId,'广播消息');
         
         popWindow.resizePopWindow = function(width,height){
             width = width;
             height =height;
              chatFrame.style.width =width;
              chatFrame.style.height =height;
             //top.document.frames['ChatFrame'+chatRoomId].Msg_DlgObj.resize(width,height);
            //edit by crazy7 2008-02-25
             var topFrame = document.frames ? top.document.frames['ChatFrame'+chatRoomId] : top.document.getElementById('ChatFrame'+chatRoomId).contentWindow;
             topFrame.Msg_DlgObj.resize(width,height);
             //end edit
         }
         popWindow.closePopWindow = function(){
              //var ret = confirm('您真的要退出会议室吗？');//top.document.frames['ChatFrame'+chatRoomId].chatRoomObj.QuitChatRoom();
              return true;
         }
         
//         if(window.document.hasFocus && !window.document.hasFocus()){
//                 window.focus();
//         }
         return 2;
     
     }
    
 }

