var ajax_http;
var ajax_resultFunction;
function Ajax(url, resultFunc)
{
	this.GetHttpObj = function()
	{
		var xmlHttp = null;
		try
		{
			// Firefox, Opera 8.0+, Safari
			xmlHttp = new XMLHttpRequest();
		}
		catch (e)
		{
			// Internet Explorer
			try
			{
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
	
		return xmlHttp;
	};

	this.addParam = function(name, value)
	{
		if(this._params.length == 0)
			this._params = name + "=" + escape(value);
		else
			this._params += "&" + name + "=" + escape(value);
	};
	
	this.addParamString = function(str)
	{
		if(this._params.length == 0)
			this._params = str;
		else
			this._params += "&" + str;
	};

	this.cycle = function()
	{
		ajax_http.open("POST", this._url, true);
		ajax_http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajax_http.setRequestHeader("Content-length", this._params.length);
		ajax_http.setRequestHeader("Connection", "close");
		ajax_http.onreadystatechange = function()
		{
			if(ajax_http.readyState == 4)
				ajax_resultFunction(ajax_http.responseText);
		};

		ajax_http.send(this._params);
		this._params = "";
	};

	this._url = url;
	this._params = "";
	ajax_resultFunction = resultFunc;
	ajax_http = this.GetHttpObj();
	if(ajax_http == null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
}