function Ajax ()
{
	this.xmlHttp = false;
	this.ajaxResult = 0;
	this.dataStr = false;
	this.requestResult;
	this.paramLen = 0;
	this.errorTxt ='no error';
	function createXmlHttpRequestObject(request) 
	{
	  if(!request || typeof request=='undefined')
	  {
		  try
		  {
		    request = new XMLHttpRequest();
		  }
		  catch(e)
		  {
		      var XmlHttpVersions = new Array(
		      "MSXML2.XMLHTTP.7.0",
		      "MSXML2.XMLHTTP.6.0",	
		      "MSXML2.XMLHTTP.5.0",
		      "MSXML2.XMLHTTP.4.0",
		      "MSXML2.XMLHTTP.3.0",
		      "MSXML2.XMLHTTP",
		      "Microsoft.XMLHTTP");
		      for (var i=0; i<XmlHttpVersions.length && !request; i++) 
		      {
			      try 
			      { 
			        request = new ActiveXObject(XmlHttpVersions[i]);
			      } 
			      catch (e) 
			      {
			      	
			      }
			  }
		  }
	  }	  
      return request;
	};
	
	function encodeDataComponents(dataComponents,method)
	{
	
		if(method=='POST')
			var dataString = '&';
		else	
			var dataString = ' ';
		if(!dataComponents || typeof dataComponents == 'undefined')
		{
			return dataString;
		}
		if(typeof  dataComponents.elements == 'undefined')
			return encodeURI(dataString+dataComponents);
		var params=dataComponents;
		this.paramLen = params.length;
		if(this.paramLen==0)
		{
			return dataString;
		}
		
		for(n=0;n<this.paramLen;n++)
		{
			if(params.elements[n].type=='checkbox')
			{
				 dataString += params.elements[n].name + "=" + encodeURIComponent(params.elements[n].checked)+"&";
			}
			else if(params.elements[n].type=='radio')
			{
				 if(params.elements[n].checked) 
				 {
       				dataString +=  params.elements[n].name + "=" + encodeURIComponent(params.elements[n].value)+"&";
      			  }
			}
			else if(params.elements[n].type=='select-multiple')
			{
				for(i=0; i<params.elements[n].options.length; i++) 
				{
        			dataString += params.elements[n].name + "=" + encodeURIComponent(params.elements[n].options[m].value)+"&"
				}	
			}
			else
			{
				dataString += params.elements[n].name + "=" + encodeURIComponent(params.elements[n].value)+"&";
			}
		}
		
		return dataString;
	};
	
	
	
	this.getAjax = function()
	{
		this.xmlHttp = createXmlHttpRequestObject(this.xmlHttp); 
		this.ajaxResult = 2;
		if(!this.xmlHttp)
			this.ajaxResult = -11;
		return this.xmlHttp;
	};
	
	this.getRequestData = function(data,method)
	{
		
		this.dataStr = encodeDataComponents(data,method);
		this.ajaxResult = 3;
		if(!this.dataStr)
			this.ajaxResult = -12;
	};
	
	this.sendRequest = function(url,data,method,asynchro)
	{
		this.getAjax();
		if(this.ajaxResult==2)
		{
			if(method!='POST' && method!='GET')
				method='GET';
			if(asynchro != true && asynchro != false)	
				asynchro = true;
			this.getRequestData(data,method);
			if(this.ajaxResult==3)
			{	
				if(method == 'GET')
				{	
					var urlSend = url + this.dataStr;
					var sendetVar = null;
				}	
				else	
				{
					var urlSend = url;
					var sendetVar = this.dataStr;
				}	
				try
				{	
					var tmpObj = this;	
					this.xmlHttp.onreadystatechange = function()
					{
						 tmpObj.getResponse();
					}
					this.xmlHttp.open(method, urlSend, asynchro);
					if(method=='POST')
					{
						this.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
						this.xmlHttp.setRequestHeader("Content-length",this.paramLen);
						this.xmlHttp.send(sendetVar);
					}	
					else
						this.xmlHttp.send(null);
					this.ajaxResult=1;
					
				}
				catch(e)
				{
					alert(e);
					this.errorTxt = e;
					this.ajaxResult = -1;
				}
			}	
		}
		else
			this.ajaxResult = -2;
		
	};
	this.action = function(){};
	this.getResponse = function()
	{
		if (this.xmlHttp.readyState == 4) 
		{
			if (this.xmlHttp.status == 200) 
			{
				this.action();
			}
			else
				this.ajaxResult = -22;	
		} 
		else 
		  	this.ajaxResult=-23;
	};
	this.getAjaxResult = function()
	{
		return this.ajaxResult;
	};
	this.getRequestResult = function()
	{
		return this.requestResult;	
	};
	this.getErrorTxt = function()
	{
		return this.errorTxt;
	};
	
}
