var xmlHttp = false, xmlHttp2 = false;

try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}


if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
  xmlHttp2 = new XMLHttpRequest();
}


function callServer() {
	setTimeout ( "callServer()", 3000 ); 
	var url = "ChatText_Client.asp";
	xmlHttp.open('GET', url, true);
	xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);
}

function sendText() {
	var user = document.getElementById("user").value;
	var texto = document.getElementById("texto").value;
	var url = "ChatInsert_Client.asp?user=" + user + "&texto=" + texto;
	xmlHttp2.open('GET', url, true);
	xmlHttp2.send(null);
	document.getElementById("texto").value = '';
	document.getElementById("texto").focus();
}

function updatePage() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    document.getElementById("TEXT").innerHTML = response;
  }
}