//Ceres Control Panel
//.js Ceres ajax-engine

function LINK_ajax(http, div_name) { //função para links

	var LINK_xmlhttp = false;

	try { LINK_xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
	catch (e) { try { LINK_xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch (e) { try { LINK_xmlhttp = new XMLHttpRequest(); }
	catch (e) { LINK_xmlhttp = false; }}}
	if (!LINK_xmlhttp) return null;
	
	document.getElementById('load_div').style.visibility="visible";

	LINK_xmlhttp.open("GET", http, true);

	LINK_xmlhttp.onreadystatechange = function() {
		if (LINK_xmlhttp.readyState == 4) {
			document.getElementById('load_div').style.visibility="hidden";

			if (LINK_xmlhttp.responseText.indexOf("<script type=\"text/javascript\">") > -1) {
				var x = LINK_xmlhttp.responseText.indexOf("<script type=\"text/javascript\">") + "<script type=\"text/javascript\">".length;
				var y = LINK_xmlhttp.responseText.indexOf("</script>") - x;
				eval(LINK_xmlhttp.responseText.substr(x, y));
			}

			if (LINK_xmlhttp.responseText.indexOf('ALERT|') > -1) 
				window.alert(LINK_xmlhttp.responseText.substr(LINK_xmlhttp.responseText.indexOf('|') + 1));
			else
				document.getElementById(div_name).innerHTML = LINK_xmlhttp.responseText + ' ';
		}
	}

	LINK_xmlhttp.send(null);  

	return false;
}

function server_status() {
	LINK_ajax('server_status.php','status_div');

	setTimeout("server_status()", 120000);
}
