// JavaScript Document

function Asynchronous() {
	this._xmlhttp = new FactoryXMLHttpRequest();
}

function Asynchronous_call(method, url, data, user) {
	var instance = this;
	var userdata = user;
	if (data == null || data.length == 0) {
		method = "GET";
	}
	this._xmlhttp.open(method, url, true);
	if (method === 'POST') {
		this._xmlhttp.setRequestHeader("Content-Type",
			"application/x-www-form-urlencoded; charset=UTF-8");
		this._xmlhttp.setRequestHeader("Content-Length", data != null ? data.length : 0);
	}
	this._xmlhttp.onreadystatechange = function() {
		switch(instance._xmlhttp.readyState) {
			case 1: instance.loading(this._user); break;
			case 2: instance.loaded(this._user); break;
			case 3: instance.interactive(this._user); break;
			case 4: instance.complete(userdata, 
						instance._xmlhttp.status,
						instance._xmlhttp.statusText,
						instance._xmlhttp.responseText, 
						instance._xmlhttp.responseXML);
					break;
		}
	}

	this._xmlhttp.send(data);
}

function Asynchronous_loading(user) {
}

function Asynchronous_loaded(user) {
}

function Asynchronous_interactive(user) {
}

function Asynchronous_complete(user, status, statusText, responseText, responseHTML) {
}

Asynchronous.prototype.loading = Asynchronous_loading;
Asynchronous.prototype.loaded = Asynchronous_loaded;
Asynchronous.prototype.interactive = Asynchronous_interactive;
Asynchronous.prototype.complete = Asynchronous_complete;
Asynchronous.prototype.call = Asynchronous_call;


