/**
 * Ajax script
 * (c) Pete Walker 2007
 *
 * @author Pete Walker
 * @version 2.0
 * @started 06/07/06
 */
 
var req;

ajax = function()
{
	this.ax = false;
	if(window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		this.ax = true;
	}
	if(!req) {
		alert("Ajax could not be loaded");
		return;
	}
}

ajax.prototype.loadXMLDoc = function(url)
{
	req.onreadystatechange = this.processReqChange;
	req.open("GET", url, true);
	if(!this.ax) {
		req.send(null);
	} else {
		req.send();
	}
}

ajax.prototype.processReqChange = function() 
{
	// only if req shows "complete"
	if (req.readyState == 4) {
       		// only if "OK"
       		if (req.status == 200) {
            		// ...processing statements go here...
			response  = req.responseXML.documentElement;
			method = response.getElementsByTagName('method')[0].firstChild.data;		
			result = response.getElementsByTagName('result')[0].firstChild.data;
			eval(method + '(\'\', result)');
		} else {
			alert('There was a problem retrieving the XML data:\n' + req.statusText);
		}
	}
}
