var AjaxStarted = false;
var AjaxFIFO = new Array();

function BannersAjaxInit() {
	var ajax_obj = false;
	/* Create a new XMLHttpRequest object to talk to the Web server */
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try {
		ajax_obj = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			ajax_obj = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			ajax_obj = false;
		}
	}
	@end @*/

	if (!ajax_obj && typeof XMLHttpRequest != 'undefined') {
		ajax_obj = new XMLHttpRequest();
	}
	
	return ajax_obj;
}	

function AjaxReq (url, target) {
	xml_http = BannersAjaxInit();
	xml_http.open("GET", url, true);
	xml_http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xml_http.send(null);
	xml_http.onreadystatechange = function () {
		
		if (xml_http.readyState == 4) {
			if (xml_http.status == 200) {
				text = xml_http.responseText;
				document.getElementById(target).innerHTML = text;
				doAjaxFIFO();
			}
		}
	}

}

function AjaxEval (url) {
	xml_http = BannersAjaxInit();
	xml_http.open("GET", url, true);
	xml_http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xml_http.send(null);
	xml_http.onreadystatechange = function () {
		
		if (xml_http.readyState == 4) {
			if (xml_http.status == 200) {
				eval(xml_http.responseText);

				doAjaxFIFO();
			}
		}
	}
	
}

function click (id) {
	AjaxEval("frame.php?page=bzone_banners&do=click&id="+id);
}

function addToAjaxFIFO (ev) {
	AjaxFIFO.push(ev);
}

function doAjaxFIFO() {

	if (AjaxFIFO.length > 0) {
		expr = AjaxFIFO.shift();
		eval(expr);
	} else {
		AjaxStarted = false;
	}
}

function changeBlock(url, target) {
	xml_http = BannersAjaxInit();
	xml_http.open("GET", url, true);
	xml_http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xml_http.send(null);
	xml_http.onreadystatechange = function () {
		if (xml_http.readyState == 4) {
			if (xml_http.status == 200) {
				text = xml_http.responseText;
				document.getElementById(target).innerHTML = text;
				document.getElementById('body').scrollIntoView();
				doAjaxFIFO();
			}
		}
	}
}