//最小化层
function smallDiv() {
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.smallDiv();
  proxy=null;
}

function minimize(node) {
  node.parentNode.parentNode.className = 'presence_bar_section';

}
function hoverButton(node) {
  node.className = 'presence_bar_button hover';
}

function outButton(node) {
  node.className = 'presence_bar_button';

}

var sign=0;//为0时执行onlineChatButton，为1时不执行

//关闭在线聊天
function closeTab() {
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.closeTab();
  proxy=null;
}
//打开全屏聊天
function openBigChat() {
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.openBigChat();
  proxy=null;
}
//打开新的聊天窗口
function talk(str,type)
{
  if(str>0)
  {
    var proxy = document.getElementById("imengine").contentWindow;
    proxy.talkwith(str);
    proxy=null;
  }
  else
  {
    var proxy = document.getElementById("imengine").contentWindow;
    proxy.talkbefor(str,type);
    proxy=null;
  }
}

//变换是圈聊还是私聊
function switchChat(node) {
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.switchChat(node);
  proxy=null;
}
//变换聊天好友
function changChatUser(uid) {
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.changChatUser(uid);
  proxy=null;
}
//变换圈聊圈子
function changChatGroup(uid) {
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.changChatGroup(uid);
  proxy=null;
}
//上一页，下一页--------私聊
function priUpDownUsers(tag)
{
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.priUpDownUsers(tag);
  proxy=null;
}
//上一页，下一页----------圈子
function priUpDownGroups(tag)
{
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.priUpDownGroups(tag);
  proxy=null;
}


function imFindFriendUsers()//搜------私聊
{
  if(document.getElementById("imfindUsers").value.replace(/\s/gi,"")!="")
  {
    var proxy = document.getElementById("imengine").contentWindow;
    proxy.imFindFriendUsers(document.getElementById("imfindUsers").value);
    proxy=null;
  }
}
function imFindFriendGroups()//搜---------圈子聊
{
  if(document.getElementById("imfindGroups").value.replace(/\s/gi,"")!="")
  {
    var proxy = document.getElementById("imengine").contentWindow;
    proxy.imFindFriendGroups(document.getElementById("imfindGroups").value);
    proxy=null;
  }
}

function goToHeadUsers()//首页----私聊
{
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.goToHeadUsers();
  proxy=null;
}

function goToHeadGroups()//首页----圈子
{
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.goToHeadGroups();
  proxy=null;
}
function showFace()//显示表情
{
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.showFace();
  proxy=null;
}
function kickChatUser(userids)//踢人
{
  var proxy = document.getElementById("imengine").contentWindow;
  proxy.kickChatUser(userids);
  proxy=null;
}
function writeChatFace(str)
{
  var remark = document.getElementById("remark");
  if(remark)
  {
    remark.value+=str;
    remark.focus();
  }
  remark=null;
  var chatemotions=document.getElementById('chat_emotions');
  if(chatemotions)
  {
    chatemotions.style.display='none';
  }
  chatemotions=null;
}
//新的==================================有点是要的===============================================================
document.onkeydown=function(event)
{
  e = event ? event :(window.event ? window.event : null);
  if(e.keyCode==13)
  {
    //发言
    var proxy = document.getElementById("imengine").contentWindow;
    proxy.sendWords();
    //查找-----------私聊
    if(document.getElementById("imfindUsers"))
    {
      if(document.getElementById("imfindUsers").value.replace(/\s/gi,"")!="")
      {
        proxy.imFindFriendUsers(document.getElementById("imfindUsers").value);
      }
    }
    //查找------------圈子 聊
    if(document.getElementById("imfindGroups"))
    {
      if(document.getElementById("imfindGroups").value.replace(/\s/gi,"")!="")
      {
        proxy.imFindFriendGroups(document.getElementById("imfindGroups").value);
      }
    }
    proxy=null;
  }
}
//新的=================================================================================================
function resizeChatList() {
	var availableWidth = document.documentElement.clientWidth - 324;
	var tabsWidth = document.getElementById('chatuserlist').childNodes.length * 129;
	//alert(availableWidth + '+' + tabsWidth);
	if(tabsWidth < availableWidth) {
		document.getElementById('chatuserlist').style.width = tabsWidth + 'px';
		document.getElementById('chat_modules').style.width = tabsWidth + 'px';
	} else {
		document.getElementById('chat_modules').style.width = tabsWidth + 48 +'px';
		document.getElementById('chat_modules').childNodes[0].style.display = 'block';
		document.getElementById('chat_modules').childNodes[1].style.display = 'block';
		var showTabsNum = availableWidth / 129;
		document.getElementById('chatuserlist').style.width = tabsWidth + 'px';
	}
}
document.onresize="resizeChatList();";
