// JavaScript Document
var xmlHttp;

clsAjax.prototype._method;
clsAjax.prototype._url;
clsAjax.prototype._param = "";
clsAjax.prototype._function;
var _function;

function clsAjax()
{
	this.createXMLHttpRequest();
	//return xmlHttp;
}

clsAjax.prototype.createXMLHttpRequest = function()
{
	if(window.ActiveXObject){
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest){
		xmlHttp = new XMLHttpRequest();		
	}
}


clsAjax.prototype.setMethod = function(method){
	this._method = method;
}

clsAjax.prototype.getMethod = function(){
	return this._method;
}

clsAjax.prototype.setUrl = function(url){
	this._url = url;
}

clsAjax.prototype.getUrl = function(){
	return this._url;
}

clsAjax.prototype.setParam = function(param){
	this._param = param;
}

clsAjax.prototype.getParam = function(){
	return this._param;
}

clsAjax.prototype.setFunction = function(name){
	this._function = name;
	_function = name;
}

clsAjax.prototype.startRequest = function(){
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		xmlHttp.onreadystatechange = this.onReady;
		xmlHttp.open(this._method, this._url,true);
		if(this._param != "")
		{
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlHttp.setRequestHeader("Content-length", this._param.length);
			xmlHttp.setRequestHeader("Connection", "close");
			xmlHttp.send(this._param);
		}
		else
		{	
			xmlHttp.send("");
		}
	}
}

//onReady cho ta biet da nhan duoc gia tri, de tiep tuc goi thang khac

var giatriText;
var giatriXML;

clsAjax.prototype.onReady = function(){
	if(xmlHttp.readyState ==4){
		if(xmlHttp.status==200){
			giatriText = xmlHttp.responseText;
			giatriXML = xmlHttp.responseXML;
			_function();
			//this._function();
		}
	}
}


