关闭

js替换

1666人阅读 评论(0) 收藏 举报

document.getElementById("txtid").value.replace( //<//*[^<>]*/>/, "");

 

注册回车事件响应的按钮

this.Page.RegisterClientScriptBlock("_autoPostBack", " <script type=/"text/javascript/"> function document.onkeydown(){ if (event.keyCode == 13){ document.getElementById('" + btnDelSel.ClientID+ "').click(); }} </script> ");

this.Page.RegisterClientScriptBlock("_autoPostBack", " <script type=/"text/javascript/"> function document.onkeydown(){ if (event.keyCode == 13){ document.getElementById('" + btnDelSel.ClientID+ "').click(); }} </script> ");

//Page.Application.Add("onkeypress","if(event.keyCode == 13){document.all.btnSubmited.click(): return false:}");

 ((LinkButton)(this.FindControl("lbtnMsg"))).Attributes.Add("onclick", "window.open('adminMsg.aspx',target='show')");
href.location('xxx.aspx');this.display:none;

public string GetSQL()
  {
   string strBeginTime = "";
   string strEndTime = "";

   StringBuilder condition = new StringBuilder();
   condition.Append("unpass = 1 AND status=1 ");
   string strName = "";
   string strGrade = "";
   string strAreaID = "";
   string strSort = "";
   string strType = "";

   if(Request.QueryString["name"]!=null)
   {
    strName = FunctionList.SqlFormat(Server.UrlDecode(Request.QueryString["name"]));
   }

   if(Request.QueryString["grade"]!=null)
   {
    strGrade = FunctionList.SqlFormat(Request.QueryString["grade"].ToString());
   }

   if(Request.QueryString["AreaID"]!=null)
   {
    strAreaID = FunctionList.SqlFormat(Request.QueryString["AreaID"].ToString());
   }

   if(Request.QueryString["sort"]!=null)
   {
    strSort = FunctionList.SqlFormat(Request.QueryString["sort"].ToString());
   }
   
   if(strGrade.Trim()!="")
   {
    condition.Append(" AND GradeId="+strGrade);
   }

   if(strSort.Trim()!="")
   {
    condition.Append(" AND SortId="+strSort);
   }

   if(strAreaID.Trim()!="")
   {
    condition.Append(" AND OverID LIKE '"+FunctionList.SplictString(strAreaID)+"%"+"'");
   }

   if(strName.Trim()!="")
   {
    condition.Append(" AND SightName LIKE '%"+strName+"%"+"'");
   }

   if(strCountry!=null&&strCountry!="")
   {
    condition.Append(" AND OverID not LIKE '1,7,%'");
   }

   //根据控件类别获取Where条件
   if(Request.QueryString["Type"]!=null)
   {
    strType = Request.QueryString["Type"].ToString();
   }
   if(strType!="")
   {
    switch(strType)
    {
     case"1"://点击排行
     {
      this.SortField = "List";
      break;
     }
     case"2"://推荐排行
     {
      strBeginTime = "(CASE ISNULL(StartTime,'') WHEN '' THEN '1900-1-1' else StartTime end)";
      strEndTime = "(CASE ISNULL(FinishTime,'') WHEN '' THEN '2900-1-1' else FinishTime end)";
      condition.Append(" AND vouch!=0 AND Convert(datetime,"+strBeginTime+")<=getdate() AND Convert(datetime,"+strEndTime+")>=getdate()");
      this.SortField = "vouch";
      break;
     }
     case"3"://评分排行
     {
      this.SortField = "STASum";
      break;
     }
     case"4"://精品排行
     {
      strBeginTime = "(CASE ISNULL(popStartTime,'') WHEN '' THEN '1900-1-1' else popStartTime end)";
      strEndTime = "(CASE ISNULL(popEndTime,'') WHEN '' THEN '2900-1-1' else popEndTime end)";

      condition.Append("AND pop!=0 AND Convert(datetime,"+strBeginTime+")<=getdate() AND Convert(datetime,"+strEndTime+")>=getdate()");
      this.SortField = "pop";
      break;
     }
    }
   }
   return condition.ToString().Trim();
  }

 

 

static public void Up(string id,string type)
  {
  DataHelper dh=new DataHelper("TravelLine");
   try
   {
    dh.ExecuteNonQuery(@"declare @mintop int ,@selfPop int,@topid int,@id int
set @id="+id+@"
select @selfPop="+type+@" from TL_TravelLines where id=@id
select top 1 @topid=id,@mintop="+type+@" from TL_TravelLines where "+type+@">(select "+type+@" from TL_TravelLines where id=@id)  and "+type+@"!=0 and LogicDel=0 and AuditTag=0 order by "+type+@"
if(@topid is not null and @mintop is not null)
begin
update TL_TravelLines set "+type+@"=@mintop where id=@id
update TL_TravelLines set "+type+@"=@selfPop where id=@topid
end
");
   }
   catch(Exception e)
   {
   throw e;
   }
  }

 

 

xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
xmlhttp.open("GET", "http://localhost/sample.xml", false);
xmlhttp.send();
alert(xmlhttp.responseXML.xml);


var xmlhttp;

function createXMLHttpRequest()
{
 if(window.ActiveXObject)
 {
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 }
 else if (window.XMLHttpRequest)
 {
  xmlhttp = new XMLHttpRequest();
 }
}

function startRequest(url,method)
{
 createXMLHttpRequest();
 xmlhttp.open('GET',url,true);
 xmlhttp.onreadystatechange = method;
 xmlhttp.send(null);
}

 

function ChangeSkin()
{
 var link = document.getElementById("skinLink");
 var cssPath = document.getElementById("skinPath");
 if(link != null && cssPath != null && cssPath.value != "")
 {
  link.href = cssPath.value;
  cssStylePath = cssPath.value;
 }
 
}

var cssStylePath;

function ChangeSkinByPath(path)
{
 var link = document.getElementById("skinLink");
 
 if (link != null && path != null && path != "")
 {
  link.href = path;
 }
}

 

 

var fontfamily;
var fontSize;
var fontColor;
var ChatMsg;

//document.oncontextmenu = "return false;";
//取出用户的ID形成字符串
function UserListIDs(strUserList)
{
 var msgUserIds = "";
 var sender = $("sender").value + ",";
 if((strUserList != "") && (strUserList != ","))
 {
  var strUserList = strUserList.replace("*","");
  if(strUserList.indexOf(";") > 0)
  {
   var ChatUserArray = strUserList.split(";");
   for(var i = 0;i<ChatUserArray.length;i++)
   {
    if(ChatUserArray[i].indexOf(",") >=0)
    {
     var UserForList = ChatUserArray[i].split(",");
     msgUserIds += UserForList[0] + ",";   
    }
   }
   //群聊的时候,把发送者的ID加入到USERLIST中
   //msgUserIds = sender + msgUserIds;
  }
  else
  {
   var SingleUser = strUserList.split(",");
   msgUserIds = SingleUser[0];
  }
  if(msgUserIds.substr(msgUserIds.length -1) == ",")
  {
   //msgUserIds = sender + msgUserIds.substr(0,msgUserIds.length - 1);
   msgUserIds = msgUserIds.substr(0,msgUserIds.length - 1);
  }
 }
 return msgUserIds;
}
function onConClick()
{
 if(window.event.button == 0)
 {
  event.returnValue = false;
  var tmp = event.srcElement;
  if(tmp.id == "ChatValue")
  {
   var conMenu = $("contextmenu");
   conMenu.style.visibility = '';
   conMenu.style.top = event.clientY;
   conMenu.style.left = event.clientX;
  }
 }
}
//$("windowid").value = <%=Request["id"]%> ;
function $(d){return document.getElementById(d);}
//全局变量
//指示是否可以发送文件、禁止好友,多个用户群聊的时候不可以,默认为可以(单个用户)
var isSingleUser = true;

//初始化在线聊天用户
function FillGroupUserList()
{
   var txtUserList = $("ChatUserList").value.split(';');
   
   //刷新自己父页面的用户列表。
   window.opener.ChangeUserList(this, $("ChatUserList").value);
   
   //设置otherChatUserList属性,他是需要记录所有非要有的用户Id列表。
   window.opener.SetOtherChatUserList(UserListIDs($("ChatUserList").value));
   
   var userIdList = "";
   
   //切分用户列表。
   for (var i = 0;i < txtUserList.length;i++)
   {
    if(txtUserList[i] != null && txtUserList[i] != "")
    {
     if(userIdList == "")
     {
      userIdList = txtUserList[i].split(',')[0];
     }
     else
     {
      userIdList += "," + txtUserList[i].split(',')[0];
     }
    }
   }
   
   //在这里取得用户的头像信息。
   if(userIdList != null && userIdList != "")
   {
    var xmlhttp=createXMLHttpRequest();
  var dataToSend = "userIdList=" + userIdList;
  if(xmlhttp==null)
  {
   alert(varAlert1);
   return;
  }
  xmlhttp.open("POST", "../Online/GetUsersIcon.aspx",false);
  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  xmlhttp.onreadystatechange = function()
  {
   if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
   {
    sReturn=xmlhttp.responseText;
    
    if(sReturn != null && sReturn != "")
    {
     var imageDiv = $("friendImageDiv");
     imageDiv.innerHTML = "";
     
     var userList = sReturn.split(USER_ICON_SEPARATOR_1);
     
     for(var i = 0; i < userList.length;i++)
     {
      var userIcon = userList[i].split(USER_ICON_SEPARATOR_0);
      imageDiv.innerHTML =  imageDiv.innerHTML + "<IMG height='52' src='" + userIcon[1] + "' width='52'>";
      var userShowName = "";
      for (var j = 0;j < txtUserList.length;j++)
      {
       if(txtUserList[j] != null && txtUserList[j] != "")
       {
        var nameList = txtUserList[j].split(',');
        if(userIcon[0] == nameList[0])
        {
         userShowName = nameList[1];
         break;
        }
       }
      }
      imageDiv.innerHTML = imageDiv.innerHTML + "<div>" + userShowName + "</div>";
     }
    }
   }
  }
  try
  {
   xmlhttp.send(dataToSend);
  }
  catch(e)
  {
   alert(varAlert2);
   return;
  }
   }
   
   SetPageTitle();
}

 


//将用户输入的内容显示在上方的DIV
function ChatSend(obj)
{
 var chatValue = $("ChatValue");
 if (chatValue.innerHTML.length > 0)
 {
 var realHTML ="";
 var cont = "";
 var tempCont = chatValue.innerText;
 
 //截取聊天信息,不允许超过500字。
 if (tempCont.length > 500)
 {
  chatValue.innerText = tempCont.substr(0,500);
 }
 
 //处理掉所有的超链接。
 cont = chatValue.innerHTML.replace(/<a[^>]*>/gi,"").replace(/<//a>/gi,"");
 
 
 var isFamily = " face='" + fontfamily + "'";
 var isSize = " style='FONT-SIZE:" + fontSize + "px;' ";
 var isColor = " color='" + fontColor + "'";
 
 if(fontfamily)
 {
  realHTML +=  isFamily + " ";
 }
 
 if(fontSize)
 {
  realHTML +=  isSize + " ";
 }
 
 if(fontColor)
 {
  realHTML +=  isColor + " ";
 }
 
 //var msg = "<span style='font-size:13px;'>我 说 (" + GetDateTime() + "):</span><br/><font "+ realHTML + ">" + cont + "</font><br/>";
 
 var msg = "<span style='font-size:13px;'>" + varMsg + "(" + GetDateTime() + "):</span><br/><font "+ realHTML + ">" + cont + "</font><br/>"
  
 $("ChatContent").innerHTML += msg;
 $("ChatContent").doScroll();
 chatValue.innerHTML='';
 //var windowid = $("windowid").value;
 
 //cont = cont.replace(",",MESSAGE_SEPARATOR_2);
 cont = replaceAll(cont,",",MESSAGE_SEPARATOR_2);
 
 
 //要发送消息的用户列表,需要处理
 //var userids;
 //消息格式为:用户ID|用户状态0可用1不可用-1其它禁用|消息类型:子窗口消息sub|消息标识:接收消息|子窗口标识|窗口人员列表|消息内容:消息内容
 //var sendMsg = ""+ sender +"|0|sub|WM_ChatSendMessage|"+ windowid +"|"+ userids +"|<font "+ realHTML + ">" + cont + "</font><br/>";
 //var sendMsg = "45|0|sub|WM_ChatSendMessage|"+ windowid +"|49|<font "+ realHTML + ">" + cont + "</font><br/>";
 //需要增加判断当前会话中所有的好友,然后群发消息
    var userList=$("ChatUserList").value;
    var sender = $("sender").value;
 //var sendMsg = sender + "|0|sub|WM_ChatSendMessage|"+$("windowid").value+"|"+UserListIDs(userList)+"|"+$("windowid").value+","+UserListIDs(userList)+",<font "+ realHTML+ ">" + trimcomma(cont) + "</font><br/>";
 var sendMsg = sender + MESSAGE_SEPARATOR_0 + "0" + MESSAGE_SEPARATOR_0 + "sub" + MESSAGE_SEPARATOR_0 + "WM_ChatSendMessage" + MESSAGE_SEPARATOR_0 + $("windowid").value + MESSAGE_SEPARATOR_0 + UserListIDs(userList) + MESSAGE_SEPARATOR_0;
 

 
 var msgTemp = "<font "+ realHTML+ ">" + cont + "</font><br/>";
 
 
 //聊天内容加密。
 msgTemp = encrypt(msgTemp, MESSAGE_ENNCRYPT_PASSWORD);
 
 sendMsg = sendMsg + msgTemp;
 SendMsg(sendMsg);
 CheckSendButton(chatValue);
 }
}
//发送消息
function SendFileMsg(msg)
{
 var userList=$("UserList").value;
 var sendUser;
 
 $("ChatContent").doScroll();
 
 if(userList.indexOf(",") > 0)
 {
  sendUser = userList.split(',');
 }
 var sender = $("sender").value;
 var filemsg= sender + MESSAGE_SEPARATOR_0 + "0" + MESSAGE_SEPARATOR_0 + "sub" + MESSAGE_SEPARATOR_0 + "WM_ChatSendMessage" + MESSAGE_SEPARATOR_0 +$("windowid").value+MESSAGE_SEPARATOR_0+UserListIDs(userList)+MESSAGE_SEPARATOR_0;
 msg = "<font style='font-size:13px;'>" + msg + "</font>";
 var msgTemp = msg;
 //聊天内容加密。
 msgTemp = encrypt(msgTemp, MESSAGE_ENNCRYPT_PASSWORD);
 filemsg += msgTemp;
 SendMsg(filemsg);
}
function SendMsg(msg)
{
 var xmlhttp=createXMLHttpRequest();
 if(xmlhttp==null)
 {
  alert(varAlert1);
  return;
 } 
 
 var dataToSend = "message=" + escape(msg);
 xmlhttp.open("POST", "../online/IMPassMessage.aspx",false);
 xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 xmlhttp.onreadystatechange = function()
 { 
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
  {
   //根据返回值判断消息是否发送成功
  }
 }
 try
 {
  xmlhttp.send(dataToSend);
 }
 catch(e)
 {
  alert(varAlert2);
  return;
 }
 
 ChatMsg.focus();
 
}


//接到聊天内容后处理,将聊天内容显示到页面中
function convertmsg(msg)
{
 //消息格式为:用户ID|用户状态0可用1不可用-1其它禁用|消息类型:子窗口消息sub|消息标识:接收消息|子窗口标识|窗口人员列表|消息内容:消息内容
 if(msg.length > 0)
 {
  var MsgArray = msg.split(MESSAGE_SEPARATOR_0);
  var userid = MsgArray[5];
  var sender = $("sender").value;
  //$("sender").value = $("UserList").value;
  $("UserList").value = userid;
  FillGroupUserList();
  //var userstate =  MsgArray[1];
  //var messagetype = MsgArray[2];
  //var messageid =  MsgArray[3];
  var windowid = MsgArray[4];
  $("windowid").value = windowid;
  //var userids =  MsgArray[5];
  var MsgContent = MsgArray[6];
  if(userid.indexOf(',') > 0)
  {
   //不管是不是群聊,发送者永远是第一个用户。
   var sendUser = userid.split(';')[0];
   var userName = sendUser.split(',')[1];
   
   //var UseriDName = sendUser.split(',');
   //var userName = UseriDName[1].toString();//$("lblUserProfile").value;
  }
  
  //////////////////////////////////////////////////////////////////////
  //修改内容:去掉判断,不知道为什么在这里判断下这个,到底起什么作用。
  //   但如果发送这ID是接受者ID的一部分,比较ID=1发给ID=101的。
  //   那么消息永远都得不到,类似的问题还根多,用字符串可能很多地方会出现。
  //修改人:蔡芃
  //修改时间:2007-5-17 14:25:13
  ////////////////////////////////////////////////////////////////////////
  
  //if(userid.indexOf(sender) < 0)
  //{
  
   //MsgContent = MsgContent.replace(MESSAGE_SEPARATOR_2,",");
   
   MsgContent = decrypt(MsgContent, MESSAGE_ENNCRYPT_PASSWORD);
   
   MsgContent = replaceAll(MsgContent,MESSAGE_SEPARATOR_2,",");
  
   $("ChatContent").innerHTML += "<span style='font-size:13px;'>"+ userName +"(" + GetDateTime() + "):</span><br/>" + MsgContent;
   $("ChatContent").doScroll();
  //}
 }
}


//初始化,主要是摆放各个DIV
function init()
{
   ChatMsg = $("ChatValue");
   //var btn = $("chatbtn");
   try
   {
    var firstMsg = opener.document.all('firstMessage');
   }
   catch(e)
   {
    alert(varAlert3);
    window.location = "../webmanage/onlineuserlogin.aspx";
   }
   
   ////////////////////////////////////////////////////////////////
   //修改内容:去掉了第一次加载消息。
   //修改人:蔡芃
   //修改日期:2007-4-30 9:37:42
   ////////////////////////////////////////////////////////////////
   //if((firstMsg!=null) && (firstMsg.value.length > 0))
   //{
    //convertmsg(firstMsg.value);
    //$("ChatContent").innerHTML += "<strong><br>说:</strong>" + firstMsg.value + "<br>";
    //firstMsg.value = "";
   //}
   //btn.style.left = ChatMsg.style.pixelWidth + 30;
   //btn.style.top  = ChatMsg.style.top;
   
   var SendFileLink = $("divSendFileLink");
   //var lblUser = $("lblUserProfile");
   
   //SendFileLink.left = lblUser.style.pixelWidth + 10;
   //SendFileLink.top  = lblUser.top;
   
   FillGroupUserList();
   
   //widthTemp = window.document.body.offsetWidth;
 //heightTemp = window.document.body.offsetHeight;
 
 ReSetDiv();
 
 //加入未保存提示信息。
 $("ChatContent").innerHTML = "<font style='FONT-SIZE:13px' color='#636180'>" + varMsg1 + "</font><br/>";
 
 if ($("userIsOnline").value == "False")
 {
  AddUnOnlineMsg();
 }
 else
 {
  $("userIsOnline").value = "False";
  setTimeout("ResetImageButton()",3000);
 }
 
 ChatMsg.focus();
 
}

//初始化邀请好友按钮。
function ResetImageButton()
{
 $("userIsOnline").value = "True";
 $("imgAddFriend").className = "UserIconStyle3";
}

//var widthTemp;
//var heightTemp;


//设置颜色面板
function ShowColorPanel(img)
{
 var colorpanel = $("colorpanel");
 colorpanel.style.display = 'block';
 colorpanel.style.top = event.clientY - colorpanel.style.height + 12;
 colorpanel.style.left = event.clientX;
}
//设置字体颜色
function SetForeColor(color)
{
 var colorimg = $("colorpicker");
 colorimg.style.backgroundColor = color;
 var chat_forecolor= $("colorpanel");
 chat_forecolor.style.display = "none";
 ChatMsg.style.color = color;
 fontColor = color;
 ChatMsg.focus();
}
//设置字体粗体
function SetFontBold()
{
 document.execCommand('Bold',false,'');
 ChatMsg.focus();
}
//设置字体斜体
function SetFontItalic(img)
{
 document.execCommand('Italic',false,'');
 ChatMsg.focus();
}
//设置字体下划线
function SetFontUnderline()
{
 document.execCommand('Underline',false,'');
 ChatMsg.focus();
}
//设置字体
function SetFontFamily(selfont)
{
 ChatMsg.style.fontFamily = selfont.value;
 if (selfont.value != "")
 {
  fontfamily = selfont.value;
 }
 else
 {
  fontfamily = "Arial";
 }
 ChatMsg.focus();
}
//设置字号
function SetFontSize(fontsize)
{
 ChatMsg.style.fontSize = fontsize.value;
 if (fontsize.value != "")
 {
  fontSize = fontsize.value;
 }
 else
 {
  fontSize = null;
 }
 ChatMsg.focus();
}

var mousePoint;

//显示表情面板
function ShowEmotionPanel(img)
{
 var emotionpanel = $("emotionpanel");
 emotionpanel.style.display = 'block';
 emotionpanel.style.top = event.clientY - emotionpanel.style.height;
 emotionpanel.style.left = event.clientX;
 
 /*
 //获取当前光标的位置。
 ChatMsg.focus();
 
 //记录原始数据。
 var oldHTML = ChatMsg.innerHTML;
 
 //把特殊字符插入到当前位置。
 var range = document.selection.createRange();
 range.pasteHTML(MOUSE_POINT);
 
 //新的数据。
 var newHTML = ChatMsg.innerHTML;
 
 //还原
 ChatMsg.innerHTML = oldHTML;
 
 //获取位置。
 mousePoint = newHTML.indexOf(MOUSE_POINT);
 
 emotionpanel.focus();
 
 
 return false;
 */
}

var imageCount = 0;

//插入表情
function InsertEmotion(img)
{
 
 /*
 //手动插入表情。
 var newHTML;
 newHTML =  ChatMsg.innerHTML.substring(0, mousePoint);
 var imgId = "img" + imageCount;
 imageCount ++;
 var imageCode = "<img id='" + imgId + "' src='" + img + "' width='19' height='19' border=0 unselectable='on'>";
 newHTML += imageCode;
 newHTML += ChatMsg.innerHTML.substring(mousePoint, ChatMsg.innerHTML.length);
 ChatMsg.innerHTML = newHTML;
 
 //var imageCode = "<img src='" + img + "' width='19' height='19' border=0 unselectable='on'>";
 //range.pasteHTML(imageCode);
 */
 
 ChatMsg.focus();
 var range = document.selection.createRange();
 var imageCode = "<img src='" + img + "' width='19' height='19' border=0 unselectable='on'>";
 range.pasteHTML(imageCode);
 
 var emotionpanel = $("emotionpanel");
 emotionpanel.style.display = "none";
 CheckSendButton(ChatMsg);
 
}

isSetPoint = false;

//邀请好友到对话中
function ShowInvitePanel()

 if ($("userIsOnline").value == "False")
 {
  return;
 }
 
 //从新拆分好友列表。
 var userList = $("ChatUserList").value.split(';');
 var newUserList = "";
 
 for (var i = 0; i < userList.length; i++)
 {
  if (userList[i] != null && userList[i] != "")
  {
    if (newUserList == "")
    {
    newUserList = userList[i].split(',')[0];
    }
    else
    {
    newUserList += "," + userList[i].split(',')[0];
    }
  }
 }
 
 argDialogNewUserList = newUserList;
 
 //打开好友列表,选择要邀请的好友
 var Wininvite = window.showModelessDialog('../WebManage/OnLineFriendList.aspx?userid=' + UserSelfId,window,'dialogHeight:400px;dialogWidth:300px;status:no;toolbar:no;menubar:no;location:no;');
 
 //UpdateUserList(Wininvite);
 ChatMsg.focus();
}

var argDialogNewUserList;

function UpdateUserList(Wininvite)
{
 if((Wininvite != null) && (Wininvite != "undefined"))
 {
  var UserList = $("ChatUserList");
  var newArrayUserList = Wininvite.split(";");
  var oldArrayUserList = UserList.value.split(";");
  var result;
  for(var i=0;i<newArrayUserList.length;i++)
  {
   result = true;
   for(var j=0;j<oldArrayUserList.length;j++)
   {
    if(newArrayUserList[i] == "")
    {
     result = false;
     break;
    }
    else
    {
     if(newArrayUserList[i] == oldArrayUserList[j])
     {
      result = false;
      break;
     }
    }
   }
   
   if(result)
   {
    UserList.value += ";" + newArrayUserList[i];
   }
   
  }
  
  FillGroupUserList();
 }
}

 

//禁止某个用户
var banimage = true;
function banFriend()
{
 var banLink = document.getElementById("banImage");
 if(isSingleUser)
 {
  if(banimage)
  {
   banLink.alt = "解禁此用户";
   banLink.src = "../OnLine/Skin/Skin1/Images/unban.gif";
   banimage = false;
  }
  else
  {
   banLink.alt = "禁止此用户";
   banLink.src = "../OnLine/Skin/Skin1/Images/ban.gif";
   banimage = true;
  }
  Ban(banimage);
 }
}
//禁止某用户,提交数据库处理
function Ban(isBan)
{
 //
 var UserList = $("UserList");
 var User = UserList.value.split(',');
 var UserID = User[0];

 var xmlhttp=createXMLHttpRequest();
 if(xmlhttp==null)
 {
  alert(varAlert1);
  return;
 }
 var sSelfID = $("sender").value;
 xmlhttp.open("GET", "../online/IMBanFriend.aspx?BanedId="+ UserID +"&isBan="+ isBan +"&SelfID="+ sSelfID,false);
 xmlhttp.onreadystatechange = function()
 { 
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
   {
    //根据返回值判断消息是否发送成功
    var sReturn=xmlhttp.responseText;
    if(sReturn=='false')
    {
     alert('禁止好友失败');
     return;
    }
    else
    {
     alert('更新成功');
    }
   }
 }
 xmlhttp.send(null);
}
function ConfirmQuit()
{
 var UserType = $("usertype");
 
 if(!confirm('直接退出将不会保存聊天记录,保存聊天记录吗?'))
 {
  //RecordSave();
  return false;
 }
 else
 {
  //否
  
  window.close();
  return false;
 }
}
//访客退出
function UserLogOut()
{
 var xmlhttp=createXMLHttpRequest();
 if(xmlhttp==null)
 {
  alert(varAlert1);
  return;
 }
 var sSelfID=document.getElementById('sender').value;
 xmlhttp.open("GET", "../online/IMUserLogOut.aspx?UserID="+sSelfID+"&usertype=guest",false);
 xmlhttp.onreadystatechange = function()
 {
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
  {
   var sReturn=xmlhttp.responseText;
   if(sReturn=='false')
   {
    alert(varAlert4);
    return;
   }
   else
   {
    window.close();
   }
  }
 }
 xmlhttp.send(null);
}

function RecordArgs()
{
 this.Content = "";
 this.Title = "";
 this.FileName = "";
}


//保存聊天记录
function RecordSave()
{
 var obj = document.getElementById("ChatContent").innerHTML;
 if(obj != null && obj != "" && confirm(Confirm))
 {
  var objargs = new RecordArgs();
  objargs.Content = obj;
  objargs.Title = varChatRecordTitle;
  objargs.FileName = varFileName;
  window.showModelessDialog("../WebManage/MonitorRecordFrame.aspx",objargs,"dialogHeight:0px;dialogWidth:0px;dialogTop:10000px;dialogLeft:-100px;edge: Raised; center: No; scroll: yes; help: no; resizable: no; status: No;");
 }
}
//转换字符串
function TranslateText(text)
{
 if(text==null)return "";

 for(var i=0;i<text.length;i++)
 {
  var o=text[i];
  text=text.replace(o.r,o.t);
 }
 text=Html_Encode(text);
 text=text.split("/n").join("<br/>");
 text=text.replace(/(/S+://///S+)/ig,"<a target='_blank' href='$1'>$1</a>");
 text=TranslateHtml(text);

 return text;
}
//转换成HTML
function TranslateHtml(html)
{
 if(html==null)return "";
 html=html.replace(//[Emotion=([^/[/]=/s]+)/]/ig,"<img src=Skin/Skin1/Images/emotions/$1>");
 return html;
}
//向用户列表中增加用户邀请的好友
function AppendContact(div,Username)
{
 var p=document.createElement("NOBR");
 var img=document.createElement("IMG");
 img.src="Skin/Skin1/Images/personal_online.gif";
 img.align='absmiddle';
 p.appendChild(img);
 p.appendChild(document.createTextNode(" "));
 var span=document.createElement("SPAN");
 span.innerHTML=Html_Encode(Username);
 p.appendChild(span);
 var tmpDiv = $(div);
 tmpDiv.appendChild(p);
 //将上传文件功能隐藏
 AllowSendFileLink(false);
}
//处理客户输入的内容,主要是滤掉和转换一些特殊字符
function Html_Encode(text)
{
 if(text==null) return "";
 if(typeof(text)!="string") text = text + "";
 return text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(//x22/g,"&quot;").replace(//x27/g,"&#39;").replace(//n/g,"<br/>").replace(//r/g,"") + "<BR>";
}
//用户直接按回车后直接发送内容,功能相当于是用户点击发送按钮

var isSend =false;

function DoSend(obj)
{
 if(event.ctrlKey)
 {
  if (event.keyCode == 13 && isSend)
  {
  event.returnValue=false;
  event.cancel = true;
  //使用表单提交
  ChatSend(obj);
  }
    }
   
}
//用户选择文件,发送
function fileDialogShow()
{
 //window.showModalDialog("IMSendFile.aspx",null,"dialogWidth=400px;dialogHeight=200px;edge: Raised; center: No; scroll: yes; help: no; resizable: no; status: No;dialogTop:" + (screen.availHeight - 200)/2 + "; dialogLeft:" + (screen.availWidth - 400)/2 + ";");
 var id = document.getElementById("sender").value;
 
 window.open("IMSendFile.aspx?Id=" + id,"_blank","width=400px,height=200px,top=" + (screen.availHeight - 200)/2 + ", left=" + (screen.availWidth - 400)/2);
  
 
}
//是否显示发送文件按钮
/*function AllowSendFileLink(isAllowSend)
{
 var linkSendFile = document.getElementById("divSendFileLink");
 var linkBan      = document.getElementById("banImage");
 if(isAllowSend)
 {
  linkSendFile.style.display = '';
  linkBan.style.display = '';
 }
 else
 {
  linkSendFile.style.display = 'none';
  linkBan.style.display = 'none';
 }
}
//是否显示禁止用户按钮
function AllowBanLink(isAllow)
{
 var linkBan      = document.getElementById("banImage");
 if(isAllow)
 {
  linkBan.style.display = '';
 }
 else
 {
  linkBan.style.display = 'none';
 }
}
*/
//隐藏所有浮动的DIV
//function HideAllFloatDivs()
//{
 //var colorpanel   = $("contextmenu");
 //var emotionpanel = $("colorpanel");
 //var contextpanel = $("emotionpanel");
 //colorpanel.style.visibility = 'hidden';
 //emotionpanel.style.visibility = 'hidden';
 //contextpanel.style.visibility = 'hidden';
//}


/*
类名称:MessageType 消息类型处理类
类用途:用作消息类型的增删查
编写日期:2007-3-26
编写人:  杨云鹏
操作方法:
  增加(add)
  批量增加(addRange)
  删除(remove)
  删除指定的(removeAt)
  批量删除(removeRange)
  获得消息类型数量getCount
  查找find
  获取指定的键getKeys
  获取指定的值getValues
*/

var MessageType = function(){
    this._data = new Object();   
}
    function MessageType$add(key,value){    
        if(!key) return;
        if(typeof(value) === 'undefined') return;       
        this._data[key] = value;  
    }
    function MessageType$addRange(h){
        if(!h || !h._data) return;
        for(var key in h._data){
            var value = h._data[key];           
            this.add(key,value);           
        }
    }
    function MessageType$remove(key){
        if(!key) return null;
        var value = this._data[key];
        delete this._data[key];   
        return value;             
    }
   
    function MessageType$removeAt(index){
        if(isNaN(index)) return null;
        var i = 0;       
        for(var key in this._data){
            if(i == index){
                return this.remove(key);
            }
            i++;
        }
        return null;
    }
    function MessageType$removeRange(startIndex,endIndex){
        if(isNaN(startIndex) || isNaN(endIndex)) return null;
        if(startIndex > endIndex)return null;
        var i = 0;
        var h = new MessageType();
        for(var key in this._data){
            if(i>=startIndex && i<= endIndex){
                h.add(key,this.remove(key));
            }else if(i>endIndex){               
                break;
            }
            i++;
        }       
        return h;
    }   
    function MessageType$getCount(){
        var i = 0;
        for(var key in this._data) i++;       
        return i;
    }
    function MessageType$find(key){
        if(!key) return null;  
        return this._data[key];
    }
    function MessageType$forEach(method,instance){
        var i = 0;
        for(var key in this._data){
            var value = this._data[key];
            if(typeof(value) !== 'undefined'){
                var r = method.call(instance, key, value, i, this);
                if(r == 'break') break;               
                i++;
            }
        }
    }
    function MessageType$getKeys(){
        var arr = new Array();
        for (var key in this._data){
            arr.push(key);
        }
        return arr;
    }
    function MessageType$getValues(){
        var arr = new Array();
        for (var key in this._data){
            arr.push(this._data[key]);
        }
        return arr;       
    }
 MessageType.prototype = {
    _data : null,
    add : MessageType$add,
    addRange: MessageType$addRange,
    remove : MessageType$remove,
    removeAt : MessageType$removeAt,
    removeRange : MessageType$removeRange,
    getCount : MessageType$getCount,
    find : MessageType$find,
    forEach : MessageType$forEach,
    getKeys : MessageType$getKeys,
    getValues : MessageType$getValues   
}
MessageType.__typeName = 'MessageType';

/*
类名称:CookieMgr Cookie管理类
类用途:用作对Cookie的增删查
编写日期:2007-3-26
编写人:  杨云鹏
操作方法:
  初始化(init)
  增加(set)
  删除(Del)
  取得(get)
  获取所有getAll
  删除所有Destroy
*/
function CookieMgr(){
    this.key="";
    this.value="";
    this.expires=0;
    this.init=function(){
        this.key="";
        this.value="";
        this.expires=0;
    }
    this.set=function(key,value,expires){
        if(this.key=="")this.key=key;
        if(this.value=="")this.value=value;
        if(this.expires<=0)this.expires=expires;
        if(this.key==""||typeof(this.key)!="string"){
            //alert("请先设置要保存的cookie键");
            this.init();
            return false;
        }
        if(this.key.match(/[,; ]/)){
            //alert("cookie键中不能包含",",";"或空格等非法字符");
            this.init();
            return false;
        }
        if(this.value.toString().match(/[,; ]/)||typeof(this.value)=="undefined"){
            //alert("cookie值中不能包含",",";"或空格等非法字符");
            this.init();
            return false;
        }
        if(this.expires<=0||typeof(this.expires)!="number"){
            //alert("请正确设置cookie的有效时间");
            this.init();
            return false;
        }
        //保存的cookie名称已经存在
        var cookie=document.cookie;
        if(cookie.indexOf(this.key+"=")!=-1){
            //if(!confirm("cookie名称已经存在,是否要进行替换?"))
            //{
                this.init();
                return false;
           // }
        }
        var dt=new Date();
        dt.setTime(dt.getTime()+this.expires);
        document.cookie=this.key+"="+this.value+";expires="+dt.toGMTString();
        this.init();
        return true;
    }
    this.get=function(key){
        if(key==""||key.match(/[,; ]/)){
            //alert("请正确设置查找的cookie键");
            return false;
        }
        var cookie=document.cookie;
        var start=cookie.indexOf(key+"=");
        if(start==-1){
            //alert("查找的cookie不存在!");
            return false;
        }
        var end=cookie.indexOf(";",start);
        if(end==-1)end=cookie.length;
        var getCookie=cookie.substring(start+key.length+1,end);
        //alert("cookie:"+key+"的值为"+getCookie);
        return getCookie;
    }
    this.getAll=function(){
  var arr=[];
  var cookies=document.cookie.split(';');
  for(var i=0;i<cookies.length;i++)
  {
   var parts=cookies[i].split('=');
   var cookie={name:parts[0].replace(//s/g,''),value:unescape(parts[1])};
   arr[arr.length]=cookie;
  }
  return arr;
    }
    this.Del=function(key){
        if(key==""||key.match(/[,; ]/)){
            //alert("请正确设置删除的cookie键");
            return false;
        }
        var dt=new Date();
        dt.setTime(dt.getTime());
        document.cookie=key+"=CookieDelete;expires="+dt.toGMTString();
        this.init();
        return true;
    }
    this.Destroy=function(){
        var dt=new Date();
        dt.setTime(dt.getTime());
        while(document.cookie!=""){
            document.cookie=document.cookie+";expires="+dt.toGMTString();
            this.init();
            return true;
        }
    }
}

/*
类名称:AJAXRequest
类用途:Ajax请求类
编写日期:2007-3-26
编写人:  杨云鹏
属性:Method   -  请求方法,POST或者GET,默认为POST
   Url      -  请求URL,字符串(可以包含参数),默认为空
   Async    -  是否异步,true为异步,false为同步,默认为true
   Content  -  请求的内容,请求方法为POST时需要设定此属性,默认为空
   Callback -  回调函数,返回响应内容时调用的函数,回调函数参数为XMLHttpRequest对象
方法:Send()   -  发送请求
*/
function AJAXRequest() {
    var xmlObj = false;
    var ResponseFunc,AjaxSelf;
    AjaxSelf = this;
    try
    {
  xmlObj=new XMLHttpRequest;
 }
    catch(e)
    {
  try
  {
   xmlObj=new ActiveXObject("MSXML2.XMLHTTP");
  }
        catch(IE)
        {
   try
   {
    xmlObj=new ActiveXObject("Microsoft.XMLHTTP");
   }
            catch(NonSupport)
            {
    xmlObj=false;
   }
        }
    }
   
    if (!xmlObj) return false;
    this.Method = "POST";
    this.Url;
    this.Async = true;
    this.Content = "";
    this.Callback = function(ResponseFunc) {return;}
    this.Send = function(){
        if(!this.Method||!this.Url||!this.Async)
        {
   return false;
  }
        xmlObj.open(this.Method,this.Url,this.Async);
       
        if(this.Method == "POST")
        {
   xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  }
        xmlObj.onreadystatechange = function() {
            if(xmlObj.readyState==4)
            {
                if(xmlObj.status==200)
                {
                    AjaxSelf.Callback(xmlObj);
                }
            }
        }
        if(this.Method=="POST")
        {
   xmlObj.send(this.Content);
  }
        else
        {
   xmlObj.send(null);
  }
    }
}

/*
类名称:MessagePackage
类用途:消息包类
编写日期:2007-3-26
编写人:  杨云鹏
属性:Header      -  标志消息包的头信息(协议,压缩格式等等)
   Sender      -  发送消息者
   Receiver    -  接收消息者
   MsgType     -  消息的类型
   MsgContent  -  消息的内容
   GUID        -  会话唯一号
   toString    -  序列化消息
方法:
   Initial   -  初始化消息
   Send      - 发送消息
   toCookie  -  将消息转到Cookie
   Parse     -  将消息拆包
*/
function MessagePackage()
{
 this.Header = "";
 this.Sender = "";
 this.Receiver = "";
 this.MessageType = "";
 this.MessageContent = "";
 this.GUID = "";
 this.Initial = function(MsgHeader,MsgSender,MsgReceiver,MsgType,MsgContent,Guid)
 {
        this.Header = MsgHeader;
        this.Sender = MsgSender;
        this.Receiver = MsgReceiver;
        this.MessageType = MsgType;
        this.MessageContent = MsgContent;
        this.GUID = Guid;
    }
    this.Send = function (){}
    this.toString = function()
    {
  return "Header:" + this.Header + ";" + "MessageSender:" + this.Sender + ";" + "MessageReceiver:" + this.Receiver + ";" + "MessageType:" + this.MessageType + ";" + "MessageContent:" + this.MessageContent + "";
    }
    this.toCookie() = function()
    {
  
    }
    this.Parse() = function ()
    {
  //从服务器端得到消息内容后,根据消息的内容进行拆分,将聊天内容显示出来,此函数只是将消息包拆分开
  
    }
}
//将选中的用户ID添加到隐含变量中
function SelectUser(userid,allSelect)
{
 var userList = $("chkSelected");
 var users = userList.value;
 
 if (users.indexOf( "," + userid + ",") != -1)
 {
  //列表中有*号表示被全选,只要取消一个用户即修改全选状态为未全选,并从列表中移除该用户ID和*号
  users = users.replace("," + userid + ",",",");
  users = users.replace("*","");
  document.getElementById(allSelect).checked = false;
 }
 else
 {
  if (users == "") users = ",";
  
  //用户列表以 ,ID,ID, 的形式存储,添加用户ID到列表时要添加结束的,号
  users = users + userid + ",";
  
  //如果所有的ID都被选中,修改全选状态为全选,并将*号添加到用户列表
  //if ("*" + users == document.getElementById("chkAllUsers").value)
  if (Compare(document.getElementById("chkAllUsers").value,users))
  {
   users = "*" + users;
   document.getElementById(allSelect).checked = true;
  }
 }
 
 userList.value = users;
}
//比较
function Compare(all,selected)
{
 selected = "*" + selected;
 
 if (all.length != selected.length)
 {
  return false;
 }
 
 var list = selected.split(',');
 
 for (var i = 0; i < list.length; i++)
 {
  all = all.replace(list[i] + ',','');
 }
 
 if (all == "")
 {
  return true;
 }
 
 return false;
}

var UserSelfId;

function SetUserId(uid)
{
 UserSelfId = uid;
}

//重发消息
function ReSendMessage(message)
{
 var xmlhttp=createXMLHttpRequest();
 var dataToSend = "msg=" + escape(message) + "&userId=" + UserSelfId;
 if(xmlhttp==null)
 {
  alert(varAlert1);
  return;
 }
 xmlhttp.open("POST", "../online/IMReSendMessage.aspx",false);
 xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 try
 {
  xmlhttp.send(dataToSend);
 }
 catch(e)
 {
  alert(varAlert2);
  return;
 }
}

function CheckSendButton(obj)
{
 if(obj.innerHTML != null && obj.innerHTML != "")
 {
  isSend = true;
 }
 else
 {
  isSend = false;
 }
 ChangeSendButtonImage();
}

function ChangeSendButtonImage()
{
 var obj = document.getElementById("sendButton");
 var cssFolderPath = cssStylePath.substring(0,cssStylePath.lastIndexOf("/"));
 var sendButtonImageUrl;
 if(obj != null)
 {
  if(isSend)
  {
   sendButtonImageUrl = cssFolderPath + "/images/" + varSendButtonImageUrl1;
  }
  else
  {
   sendButtonImageUrl = cssFolderPath + "/images/" + varSendButtonImageUrl;
  }
  
  document.getElementById("sendButton").style.backgroundImage  = "url(" + sendButtonImageUrl + ")";
 }
}

var isShowSelfImageDiv = true;

function ChangeSelfImageDiv()
{
 var obj = document.getElementById("selfImageDiv");
 if(obj != null)
 {
  if(isShowSelfImageDiv)
  {
   obj.style.display = "none";
  }
  else
  {
   obj.style.display = "block";
  }
  isShowSelfImageDiv = !isShowSelfImageDiv;
  ReSetDiv();
 }
}

var isShowFriendImageDiv = true;

function ChangeFriendImageDiv()
{
 var obj = document.getElementById("friendImageTd");
 if(obj != null)
 {
  if(isShowFriendImageDiv)
  {
   obj.style.display = "none";
  }
  else
  {
   obj.style.display = "block";
  }
  isShowFriendImageDiv = !isShowFriendImageDiv;
  ReSetDiv();
 }
}

function ChangeMouseStyle(sender)
{
 sender.style.cursor = "hand";
}

function IsFileLink()
{
 var el = event.srcElement;
 if(el == null)
 {
  return false;
 }
 
 //如右击的输入框,就可以弹。
 if(el.id == "ChatValue")
 {
  return true;
 }
 
 //如果是文本链接,就可以弹。
 if(el.className == "fileLink")
 {
  return true;
 }
 
 return false;
 
}

function ReSetDiv()
{

 var width = window.document.body.offsetWidth;
 var height = window.document.body.offsetHeight;
 var result = true;
 if(height >= 294)
 {
  height -= 141;
 }
 else
 {
  result = false;
 }
 
 if(width >= 439)
 {
  width -= 148;
 }
 else
 {
  result = false;
 }
 //return;
 if (result)
 {
  document.getElementById("tdChatContent").style.height = height;
  document.getElementById("ichat-left").style.height = window.document.body.offsetHeight - 40;
  //document.getElementById("friendImageDiv").style.height = document.getElementById("friendImageTd").offsetHeight - 50;
  document.getElementById("friendImageTd").height = height;
  document.getElementById("friendImageDiv").style.height = height - 3;
  document.getElementById("button").style.width = window.document.body.offsetWidth;
  
  if(isShowFriendImageDiv)
  {
   document.getElementById("tdChatContent").style.width = width;
  }
  else
  {
   document.getElementById("tdChatContent").style.width = width + 79;
  }
  
  if(isShowSelfImageDiv)
  {
   document.getElementById("tdChatValue").style.width = width;
  }
  else
  {
   document.getElementById("tdChatValue").style.width = width + 79;
  }
 }
 
 if(window.document.body.offsetWidth < 439)
 {
  if (window.document.body.offsetHeight != null && window.document.body.offsetHeight != "")
  {
   window.resizeTo(447,window.document.body.offsetHeight + 27);
  }
  else
  {
   window.resizeTo(447,321);
  }
 }
 
 if(window.document.body.offsetHeight < 294)
 {
  if (window.document.body.offsetWidth != null && window.document.body.offsetWidth != "")
  {
   window.resizeTo(window.document.body.offsetWidth + 8,321);
  }
  else
  {
   window.resizeTo(447,321);
  }
 }
 
}

function DocumentMouseUp()
{
 CheckSendButton(document.getElementById("ChatValue"));
 document.getElementById("emotionpanel").style.display = "none";
 document.getElementById("colorpanel").style.display = "none";
}


function replaceAll(src, oldStr, newStr)
{
 return src.replace(new RegExp(oldStr, "g"), newStr);
}

function SetPageTitle()
{
 var txtUserList = $("ChatUserList").value.split(';');
 var friendName = "";
 for (var i = 0;i < txtUserList.length;i++)
 {
  if (friendName == "")
  {
   friendName = txtUserList[i].split(',')[1];
  }
  else
  {
   friendName += "、" + txtUserList[i].split(',')[1];
  }
 }
 
 if (friendName != "")
 {
  friendName = String.format(varTitle, friendName)
  window.document.title = friendName;
 }
 
}

//修改表情按钮鼠标移动上去时的图片
function ChangeeMotionpickerImage(sender)
{
 sender.src = "Skin/Skin1/Images/biaoqing-hover.gif";
}

function ChangeeMotionpickerImageOut(sender)
{
 sender.src = "Skin/Skin1/Images/biaoqing.gif";
}

function GetDateTime()
{
 var d = new Date();
 var time;
 var month;
 var day;
 var hours;
 var minutes;
 var seconds;
 time = d.getFullYear();
 month = d.getMonth() + 1;
 
 if (month.toString().length == 1)
 {
  month = "0" + month.toString();
 }
 time += "-" + month;
 day = d.getDate();
 
 if (day.toString().length == 1)
 {
  day = "0" + day.toString();
 }
 time += "-" + day;
 time += " ";
 hours = d.getHours();;
 
 if (hours.toString().length == 1)
 {
  hours = "0" + hours.toString();
 }
 time += hours;
 minutes = d.getMinutes();
 
 if (minutes.toString().length == 1)
 {
  minutes = "0" + minutes.toString();
 }
 time += ":" + minutes;
 seconds = d.getSeconds();
 
 if (seconds.toString().length == 1)
 {
  seconds = "0" + seconds.toString();
 }
 time += ":" + seconds;
 
 return time;
}

function GetFontType()
{
 var obj = event.srcElement.createTextRange();
 
}

function DocumentKeyDown()
{
 //屏蔽tab键
 if (event.keyCode == 9 || event.keyCode == 116)
 {
  event.keyCode = 0;
  event.returnValue=false;
  return false;
 }
 
}

//分析复制的内容。
function fnPaste()
{
 try
 {
  //window.clipboardData.setData("Text", window.clipboardData.getData("Text"));
  
  var objChat = document.getElementById("ChatValue");
  var text = window.clipboardData.getData("Text");
  
  //如果是超链接,我们这里需要手动处理。不允许复制超链接。
  //不知道为什么,就算处理了,写进DIV如果带有下列特性他还是会自动添加超链接标记。
  if (text.toLowerCase().indexOf("www.") == 0 || text.toLowerCase().indexOf("http://") == 0)
  {
   //手动插入文字,不让IE剪贴版乱搞。
   
   //在当前问题粘贴进特殊字符,以便替换。
   objChat.focus();
   var range = document.selection.createRange();
   range.pasteHTML(CHAT_TEXT_SPECIAL);
   ChatMsg.focus();
   
   //手动在当前位置替换这个文本。
   objChat.innerHTML = objChat.innerHTML.replace(CHAT_TEXT_SPECIAL, text);
   
   //取消复制
   event.returnValue=false;
   return false;
  }
  else
  {
   window.clipboardData.setData("Text", window.clipboardData.getData("Text"));
  }
  
 }
 catch(e)
 {
  event.returnValue=false;
  return false;
 }
}

function AddUnOnlineMsg()
{

 if (isShowLogoutMessage)
 {
  $("ChatContent").innerHTML += "<font style='font-size:13px;color:#636180;'>" + varMsg2 + "</font><br/>"
  $("ChatContent").doScroll();
 }
}


var isShowLogoutMessage = true;

function DelUserList(userId)
{
 var txtUserList = $("ChatUserList").value.split(';');
 
 //如果是单聊
 if (txtUserList.length == 1)
 {
 
  var userIdAndName = txtUserList[0].split(',');
  
  if (userIdAndName[0] == userId)
  {
   
   //单聊下线后不能邀请好友。
   $("imgAddFriend").className = "UserIconStyle2";
   $("userIsOnline").value = "False"
   AddUnOnlineMsg();
   isShowLogoutMessage = false;
   return false;
  }
 }
 else
 {
  var userListtext = "";
  
  for (var i = 0;i < txtUserList.length;i++)
  {
   var userIdAndName = txtUserList[i].split(',');
   
   if (userIdAndName[0] != userId)
   {
    if (userListtext == "")
    {
     userListtext = userIdAndName[0] + "," + userIdAndName[1];
    }
    else
    {
     userListtext += ";" + userIdAndName[0] + "," + userIdAndName[1];
    }
   }
  }
  $("ChatUserList").value = userListtext;
 }
 
 return true;
}

function LoguotMessage(userId)
{
 //获取下线好友的用户名。
 var txtUserList = $("ChatUserList").value.split(';');
 var userName = "";
 for (var i = 0;i < txtUserList.length;i++)
 {
  var userIdAndName = txtUserList[i].split(',');
  if (userIdAndName[0] == userId)
  {
   userName = userIdAndName[1];
   break;
  }
 }
 
 //写入提示信息。
 if (userName != "" && isShowLogoutMessage)
 {
  var msg = String.format( varMsg3, userName);
  $("ChatContent").innerHTML += "<font style='font-size:13px;color:#636180;'>" + msg + "</font><br/>"
  $("ChatContent").doScroll();
 }
 
 return userName;
 
}

//把主窗体中自己的引用移除
function RemoveWindow()
{

 //如果是群聊,那么发送退出群聊消息。
 var txtUserList = $("ChatUserList").value.split(';');
 if (txtUserList.length > 1)
 {
  var xmlhttp=createXMLHttpRequest();
   if(xmlhttp==null)
   {
    alert(varAlert1);
    return;
   }
   var userId = $("sender").value;
   var dataToSend = "userId=" + userId + "&userList=" + escape($("ChatUserList").value);
   xmlhttp.open("POST", "../online/IMExitChat.aspx",false);
   xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   try
   {
    xmlhttp.send(dataToSend);
   }
   catch(e)
   {
    alert(varAlert2);
    return;
   }
 }
 
 try
 {
  window.opener.RemoveWindow(this);
 }
 catch(e)
 {
  
 }
}

function setFocus()
{
 //event.returnVlaue = false;
 //return false;
}

//
function cvblur()
{
/*
 var pos = -1;
 var rang = ChatMsg.document.selection.createRange();
 var tempText=document.body.createTextRange();
 rang.select();
 tempText.setEndPoint("EndToStart",rang);
 pos=tempText.text.length;
 alert(pos);
*/ 
}

function UserExitChat(userId, userList)
{
 var txtUserList = $("ChatUserList").value.split(';');
 var arrUserList = userList.split(';');
 var selfId = $("sender").value;
 var arrUsersIdList = GetUsersIdFromUserList(txtUserList);
 var arrUsersIdListTemp = GetUsersIdFromUserList(arrUserList);
 
 //首先去掉自己。
 for (var i = 0;i < arrUsersIdListTemp.length;i++)
 {
  if (arrUsersIdListTemp[i] == selfId)
  {
   arrUsersIdListTemp.splice(i, 1);
   break;
  }
 }
 
 //去掉其他聊天好友。
 for (var i = 0;i < arrUsersIdListTemp.length;i++)
 {
  for (var j = 0;j < arrUsersIdList.length;j++)
  {
   if (arrUsersIdListTemp[i] == arrUsersIdList[j])
   {
    arrUsersIdList.splice(j, 1);
    break;
   }
  }
 }
 
 //好友列表核对完毕。
 if (arrUsersIdList.length == 1 && arrUsersIdList[0] == userId)
 {
  //重新生成好友列表。
  var tempUserList = $("ChatUserList").value.split(';');
  var newUserListString = "";
  var exitUserName = "";
  var tempUserIdAndName;
  for (var i = 0;i < tempUserList.length;i++)
  {
   tempUserIdAndName = tempUserList[i].split(',');
   if (tempUserIdAndName[0] == userId)
   {
    exitUserName = tempUserIdAndName[1];
   }
   else
   {
    if (newUserListString == "")
    {
     newUserListString = tempUserList[i];
    }
    else
    {
     newUserListString += ";" + tempUserList[i];
    }
   }
  }
  
  $("ChatUserList").value = newUserListString;
  FillGroupUserList();
  AddUserExitChatMsg(exitUserName);
  
 }
 
}

function AddUserExitChatMsg(exitUserName)
{

 var msg = String.format(varMsg4, exitUserName);
 $("ChatContent").innerHTML += "<font style='font-size:13px;color:#636180;'>" + msg + "</font><br/>"
 $("ChatContent").doScroll();
}

function GetUsersIdFromUserList(userList)
{

 var userIdList = Array();
 
 for (var i = 0;i < userList.length;i++)
 {
  userIdList[i] = userList[i].split(',')[0];
 }
 
 return userIdList;
}

//设置页面上图片的路径,因为不能完全使用css来定位图片。
//多语的时候可能在同一个文件夹中,不同的图片。
function SetButtonImage()
{
 //先获取文件夹的虚拟路径。
 var cssFolderPath = cssStylePath.substring(0,cssStylePath.lastIndexOf("/"));
 
 //两个按钮的url。
 var sendButtonImageUrl = cssFolderPath + "/images/" + varSendButtonImageUrl;
 var exitButtonImageUrl = cssFolderPath + "/images/" + varExitButtonImageUrl;
 
 document.getElementById("sendButton").style.backgroundImage  = "url(" + sendButtonImageUrl + ")";
 document.getElementById("exitButton").style.backgroundImage  = "url(" + exitButtonImageUrl + ")";
}

 

var UPDATE_USERSTATE_REFRESHTIME = 2000;
var MESSAGE_ENNCRYPT_PASSWORD = "CE.Components.WebOnline";

var MONITOR_ID_SEPARATOR = "@CE-Online-070427-99@";
var MONITOR_MESSAGE_SEPARATOR_0 = "@CE-Online-070427-98@";
var MONITOR_MESSAGE_SEPARATOR_1 = "@CE-Online-070427-97@";
var MONITOR_MESSAGE_SEPARATOR_2 = "@CE-Online-070427-96@";
var MONITOR_MESSAGE_SEPARATOR_9 = "@CE-Online-070427-95@";
var FIND_USER_SEPARATOR = "@CE-Online-070427-88@";
var SEPARATOR = '^';
var SEPARATOR1 = "@CE-Online-070427-928@";
var AFFICHE_SPEED_TIME = 25;
var USER_ICON_SEPARATOR_0 = "@CE-Online-070427-94@";
var USER_ICON_SEPARATOR_1 = "@CE-Online-070427-93@";
var MESSAGE_SEPARATOR_0 = "@CE-Online-070427-00@"; //替代“|”符号。
var MESSAGE_SEPARATOR_1 = "@CE-Online-070427-01@"; //替代“$”符号。
var MESSAGE_SEPARATOR_2 = "@CE-Online-070427-02@"; //替代“,”符号。
var NO_WINDCHATUSER_ME = "@CE-Online-070427-03@"; //实例中没有自己时发送的消息。
var CHAT_TEXT_SPECIAL = "@CE-Online-070427-04@"; //用于剪贴板中特殊的定位字符。
var MOUSE_POINT = "@CE-Online-070427-05@"; //在获取光标的位置的时候插入定位的特殊字符。

 

 

//加密函数
function encrypt(str, pwd) {
  if(pwd == null || pwd.length <= 0) {   
    return null;
  }
  var prand = "";
  for(var i=0; i<pwd.length; i++) {
    prand += pwd.charCodeAt(i).toString();
  }
  var sPos = Math.floor(prand.length / 5);
  var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos*2) + prand.charAt(sPos*3) + prand.charAt(sPos*4) + prand.charAt(sPos*5));
  var incr = Math.ceil(pwd.length / 2);
  var modu = Math.pow(2, 31) - 1;
  if(mult < 2) {
    return null;
  }
  var salt = Math.round(Math.random() * 1000000000) % 100000000;
  prand += salt;
  while(prand.length > 10) {
    prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
  }
  prand = (mult * prand + incr) % modu;
  var enc_chr = "";
  var enc_str = "";
  str = escape(str);
  for(var i=0; i<str.length; i++) {
    enc_chr = parseInt(str.charCodeAt(i) ^ Math.floor((prand / modu) * 255));
    if(enc_chr < 16) {
      enc_str += "0" + enc_chr.toString(16);
    } else enc_str += enc_chr.toString(16);
    prand = (mult * prand + incr) % modu;
  }
  salt = salt.toString(16);
  while(salt.length < 8)salt = "0" + salt;
  enc_str += salt;
  return enc_str;
}
//解密函数
function decrypt(str, pwd) {
  if(str == null || str.length < 8) {
    return null;
  }
  if(pwd == null || pwd.length <= 0) {
    return null;
  }
  var prand = "";
  for(var i=0; i<pwd.length; i++) {
    prand += pwd.charCodeAt(i).toString();
  }
  var sPos = Math.floor(prand.length / 5);
  var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos*2) + prand.charAt(sPos*3) + prand.charAt(sPos*4) + prand.charAt(sPos*5));
  var incr = Math.round(pwd.length / 2);
  var modu = Math.pow(2, 31) - 1;
  var salt = parseInt(str.substring(str.length - 8, str.length), 16);
  str = str.substring(0, str.length - 8);
  prand += salt;
  while(prand.length > 10) {
    prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
  }
  prand = (mult * prand + incr) % modu;
  var enc_chr = "";
  var enc_str = "";
  for(var i=0; i<str.length; i+=2) {
    enc_chr = parseInt(parseInt(str.substring(i, i+2), 16) ^ Math.floor((prand / modu) * 255));
    enc_str += String.fromCharCode(enc_chr);
    prand = (mult * prand + incr) % modu;
  }
  enc_str = unescape(enc_str);
  return enc_str;
}

 

 

function encrypt(str, pwd) {
  if(pwd == null || pwd.length <= 0) {   
    return null;
  }
  var prand = "";
  for(var i=0; i<pwd.length; i++) {
    prand += pwd.charCodeAt(i).toString();
  }
  var sPos = Math.floor(prand.length / 5);
  var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos*2) + prand.charAt(sPos*3) + prand.charAt(sPos*4) + prand.charAt(sPos*5));
  var incr = Math.ceil(pwd.length / 2);
  var modu = Math.pow(2, 31) - 1;
  if(mult < 2) {
    return null;
  }
  var salt = Math.round(Math.random() * 1000000000) % 100000000;
  prand += salt;
  while(prand.length > 10) {
    prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
  }
  prand = (mult * prand + incr) % modu;
  var enc_chr = "";
  var enc_str = "";
  str = escape(str);
  for(var i=0; i<str.length; i++) {
    enc_chr = parseInt(str.charCodeAt(i) ^ Math.floor((prand / modu) * 255));
    if(enc_chr < 16) {
      enc_str += "0" + enc_chr.toString(16);
    } else enc_str += enc_chr.toString(16);
    prand = (mult * prand + incr) % modu;
  }
  salt = salt.toString(16);
  while(salt.length < 8)salt = "0" + salt;
  enc_str += salt;
  return enc_str;
}

function decrypt(str, pwd) {
  if(str == null || str.length < 8) {
    return null;
  }
  if(pwd == null || pwd.length <= 0) {
    return null;
  }
  var prand = "";
  for(var i=0; i<pwd.length; i++) {
    prand += pwd.charCodeAt(i).toString();
  }
  var sPos = Math.floor(prand.length / 5);
  var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos*2) + prand.charAt(sPos*3) + prand.charAt(sPos*4) + prand.charAt(sPos*5));
  var incr = Math.round(pwd.length / 2);
  var modu = Math.pow(2, 31) - 1;
  var salt = parseInt(str.substring(str.length - 8, str.length), 16);
  str = str.substring(0, str.length - 8);
  prand += salt;
  while(prand.length > 10) {
    prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
  }
  prand = (mult * prand + incr) % modu;
  var enc_chr = "";
  var enc_str = "";
  for(var i=0; i<str.length; i+=2) {
    enc_chr = parseInt(parseInt(str.substring(i, i+2), 16) ^ Math.floor((prand / modu) * 255));
    enc_str += String.fromCharCode(enc_chr);
    prand = (mult * prand + incr) % modu;
  }
  enc_str = unescape(enc_str);
  return enc_str;
}

 

 

 

//退出时调用自己页面服务器端方法删除用户。
function UserLogOut(resultR)
{

 if (isError)
 {
  return;
 }

 WM.closeAllWindow();
 IsClose=true;
 //先发otherChatUserList的下线通知。
 var userList = "";
 var userId = document.getElementById("txtSelfId").value;
 for (var key in otherChatUserList)
 {
  if (otherChatUserList[key] != null && otherChatUserList[key] != "")
  {
   if (userList == "")
   {
    userList = otherChatUserList[key].toString();
   }
   else
   {
    userList += "," + otherChatUserList[key].toString();
   }
  }
 }
 
 var xmlhttp1=createXMLHttpRequest();
 if(xmlhttp1==null)
 {
  alert(varAlert2);
  return;
 }
 var dataToSend = "userId=" + userId + "&userList=" + escape(userList);
 xmlhttp1.open("POST", "../online/IMSendLogoutMessageByUserList.aspx",false);
 xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 try
 {
  xmlhttp1.send(dataToSend);
 }
 catch(e)
 {
  alert(varAlert5);
  return;
 }

 var xmlhttp=createXMLHttpRequest();
 var dataToSend;
 if (resultR)
 {
  dataToSend = "GuestId=" + document.getElementById("txtSelfId").value + "&type=1";
 }
 else
 {
  dataToSend = "GuestId=" + document.getElementById("txtSelfId").value;
 }
 
 if(xmlhttp==null)
 {
  alert(varAlert2);
  return;
 }
 xmlhttp.open("POST", "../online/IMGuest.aspx",false);
 xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 try
 {
  xmlhttp.send(dataToSend);
 }
 catch(e)
 {
  alert(varAlert5);
  return;
 }
 
}

function sendMessage(userId)
{

 //最后次检查该用户时候在线。
 var sReturn;
 var dataToSend = "userId=" + userId;
 var xmlhttp=createXMLHttpRequest();
 if(xmlhttp==null)
 {
  alert(varAlert2);
  return;
 }
 xmlhttp.open("POST", "../online/GetUserIsOnline.aspx",true);
 xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 xmlhttp.onreadystatechange = function()
 {
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
  {
   sReturn = xmlhttp.responseText;
   
   if (sReturn == "true")
   {
    //查找或创建新聊天窗口。
    CreateChat(GetUserIdNames(userId)); 
   }
   else
   {
    if (confirm(varConfirm))
    {
     window.location = "IMUserLeaveWord.aspx?UserId=" + userId;
    }
    else
    {
     //window.location = "IMGuestStart.aspx";
    }
   }
  }
 }
 try
 {
  xmlhttp.send(dataToSend);
 }
 catch(e)
 {
  alert(varAlert5);
  return;
 }
}

function SetLocationUrl()
{
 window.location = "../OnLine/IMWarnPage.aspx?msg=" + escape(varMsg) + "&type=98";
}

var isAlert = false;
var ReLoginUrl = "IMGuestStart.aspx";

 

 

var IsClose=false;
var isError = false;

//除好友以外其他跟我聊过的用户。
//群聊时候可能发生这样的情况,即使不是好友也在一个群里面聊天。
//因为他可能是其他人邀请过来的好友。
//那么我们记录下他们,以便下线时跟他们发送下线信息。
var otherChatUserList = new Object();

function SetOtherChatUserList(user)
{

 var userList = user.split(',');

 if (userList != null && userList != "")
 {
  for (var i = 0;i < userList.length;i++)
  {
   if (otherChatUserList[userList[i]] == null)
   {
    otherChatUserList[userList[i]] = userList[i];
   }
  }
 }
}
  
function chatWindow()
{
    this.id="";
    this.userList="";    //格式:a,b,c
    this.target=null;
    this.winid = "";
    this.message = "";
}
//打开新窗口
chatWindow.prototype.windowOpen=function()
{
    var vID = document.getElementById('txtSelfId').value;
    this.target=window.open("../online/IMChat.aspx?SelfID=" + vID + "&id="+this.winid+"&UserList="+escape(this.userList),this.id,'width=435,height=305,top='+(screen.availHeight-305)/2+',left='+(screen.availWidth-435)/2+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=1');
    var firstMsg = document.getElementById('firstMessage');
    if(firstMsg)
    {
  firstMsg.value = this.message;
    }
}
//往窗口发送消息
chatWindow.prototype.send=function(msg)
{

    var result = true;
    try
    {
  var obje = this.target.window;
    }
    catch(e)
    {
  result = false;
    }
   
    if(result)
    {
  this.target.window.convertmsg(msg);
 }
    //}
    //catch(e)
    //{
        //this.windowOpen();
        //this.target.window.convertmsg(msg);
    //}
}
chatWindow.prototype.AddUser=function(userid)
{
    this.userList=this.userList+','+userid;
}
chatWindow.prototype.DelUser=function(userid)
{
    var suserList=','+this.userList+',';
    var suser=','+userid+',';
    this.userList=suserList.replace(suser,',');
    if(this.userList==',,')
    {
        this.userList='';
        //没有用户列表则关系窗口,删除当前对象
        WM.closeWindow(this.id);
    }
}


//聊天窗口
var windowID=1;
var WM=new WindowManage();
function WindowManage()
{
    this.WindowList=new Object();
}
WindowManage.prototype.createNewWindow=function(userlist,msg)
{
    var win=this.findWindowByUser(userlist)
    if(win==null)
    {
  var vID = document.getElementById('txtSelfId').value;
  var newwindow=new chatWindow();
  newwindow.id=parseInt(vID.toString() + windowID.toString());
  newwindow.winid = parseInt(windowID.toString());
  var winID=windowID.toString();
  windowID=windowID+1;
  newwindow.userList=userlist;
  newwindow.message = msg;
  newwindow.windowOpen();
  this.WindowList[winID]=newwindow;
  win=newwindow;
    }
    else
    {
        try
        {
        if(win.target==null)
        {
            win.windowOpen();
        }
        win.target.focus();
        }
        catch(e)
        {
            try
            {
                win.windowOpen();
                win.target.focus();
            }
            catch(e)
            {
            }
        }
    }
    return win;
}
//根据用户列表查找用户窗口
WindowManage.prototype.findWindowByUser=function(userlist)
{
        var win=null;
        for(var key in this.WindowList)
        {
            var w=this.WindowList[key];
            var list = w.userList
            var list1 = userlist;
           
            var result = false;
           
            if (list.length == list1.length)
            {
   var list1Temp = list1.split(';');
   
   for (var i = 0;i < list1Temp.length;i++)
   {
    list = list.replace(list1Temp[i],"")
   }
   
   list = list.replace(/;/g,"");
   
   if (list.length == 0)
   {
    result = true;
   }
            }
           
            if(result)
            {
   win=w;
   break;
            }
        }
        return win;
}
//根据用户查询用户窗口列表
WindowManage.prototype.findWindowByOneUser=function(user)
{
        var winlist=null;
        for(var key in this.WindowList)
        {
            var w=this.WindowList[key];
           
            //获取好友列表。
            var userList = w.userList.split(';');
           
            for (var i = 0;i < userList.length;i++)
            {
   if (userList[i] != null && userList[i] != "")
   {
    if (user == userList[i].split(',')[0])
    {
    
     if (winlist == null)
     {
      winlist = new Object();
     }
    
     winlist[w.id] = w;
     break;
    }
   }
            }
           
            /*
            var suser=','+w.userList+',';
            var finduser=','+user+',';
            if(suser.indexOf(finduser)>0)
            {
                winlist[w.id]=w;
            }*/
           
        }
        return winlist;
}
//根据窗口id查询用户窗口
WindowManage.prototype.findWindow=function(id)
{
   
    var win=null;
        for(var key in this.WindowList)
        {
            var w=this.WindowList[key];
            if(w.id==id)
            {
                win=w;
                break;
            }
        }
        return win;
}
WindowManage.prototype.changeWindowID=function(oldID,newID)
{
    var oldWindow=this.findWindow(oldID);
    if(oldWindow==null)
    {
        alert(varAlert1);
    }
    else
    {
        delete this.WindowList[oldID];
        this.WindowList[newID]=oldWindow;
        oldWindow.id=newID;
    }
}
WindowManage.prototype.closeWindow=function(id)
{
    var objwindow=this.findWindow(id.toString());
    if(objwindow!=null)
    {
        delete this.WindowList[id.toString()];
       
        try
        {                   
   objwindow.target.close();
  }
  catch(e)
  {}
        objwindow.target=null;
        objwindow=null;
    }
}
WindowManage.prototype.closeAllWindow=function()
{
    for(var key in this.WindowList)
    {
        var win=this.WindowList[key];
        //直接这里管了。
        if (win != null)
        {
   delete this.WindowList[key];
   
   try
   {
    win.target.close();
   }
   catch(e){}
   win = null;
        }
       
        //this.closeWindow(win.id);
    }
}
WindowManage.prototype.RemoveWindowObject=function(id)
{
 
 for(var objwindow in this.WindowList)
 {
  if(objwindow.id == id.toString())
  {
   delete this.WindowList[id.toString()];
   objwindow=null;
  }
 }
 
}

//刷新时间2秒
function refresh()
{  
 try
 { 
  RequestPageMessage();
 }
 catch(e)
 {}
 if(IsClose==false)
 {
  setTimeout( "refresh()" , document.getElementById("refreshTime").value );
 }
}

//xmlhttp获取消息
function RequestPageMessage()
{
 var xmlhttp=createXMLHttpRequest();
 if(xmlhttp==null)
 {
  alert(varAlert2);
  return;
 }
 var sSelfID=document.getElementById('txtSelfID').value;
 var dataToSend = "UserID=" + sSelfID;
 xmlhttp.open("POST", "../online/IMMessage.aspx",false);
 xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 xmlhttp.onreadystatechange = function()
 {
   
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
  {
  
   //更新访问成功的时间。
   lastConnectionTime = getConnectionTime();
   
   if(xmlhttp.responseText!="")
   {
    if (xmlhttp.responseText != NO_WINDCHATUSER_ME)
    {
     ConvertMessage( xmlhttp.responseText);
    }
    else
    {
     IsClose = true;
     if (isAlert)
     {
      alert(varAlert3);
     }
     isError = true;
     window.location = ReLoginUrl;
    }
   }
  }
   
   
 }
 try
 {
  xmlhttp.send(dataToSend);
 }
 catch(e)
 {
  return;
 }
}

var lastConnectionTime = 0;

function getConnectionTime()
{
 var d = new Date();
 var time;
 var month;
 var day;
 var hours;
 var minutes;
 var seconds;
 
 time = d.getFullYear();
 month = d.getMonth() + 1;
 if (month.toString().length == 1)
 {
  month = "0" + month.toString();
 }
 time = time + month.toString();
 
 day = d.getDate();
 if (day.toString().length == 1)
 {
  day = "0" + day.toString();
 }
 time = time + day.toString();
 
 hours = d.getHours();
 if (hours.toString().length == 1)
 {
  hours = "0" + hours.toString();
 }
 time = time + hours.toString();
 
 minutes = d.getMinutes();
 if (minutes.toString().length == 1)
 {
  minutes = "0" + minutes.toString();
 }
 time = time + minutes.toString();
 
 seconds = d.getSeconds();
 if (seconds.toString().length == 1)
 {
  seconds = "0" + seconds.toString();
 }
 time = time + seconds.toString();
 
 return time;
 
  }


var isForceOut = false;
function ConvertMessage(sMessage)
{
 //聊天窗口接收消息:用户ID|用户状态0可用1不可用-1其它禁用|消息类型:子窗口消息sub|消息标识:接收消息|子窗口标识|窗口人员列表|消息内容:消息内容$
 var objMsgArray=sMessage.split(MESSAGE_SEPARATOR_1);
 for(var i=0;i<objMsgArray.length;i++)
 {
  var objArray=objMsgArray[i].toString().split(MESSAGE_SEPARATOR_0);
  if(objArray.length<4)
  {
   alert(varAlert4);
   return;
  }
  
  //好友下线
  if(objArray[3].toString()=="WM_ChatUserOut")
  {
   var winlist=WM.findWindowByOneUser(objArray[4].toString());
   for(var key in winlist)
   {
    var win=winlist[key];
    if(win!=null && win.target != null)
    {
     try
     {
      //向自己发送好友离线通知。
      win.target.LoguotMessage(objArray[4]);
      
      //叫该页面自己去掉这个下线的用户。
      if(win.target.DelUserList(objArray[4]))
      {
       //该页面自己刷新好友列表。
       win.target.FillGroupUserList();
       
       //给群聊中的其他好友发送下线信息。
       //win.target.SendUserLogoutMessage(objArray[4]);
      }
     }
     catch(e)
     {}
    }
    
   }
  }
  
  //被强制下线
  if(objArray[3].toString()=="WM_ChatUserForceOut")
  {
   isForceOut = true;
   IsClose=true;
   window.UserLogOut(true);
   SetLocationUrl();
  }
  
  // 子窗口消息
  if(objArray[2].toString()=="sub")
  {
   //聊天窗口接收消息
   if(objArray[3].toString()=="WM_ChatSendMessage")
   {
    try
    {
    
     var winID = parseInt(objArray[0].toString() + objArray[4].toString());
     //var winID = objArray[0].toString() + "," + objArray[5].toString();
     var win=WM.findWindow(winID);
     var RecUserIDs = objArray[5].toString();//.replace(document.getElementById('txtUserID').value,"");
     RecUserIDs = RecUserIDs.replace(",,",",");
     if(RecUserIDs.substr(RecUserIDs.length - 1) == ",")
     {
      RecUserIDs = RecUserIDs.substr(0,RecUserIDs.length - 1);
     }
     //alert("back userid =" + RecUserIDs);
     var RecUserIDNames = GetUserIdNames(RecUserIDs);
     
     //var passUserIDs = objMsgArray[i].replace(objArray[5].toString(),RecUserIDNames);
     var passUserIDs = "";
     var passUserIDsTemp = objMsgArray[i].split(MESSAGE_SEPARATOR_0);
     passUserIDsTemp[5] = RecUserIDNames;
     
     for(var l = 0;l<passUserIDsTemp.length;l++)
     {
      if(passUserIDs == "")
      {
       passUserIDs = passUserIDsTemp[l];
      }
      else
      {
       passUserIDs += MESSAGE_SEPARATOR_0 + passUserIDsTemp[l];
      }
     }
     
     var result = true;
     
     if(win == null || WM.findWindowByUser(RecUserIDNames) == null)
     {
      result = false;
     }
     else
     {
      try
      {
       win = WM.findWindowByUser(RecUserIDNames);
       var obj = win.target.window;
      }
      catch(e)
      {
       result = false;
       WM.RemoveWindowObject(winID);
      }
     }
     
     if(result)
     {
      try
      {
       win.userList = RecUserIDNames;
       win.send(passUserIDs);
      }
      catch(e)
      {}
     }
     else
     {
      try
      {
       var winID = parseInt(objArray[0].toString() + objArray[4].toString());
       //var winID = objArray[0].toString() + "," + objArray[5].toString();
       //var RecUserIDs = objArray[5].toString().replace(document.getElementById('txtSelfId').value + ",","");
       //var RecUserIDNames = GetUserIdNames(RecUserIDs);
       var win= WM.createNewWindow(RecUserIDNames,passUserIDs);
       WM.changeWindowID(win.id,winID.toString());
       //win.send(passUserIDs);//objMsgArray[i].toString()
       
       
       ////////////////////////////////////////////////////////////////
       //修改内容:修改当没聊天窗口时的消息发送方式,原来修改的发送方式
       //   是如果没把窗口open出来就重复的发,但这样处理如果同时
       //   有多条显示,那么就可以丢失信息。
       //   现在修改为,如果没有这个窗体,就open这个窗体,然后主
       //   页面把未处理排队状态下的消息重新组装。然后调用聊天子
       //   窗口(IMChat.aspx)中的方法,并且把新组装的消息链发
       //   过去,由IMChat.aspx来对自己重发消息。
       //修改人:蔡芃
       //修改时间:2007-5-11 10:15:30
       ////////////////////////////////////////////////////////////////
       //parmPassUserIDs = passUserIDs;
       
       //组装未处理的消息
       var parmPassUserIDs = "";
       
       for(var count = i;count<objMsgArray.length;count++)
       {
        if(parmPassUserIDs == "")
        {
         parmPassUserIDs = objMsgArray[count];
        }
        else
        {
         parmPassUserIDs += MESSAGE_SEPARATOR_1 +objMsgArray[count];
        }
       }
       Resend(win, parmPassUserIDs);
       break;
      }
      catch(e)
      {
       alert(e.message);
       
       //alert(e);
       //if(win != null)
       //{
        //WM.changeWindowID(win.id,winID.toString());
        //win.send(passUserIDs);
       //}
       //else
       //{
        //var win= WM.createNewWindow(RecUserIDNames);  
        //WM.changeWindowID(win.id,winID.toString());
        //win.send(passUserIDs);
       //}
      }
     }
    }
    catch(e)
    {
     //var winID = parseInt(objArray[0].toString() + objArray[4].toString());
     //var RecUserIDs = objArray[5].toString().replace(document.getElementById('txtUserID').value + ",","");
     //var RecUserIDNames = GetUserIdNames(RecUserIDs);
     //var win= WM.createNewWindow(RecUserIDNames,passUserIDs);  
     //WM.changeWindowID(win.id,winID.toString());
     //win.send(passUserIDs);
    }
   }
  }
 }
}

function Resend(win, message)
{
 try
 {
  //win.send(message);
  //先发给新窗体,再又新状态转发,这样可以确定,新窗体里面open成功。
  var id = document.getElementById("txtSelfId").value;
  win.target.window.SetUserId(id);
  win.target.window.ReSendMessage(message);
 }
 catch(e)
 {
  setTimeout(function(){Resend(win,message)},2000);
 }
}

var objWinCreateChat;
function CreateChat(userid)
{
 objWinCreateChat=WM.createNewWindow(userid,"");
 //CreateChatuserid = userid;
 SetUid();
}

function SetUid()
{
 try
 {
  var id = document.getElementById("txtSelfId").value;
  objWinCreateChat.target.window.SetUserId(id);
 }
 catch(e)
 {
  setTimeout("SetUid()",2000);
 }
 
}

//获得用户ID和用户名的字符串
function GetUserIdNames(groupUserIDs)
{
    var sReturn;
    var dataToSend = "userId=" + document.getElementById("txtSelfId").value + "&GroupUserIDs=" + groupUserIDs;
    var xmlhttp=createXMLHttpRequest();
 if(xmlhttp==null)
 {
  alert(varAlert2);
  return;
 }
 xmlhttp.open("POST", "../online/IMGetUserIDNames.aspx",false);
 xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 xmlhttp.onreadystatechange = function()
 {
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
  {
   sReturn=xmlhttp.responseText;
  }
  else
  {
   sReturn = "";
  }
 }
 try
 {
  xmlhttp.send(dataToSend);
 }
 catch(e)
 {
  alert(varAlert5);
  return;
 }
 return sReturn;
}

function ChangeUserList(obj, newUserList)
{
 for(var key in WM.WindowList)
 {
  var w=WM.WindowList[key];
  
  if (w.target == obj)
  {
   w.userList = newUserList;
   break;
  }
 }
}

function RemoveWindow(obj)
{
 for(var key in WM.WindowList)
 {
  var w=WM.WindowList[key];
  
  if (w.target == obj)
  {
   WM.RemoveWindowObject(w.id);
   break;
  }
 }
}


function ScanConnection()
{
 try
 {
  CheckedConnection();
 }
 catch(e){}
 if(IsClose==false)
 {
  setTimeout( "ScanConnection()" , document.getElementById("checkedTime").value );
 }
}

function CheckedConnection()
{
 if (lastConnectionTime != 0)
 {
  var currentTime = getConnectionTime();
  var spanTime = document.getElementById("connTime").value;

  if (currentTime - lastConnectionTime > spanTime)
  {
   alert(varAlert6);
   window.close();
  }
 }
}

文件名:OnLineAdminEdit.js
// 文件功能描述:客服资料修改页的JS操作
//
// 创建标识:简相辉20070516
//
//
//----------------------------------------------------------------

var popedomwindow = null;

function ToSetPopedom(userid)
{
 var popedom = document.getElementById("hdnPopedom").value;
 var url = "OnLinePopedom.aspx?userid=" + userid + "&popedom=" + popedom;
 
 if (popedomwindow == null)
 {
  popedomwindow = window.showModelessDialog(url,window);
 }
 else
 {
   try
        {
            popedomwindow.focus();
        }
        catch (e)
        {
            popedomwindow = window.showModelessDialog(url,window);
        }
 }
 //,"_blank","titlebar=no,width=450,height=600,left=250,top=20"
 return false;
}

window.onunload = function()
{
 try
 {
  popedomwindow.close();
 }
 catch (e){}
}

/// <summary>
/// 验证密码
/// </summary>
function ComparePassword()
{
 var ctrl = document.getElementById("txtPassword");
 
 if (ValidateTools.prototype.Trim(ctrl.value) !=
  ValidateTools.prototype.Trim(document.getElementById("txtPassword2").value))
 {
  alert("密码校验失败,请重新输入密码。");
  ctrl.focus();
  ctrl.select();
 
  return false;
 }
 
 return true;
}

 

 

文件功能描述:客服列表页使用的JS操作
//
// 创建标识:简相辉20070510
//
//
//----------------------------------------------------------------

/// <summary>
/// 查看管理员详细信息
/// </summary>
function ToAdminDetail(userid,state)
{
 window.open("OnLineAdminDetail.aspx?userid=" + userid + "&state=" + state + "&random=" + Math.random(),"_self");
 return false;
}

/// <summary>
/// 查看管理员详细信息
/// </summary>
function ToEdit(userid,state)
{
 window.open("OnLineAdminEdit.aspx?userid=" + userid + "&state=" + state,"_self");
 return false;
}

/// <summary>
/// 做操作必须先选择用户
/// </summary>
function CheckUsers(message)
{
 var users = document.getElementById("hdnSelected").value;
 
 if (users == "" || users == ",")
 {
  alert(txtSelect);//必须选择至少一个用户才能进行操作
  return false;
 }
 
 if (message != '')
 {
  return window.confirm(message);
 }
 
 return true;
}

/// <summary>
/// 选中/取消选中所有用户
/// </summary>
/// <param name="tableid">显示用户列表的表格</param>
function SelectAllUser(tableid)
{
 //选中/取消当前画面所有
 var table = document.getElementById(tableid);
 var chkbox;
 var userid;
 var index = table.childNodes[0].childNodes[0].childNodes.length - 1;
 
 var isAll = table.childNodes[0].childNodes[0].childNodes[0].childNodes[0].checked;
 
 for (var i = 1; i < table.childNodes[0].childNodes.length; i++)
 {
  chkbox = table.childNodes[0].childNodes[i].childNodes[0].childNodes[0];
  chkbox.checked = isAll;
  
  userid = table.childNodes[0].childNodes[i].childNodes[index].innerText;
  
  if (isAll)
  {
   AddUser(userid);
  }
  else
  {
   DeleteUser(userid);
  }
 }
}

/// <summary>
/// 检查是否全选了
/// </summary>
/// <param name="table">用户列表控件</param>
function IsAll(table)
{
 var checked = true;
 for (var i = 1; i < table.childNodes[0].childNodes.length; i++)
 {
  checked = table.childNodes[0].childNodes[i].childNodes[0].childNodes[0].checked;
  
  if (!checked)
  {
   break;
  }
  
 }
 
 table.childNodes[0].childNodes[0].childNodes[0].childNodes[0].checked = checked;
}

/// <summary>
/// 在选择列表中增加一个用户
/// </summary>
/// <param name="userid">操作的用户ID</param>
function AddUser(userid)
{
 var selected = document.getElementById("hdnSelected");
 var users = selected.value;
 
 var element = userid + ",";
 
 if (users.indexOf("," + element) < 0)
 {
  if (users == "") users = ",";
  users +=  element;
  
  selected.value = users;
 }
}

/// <summary>
/// 从选择列表中删除一个用户
/// </summary>
/// <param name="userid">操作的用户ID</param>
function DeleteUser(userid)
{
 var selected = document.getElementById("hdnSelected");
 var users = selected.value;
 var element = userid + ",";
 
 users = users.replace(element,"");
 
 selected.value = users;
}

/// <summary>
/// 选中/取消选中某个用户
/// </summary>
/// <param name="userid">操作的用户ID</param>
/// <param name="tableid">全选框ID</param>
function SelectedUser(sender,userid,allSelect)
{
 if (sender.checked)
 {
  AddUser(userid);
  IsAll(sender.parentElement.parentElement.parentElement.parentElement);
 }
 else
 {
  DeleteUser(userid);
  document.getElementById(allSelect).checked = false;
 }
}

/// <summary>
/// 检查跳转页索引合法性
/// </summary>
/*
function CheckIndex()
{
 var maxValue = document.getElementById("lblPages").innerText;
 var validater = new Validater(true);
 return validater.Validate("txtGoTo","E/N/V","页数",-1,-1,-1,maxValue,1);
}*/


 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:299611次
    • 积分:5751
    • 等级:
    • 排名:第4481名
    • 原创:267篇
    • 转载:5篇
    • 译文:0篇
    • 评论:21条
    文章分类
    最新评论