function Tajax()
{
	this.xmlhttp_s = null;

	this._onreadystatechanged = _onreadystatechanged;
	this._SetTransactionProperties = _SetTransactionProperties;

	this.onReadystateChanged = null;
	this.onTransactionCompleted = null;


	this.InitXMLHTTP = InitXMLHTTP;
	this.GetRequest = GetRequest;
	this.PostRequest = PostRequest;
	
	this.responseText = null;
	this.responseXML = null;
	this.responseStatus = null;

	function InitXMLHTTP()
	{
		this.xmlhttp_s = false;
		
		var msxmlhttp = new Array(
							'Msxml2.XMLHTTP.5.0',
							'Msxml2.XMLHTTP.4.0',
							'Msxml2.XMLHTTP.3.0',
							'Msxml2.XMLHTTP',
							'Microsoft.XMLHTTP'
							);
		for (var i = 0; i < msxmlhttp.length; i++)
		{
			try
			{
				this.xmlhttp_s = new ActiveXObject(msxmlhttp[i]);
			}
			catch (e)
			{
				this.xmlhttp_s = null;
			}
		}
		
		if(!this.xmlhttp_s && typeof XMLHttpRequest != "undefined")
		{
			this.xmlhttp_s = new XMLHttpRequest();
		}
		if (!this.xmlhttp_s)
		{
			alert('no xmlhttpinstance');
			return false;
		}
		else
		{
			return true;
		}
	}
		
	function GetRequest(url, paramStr, async)
	{
		if (!this.InitXMLHTTP())
		{
			return false;
		}
		__bubu = this;
		this.xmlhttp_s.onreadystatechange = function ()
		{
			__bubu._SetTransactionProperties();
			__bubu._onreadystatechanged();
		}
		this.xmlhttp_s.open("GET", url + "?" + paramStr, async);
		this.xmlhttp_s.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		this.xmlhttp_s.send(null);
		
		if (async==false)
		{
			this._SetTransactionProperties();
		}

		return true;
	}
	
	function PostRequest(url, parameters, async)
	{
		if (!this.InitXMLHTTP())
		{
			return false;
		}
		__bubu = this;
		this.xmlhttp_s.onreadystatechange = function ()
		{
			__bubu._SetTransactionProperties();
			__bubu._onreadystatechanged();
		}
//		this.xmlhttp_s.open("GET", url + "?" + paramStr, async);
		this.xmlhttp_s.open('POST', url, async);
		this.xmlhttp_s.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.xmlhttp_s.setRequestHeader("Content-length", parameters.length);
		this.xmlhttp_s.setRequestHeader("Connection", "close");
		this.xmlhttp_s.send(parameters);
				
		if (async==false)
		{
			this._SetTransactionProperties();
		}

		return true;
	}

	function _onreadystatechanged()
	{
		if (this.xmlhttp_s.readyState == 4)
		{

			if(this.onReadystateChanged != null)
			{
				this.onReadystateChanged(this.xmlhttp_s);
			}

			if(this.onTransactionCompleted != null)
			{
				this.onTransactionCompleted(this.xmlhttp_s);
			}			
		}
		else
		{

			if(this.onReadystateChanged != null)
			{				
				this.onReadystateChanged(this.xmlhttp_s);
			}
		}
	}
	
	function _SetTransactionProperties()
	{
		this.readyState = this.xmlhttp_s.readyState;
		try
		{
			this.status = this.xmlhttp_s.status;
			this.statusText = this.xmlhttp_s.statusText;
			this.responseText = this.xmlhttp_s.responseText;
			this.responseXML = this.xmlhttp_s.responseXML;
		}
		catch(e)
		{
			this.status = "";
			this.statusText = "";
			this.responseText = "";
			this.responseXML = "";
		}
	}
}

