var xml_http = ajax_object();

function error(message) {

	// document.getElementById("error").innerHTML = "Error:" + message;

}

function ajax_object() {

	var xml_http;
	
	try {
	
		xml_http = new XMLHttpRequest();
	
	} catch(e) {
	
		var xml_http_versions = new Array('MSXML2.XMLHTTP.6.0', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
		
		for (var i = 0; i < xml_http_versions.length && !xml_http; i++) {
	
			try {
			
				xml_http = new ActiveXObject(xml_http_versions[i]);
			
			} catch (e) {
			
			}
		
		}
	
	}
	
	if (!xml_http) {
	
		error("XMLHttpRequest instance could not be made!");
		
	} else {
	
		return xml_http;
	
	}
	
}

function ajax_get(url) {

	if (xml_http) {
	
		try {
		
			url = url + "&time=" + new Date().getTime();		
			xml_http.open("GET", url, true);
			xml_http.onreadystatechange = ajax_state_change;
			xml_http.send(null);
		
		} catch (e) {
					
			error("Could not connect to server");
		
		}
	
	}

}

function ajax_state_change() {

	if (xml_http.readyState == 4) {
	
		if (xml_http.status == 200) {
		
			try {
					
				ajax_response(xml_http.responseText);
			
			} catch(e) {
							
				error("Could not read response");
			
			}
		
		} else {
			
			error("Could not retrieve date");
		
		}
	
	}

}

function ajax_response(str){
	
	str = str.split(",");

	document.getElementById("ban_requests").innerHTML = str[0];
	document.getElementById("server_connections").innerHTML = str[1];
	
}

function ajax_request() {
	
	ajax_get('ajax_sources/counters.php?');
	
	setTimeout("ajax_request();", 30000);
	
}
