var Ajax =
{
	GetXMLHTTPRequest : function()
	{
		var oXMLHTTPRequest = null;
		try //IE
		{
			oXMLHTTPRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch(err) 
		{
			try 
			{
				oXMLHTTPRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(err) 
			{
				oXMLHTTPRequest = null;
			}
		}
		
		if(!oXMLHTTPRequest) //Mozilla
		{
			oXMLHTTPRequest = new XMLHttpRequest();
		}
		
		return oXMLHTTPRequest;
	},
	
	HTTPServerRequest : function(strURL,strPostParams,bIsResponseXML,oCallBackFunction,oCallBackFunctionError)
	{
		var oResponseData	= null;
		var oXMLHTTPRequest = this.GetXMLHTTPRequest();
		
		if(oXMLHTTPRequest)
		{
			var strMethod = strPostParams ? 'POST' : 'GET';
			
			oXMLHTTPRequest.open(strMethod, strURL, true);
			oXMLHTTPRequest.onreadystatechange = function()
			{
                var bComplete = false;
                var bError    = false;
				try
				{
  					if (oXMLHTTPRequest.readyState == 4)
  					{         
                        if(oXMLHTTPRequest.status == 200)
                        {
                            bComplete = true;
                            if(bIsResponseXML)
                            {
                                oResponseData = oXMLHTTPRequest.responseXML;
                            }
                            else
                            {
                                oResponseData = oXMLHTTPRequest.responseText;
                            }
                        }
                        else
                        {
                            bError = true;
                        }
 	 				}
 	 			}
 	 			catch(ex)
 	 			{	
 	 				oResponseData	= null;
 	 				bError          = true;
 	 			}

 	 			if(bComplete && oCallBackFunction)
 	 			{
                      oCallBackFunction(oResponseData);
 	 			}
                                
                if(bError && oCallBackFunctionError)
                {
                    oCallBackFunctionError();
                }
 	 		};
 	 		
 	 		if(strPostParams)
 			{
 				oXMLHTTPRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 			}
			oXMLHTTPRequest.send(strPostParams);
		}
		
		//return the request object
		return oXMLHTTPRequest;
	}
}

