function createAjaxObj()
{
	var httpRequest = false;
	
	// Mozilla, Safari etc
	if (window.XMLHttpRequest) {
		httpRequest = new XMLHttpRequest()
		if (httpRequest.overrideMimeType) httpRequest.overrideMimeType('text/xml');
	}
	// IE
	else if (window.ActiveXObject) {
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
	return httpRequest
}

var ajax = new Object();
ajax.request = createAjaxObj();
ajax.bustcachevar = 1; //bust potential caching of external pages after initial request? (1=yes, 0=no)

// ajax.basedomain = "http://" + window.location.hostName;
//ajax.fileType = "txt";

/*
ajax.getRequest = function(url, callbackFunc, fileType)
{
	var bustcacheparameter = "";
	ajax.obj = createAjaxObj();
	if (ajax.bustcachevar == 1) {
		bustcacheparameter = (url.indexOf("?") != -1) ? "&" + new Date().getTime() : "?" + new Date().getTime();
	}
	if (this.obj) {
		//this.fileType = fileType;
		//this.obj.onreadystatechange = callbackFunc;
		this.obj.open('GET', URL + bustcacheparameter, true);
		this.obj.send(null);
	}
}
*/

function ajaxPage(url, containerId)
{
	document.getElementById(containerId).innerHTML = '<div style="font:normal 14px arial;color:#999;line-height:32px;height:32px;background:url(res/img/loading_32.gif) 0 0 no-repeat;padding-left:40px;">Loading...</div>';
	
	var bustcacheparameter = "";
	ajax.request = createAjaxObj();
	if (ajax.bustcachevar == 1) {
		bustcacheparameter = (url.indexOf("?") != -1) ? "&" + new Date().getTime() : "?" + new Date().getTime();
	}
	
	if (ajax.request) {	
		ajax.request.onreadystatechange = function() {loadPage(ajax.request, containerId)}
		ajax.request.open('GET', url + bustcacheparameter, true);
		ajax.request.send(null);
	}
}

function loadPage(request, containerId)
{
	if (request.readyState == 4 && (request.status == 200 || window.location.href.indexOf("http") == -1)) {
		//alert(request.responseText);
		document.getElementById(containerId).innerHTML = request.responseText;
	}
}