var GetChaturl = "script/get_data.php";
window.onload = initJavaScript;

function initJavaScript() {
	//document.forms['chatForm'].elements['chatbarText'].setAttribute('autocomplete','off'); //this non standard attribute prevents firefox' autofill function to clash with this script
	//checkStatus('');
	//checkName();
	receiveChatText();
	//getPrivate();
}

function receiveChatText() {
	if (httpReceiveChat.readyState == 4 || httpReceiveChat.readyState == 0) {
		httpReceiveChat.open("GET",GetChaturl + '?location_id=4'  + '&rand='+Math.floor(Math.random() * 1000000), true);
		httpReceiveChat.onreadystatechange = handlehHttpReceiveChat; 
		httpReceiveChat.send(null);
	}
}

function handlehHttpReceiveChat() {
	if (httpReceiveChat.readyState == 4) {
		/*
		results = httpReceiveChat.responseText.split('---');
		if (results.length > 2) {
			for(i=0;i < (results.length-1);i=i+3) {
				insertNewContent(results[i+1],results[i+2]);
			}
			lastID = results[results.length-4];
		}
		setTimeout('receiveChatText();',4000);*/
		insertNewContent(httpReceiveChat.responseText);
	}
}

function insertNewContent(url) {
	if (url.length>716) document.getElementById('ad_tabla').style.display="";
	document.getElementById('ad_magnetx').innerHTML = document.getElementById('ad_magnetx').innerHTML  + url;
	var objDiv = document.getElementById('ad_magnetx');
	objDiv.scrollTop = objDiv.scrollHeight;
}

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

var httpReceiveChat = getHTTPObject();
