var	hubAJAX = {
    unique:	false,
    init:	function() {
	if (typeof XMLHttpRequest != 'undefined')
	    return new XMLHttpRequest();

	if (window.ActiveXObject) {
	    var avers = [
		"Microsoft.XmlHttp",
		"MSXML2.XmlHttp",
		"MSXML2.XmlHttp.3.0",
		"MSXML2.XmlHttp.4.0",
		"MSXML2.XmlHttp.5.0"
		];

	    for (var i = avers.length - 1; i >= 0; i--) {
		try {
		    httpObj = new ActiveXObject(avers[i]);
		    return httpObj;
		} catch(e) {}
	    }
	}

	throw new Error('XMLHttp (AJAX) not supported');
    },
    include:	function(id, url) {
	h = this.init();
	if (this.unique) {
		if (url.indexOf("?") == -1)
			url += "?unqiueid=" + (new Date()).getTime();
		else
			url += "&unqiueid=" + (new Date()).getTime();
	}
	h.open("GET", url, true);
	h.onreadystatechange = function() {
	    if (h.readyState == 4) {
		s = unescape(h.responseText.replace(/\+/g," "));
		document.getElementById(id).innerHTML = s;
	    }
	}
	h.send(null);
    },
    execute:	function(reqtype, url, args, func, resptype) {
	var suffix = '';
	for (var param in args)
		suffix += "&" + param + "=" + args[param];

	if (reqtype == "GET") {
		if (url.indexOf("?") == -1)
			url += "?";
		url += suffix;
	}

	h = this.init();
	h.open(reqtype, url, true);
	if (reqtype == "POST")
	    h.setRequestHeader("Content-Type",
	    	"application/x-www-form-urlencoded");

	h.onreadystatechange = function() {
	    if (h.readyState == 4) {
		if(h.status == 200) {
		    if (resptype == "xml") {
			if (document.implementation &&
			    document.implementation.createDocument) {
				xmlDoc = h.responseXML;
			} else if (window.ActiveXObject) {
			    // For IE, we need to create an XML element,
			    // insert the text and then pull out the XML
			    // element again
			    var xx = document.createElement('xml');
			    var yy = '_formjAjaxReturnXML';

			    xx.setAttribute('innerHTML', h.responseText);
			    xx.setAttribute('id', yy);
			    document.body.appendChild(xx);
			    document.getElementById(yy).innerHTML =
					h.responseText;
			    xmlDoc = document.getElementById(yy);
			    document.body.removeChild(xmlDoc);
			} else
			    xmlDoc = null;

			if (xmlDoc)
			    func(xmlDoc);
		    } else {
			data = h.responseText;
			if (data)
			    func(data);
		    }
		}

		delete h;
	    }
	}

	if (reqtype == "POST")
	    h.send(suffix);
	else
	    h.send(null);
    }
}

