function ajax()
{
	var httpRequest = false;
	var method = "GET";
	var url = null;
	var reposponseText = null;
    var postvars = null;

	var eventList = [];

	this.Initialize = function()
	{
		if (window.XMLHttpRequest) 
		{ 
			httpRequest = new XMLHttpRequest();

			if (httpRequest.overrideMimeType) 
			{
				httpRequest.overrideMimeType('text/html');
			}
		} 
		else if (window.ActiveXObject) 
		{ // IE
			try 
			{
				httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e) 
			{	  				
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 				
			}
		}

		if (!httpRequest) 
		{
			return false;
		}
		httpRequest.onreadystatechange = this.StatusChange;
		httpRequest.open(method, url, true);
        if (method == "POST")
        {
            httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            httpRequest.setRequestHeader("Content-length", postvars.length);
            httpRequest.setRequestHeader("Connection", "close");
            httpRequest.send(postvars);
        }
        else   
        {
		    httpRequest.send(null);
        }
	};

	this.StatusChange = function()
	{
		this.statusText = httpRequest.StatusText;

		if (httpRequest.readyState == 1)
		{
			if (typeof eventList["OnLoading"] == "function")
			{
				eventList["OnLoading"].apply(this, new Array(this));
			}
		}
		else if (httpRequest.readyState == 2)
		{
			if (typeof eventList["OnLoaded"] == "function")
			{
				eventList["OnLoaded"].apply(this, new Array(this));
			}
		}
		else if (httpRequest.readyState == 4)
		{
			this.responseText = httpRequest.responseText;
			this.responseStatus = httpRequest.status;

			if (typeof eventList["OnSuccess"] == "function")
			{
				eventList["OnSuccess"].apply(this, new Array(this));
			}				
		}
	}

	this.HandleArgs = function(args)
	{
		for (arg in args)
		{				
			if (arg == "url")
			{
				url = args[arg];
			}
            else
            if (arg == "postvars")
            {
                method = "POST";
                postvars = args[arg];
            }
			else 
			if (typeof args[arg] == "function")
			{
				eventList[arg] = args[arg];	
			}
		}
	};
}

ajaxGET = function(arg)
{
	return ajaxRequest('GET', arg);
};

ajaxPOST = function(arg)
{
	return ajaxRequest('POST', arg);
};

ajaxRequest = function(requestType, arg)
{
	var request = new ajax();

	request.Method = requestType;
	request.HandleArgs(arg);
	return request.Initialize();
};