var AjaxStarted = false;
var AjaxFIFO = new Array();

function AjaxInit() {
	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, ext_block) {
	ext_block = ext_block || null;
	xml_http = AjaxInit();
	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;
				if (text) {
					document.getElementById(target).style.display = 'block';
					if (ext_block)
						document.getElementById(ext_block).style.display = 'block';
				}
				document.getElementById(target).innerHTML = text;
				doAjaxFIFO();
			}
		}
	}
}

function AjaxEval (url) {
	xml_http = AjaxInit();
	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 addToAjaxFIFO (ev) {
	AjaxFIFO.push(ev);
}

function doAjaxFIFO() {
	expr = AjaxFIFO.shift();
	eval(expr);

}

function ChangeBlock(url, target) {
	xml_http = AjaxInit();
	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();
			}
		}
	}
}

