// Supporting Javascript for XMod AJAX controls and functions.
function xmodFactoryXMLHttpRequest() {
	if(window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		var msxmls = new Array(
			'Msxml2.XMLHTTP.5.0',
			'Msxml2.XMLHTTP.4.0',
			'Msxml2.XMLHTTP.3.0',
			'Msxml2.XMLHTTP',
			'Microsoft.XMLHTTP');
		for (var i = 0; i < msxmls.length; i++) {
			try {
				return new ActiveXObject(msxmls[i]);
			} catch (e) {
			}
		}
	}
	throw new Error("Could not instantiate XMLHttpRequest");
}

function xmodAjax() {
	this._xmlhttp = new xmodFactoryXMLHttpRequest();
	this.method = 'GET';
	this.contentType = '';
}

function xmodAjax_call(url,params) {
	var instance = this;
	//this._xmlhttp.open('GET', url, true);
	this._xmlhttp.open(this.method, url, true);
	this._xmlhttp.onreadystatechange = function() {
		switch(instance._xmlhttp.readyState) {
		case 1:
			instance.loading();
			break;
		case 2:
			instance.loaded();
			break;
		case 3:
			instance.interactive();
			break;
		case 4:
			instance.complete(instance._xmlhttp.status, instance._xmlhttp.statusText, 
				instance._xmlhttp.responseText, instance._xmlhttp.responseXML);
			break;
		}
	}
	if(this.method == 'POST'){
		this._xmlhttp.setRequestHeader("Content-Type", this.contentType);
		this._xmlhttp.send(params);
	}
	else {
		this._xmlhttp.send(null);
	}
}

function xmodAjax_inserHTML(url,id){

}

function xmodAjax_loading(){}
function xmodAjax_loaded(){}
function xmodAjax_interactive(){}
function xmodAjax_complete(status, statusText, responseText, responseHTML){}

xmodAjax.prototype.loading = xmodAjax_loading;
xmodAjax.prototype.loaded = xmodAjax_loaded;
xmodAjax.prototype.interactive = xmodAjax_interactive;
xmodAjax.prototype.complete = xmodAjax_complete;
xmodAjax.prototype.call = xmodAjax_call;
