
var myChatWindow;
function open_chat(ori,src){
    url = "/index.php?inc=chat&src="+src;
    w = 780;
    h = 470;
	if (myChatWindow!=null && !myChatWindow.closed){
	    myChatWindow.close();
	}
    var options;
    options = "resizable=no,toolbar=0,status=0,menubar=0,scrollbars=0, width=" + w + ",height=" + h + ",left="+(screen.width-w)/2+",top="+(screen.height-h)/6; 
    myChatWindow = window.open("","myChatWindow"+ori,options);
    myChatWindow.location = url;
    myChatWindow.focus();
}

chat_piscando = 0;
chat_origem = "0";
chat_timeout = 10000;
chat_time=0;
//cnt = 0;
function chaton(x,des){
  obj = document.getElementById("chaton");
  if (x) {
      obj.innerHTML = '<center><a title="Usuário chamando!" href="javascript:chaton_click('+"'"+des+"'"+')"><span class=title_3>Chat</span><br><img border=0 src="'+chat_icon+'"></a>';
      if (!chat_piscando){
          window.focus();
      }
      chat_piscando = 1;
  } else {
      //cnt++;
      //obj.innerHTML = cnt;
      if (chat_piscando){
          obj.innerHTML = '';
          chat_piscando = 0;
      }
  }
}
function chaton_start(ori,path){
   chat_origem = ori;
   chat_path = path+'/index.php';
   chat_icon = path+'/kit/images/btn/call_14.gif';
   chat_time = setTimeout('chaton_load()', 1000);
   document.write('<div id=chaton class=text_1 style="text-align:center;width:30px;"></div>');
}
function chaton_click(des){
  obj = document.getElementById("chaton");
  obj.innerHTML = '';
  chat_piscando = 0;
  open_chat(chat_origem,des);
}
function chaton_load(){
   try {
        par = 'inc=chaton&ori='+chat_origem.toString();
        makeRequest(chat_path,'post', par, 'chaton_eval');
   } catch(err) {
            txt="\nErro: " + err.description + "\n";
            alert(txt);
   }
  tchaton = setTimeout('chaton_load()', chat_timeout);
}
function chaton_eval(httpRequest){
   try {
       x = httpRequest.responseText;
       eval(x);
   }
   catch(err) {
          txt="\nErro: " + err.description + "\n" + httpRequest.responseText + "\n";
          alert(txt);
   }
   finally {
       httpRequest.Free;
   }
}
    