AJAX = function ()
{
	this.m_transport = this._getTransport();
}

with ( AJAX )
{
	prototype.m_transport = null;
	prototype.m_isAsync   = true;
	prototype.m_options   = {
		method : 'get'
	};
	//
	// public
	//
	prototype.request = function (options, isAsync)
	{
		for ( var a in options )
		{
			this.m_options[a] = options[a];
		}
		this.m_isAsync = isAsync;
		with ( this.m_options )
		{
			this.m_transport.open(method, url, this.m_isAsync);
			this.m_transport.onreadystatechange = this._getOnStateChangeHandler();
			this.m_transport.send( (method == 'post') ? postData : null );
		}
	}
	
	//
	// private
	//
	prototype._getTransport = function ()
	{
		var transport = null;
		try
		{
			transport = new ActiveXObject('Msxml2.XMLHTTP');
		} 
		catch (e) {}
		
		if ( !transport )
		{
			try
			{
				transport = ActiveXObject('Microsoft.XMLHTTP');
			}
			catch (e) {}
		}
		
		if ( !transport )
		{
			try
			{
				transport = new XMLHttpRequest();
			}
			catch (e) {}
		}
		
		return transport;
	}
	
	prototype.isSuccess = function ()
	{
	    return (this.m_transport.status == undefined)
		       || (this.m_transport.status == 0)
		       || (this.m_transport.status >= 200 && this.m_transport.status < 300);
	}
	
	prototype._onStateChangeHandler = function ()
	{
		var state = this.m_transport.readyState;
		switch ( state )
		{
			case 1:
			case 2:
			case 3:
				break;
			case 4: 
				if ( this.isSuccess() )
				{
					if ( this.m_options.onSuccess )
					{
						this.m_options.onSuccess(this.m_transport);
					}
				}
				else
				{
					if ( this.m_options.onError )
					{
						this.m_options.onError(this.m_transport);
					}
				}
				break;
		}
	}
	
	prototype._getOnStateChangeHandler = function ()
	{
		var obj = this;
		return function () {
			obj._onStateChangeHandler.call( obj );
		}
	}
}