var xmlHttp = false;
var xmlHttp1 = false;
var IsSendWord=0;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
xmlHttp1 = false;
}
} 

function callServer(theman,themsg) {
var url = "../sayinfo/send.asp?man="+theman+"&msg=" + escape(themsg);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}

function updatePage() {
if (xmlHttp.readyState == 4) {
   var response = xmlHttp.responseText;
   message.document.getElementById("saying").innerHTML=message.document.getElementById("saying").innerHTML+response;
   ScrollWindow();
}
}

function issend(){
var sayword= document.getElementById("sendmsg").value;
var man= document.getElementById("man").value;
if(sayword=="" || sayword=="请输入内容"){
   alert("请输入你要发送的话!");
   document.getElementById("sendmsg").focus();
   return false;
}

if(IsSendWord==0 && man=="turan"){
   getchat();
}

IsSendWord=1;

callServer(man,sayword);
document.getElementById("sendmsg").value="";
document.getElementById("sendmsg").focus();
}

function iscls(){
  message.document.getElementById("saying").innerHTML="";
  document.getElementById("sendmsg").focus();
}

function keysend(){
if(event.keyCode==13){issend();}
}

function ScrollWindow()
{
  message.scroll(0,5000); 
}

function selectit(theuid){
  document.getElementById("userid").value=theuid;
}

function quit() {
var url = "../sayinfo/logout.asp";
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = quitPage;
xmlHttp.send(null);
}

function quitPage() {
if (xmlHttp.readyState == 4) {window.close();}
}


function onlineuser(){
var url = "../sayinfo/logon.asp?tm="+partime();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = onlinePage;
xmlHttp.send(null);
}

function onlinePage() {
if (xmlHttp.readyState == 4) {
   var userresponse = xmlHttp.responseText;
   document.getElementById("userinfo").innerHTML=userresponse;
}
}

function getchat(){
var url = "../sayinfo/getchat.asp?tm="+partime();
xmlHttp1.open("GET", url, true);
xmlHttp1.onreadystatechange = chatPage;
xmlHttp1.send(null);
setTimeout("getchat()",1000);
}

function chatPage() {
if (xmlHttp1.readyState == 4) {
   var response = xmlHttp1.responseText;
   if(response!=""){
   message.document.getElementById("saying").innerHTML=message.document.getElementById("saying").innerHTML+response;
   ScrollWindow();
   self.focus();}
}
}

function partime(){
today=new Date();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
var thetime=hours+"-"+minutes+"-"+seconds;
return thetime;
}
