function AjaxQuery(URL, Method, Async, Query, onSuccess, onError)
{
	var xhr;
	
    try 
	{  
		xhr = new ActiveXObject('Msxml2.XMLHTTP');   
	}
    catch (e) 
    {
        try 
		{   
			xhr = new ActiveXObject('Microsoft.XMLHTTP');    
		}
        catch (e2) 
        {
			try 
			{
				xhr = new XMLHttpRequest();     
			}
			catch (e3) 
			{  
				return false;
			}
        }
    }
 
    xhr.onreadystatechange = function()
    { 
        if(xhr.readyState == 4)
        {
            if(xhr.status == 200)
			{
				if(onSuccess != null)
				{
					var xd = xhr.responseXML.documentElement;
					if(xd != null)
					{
						var onSuccessFunction = window[onSuccess];
						onSuccessFunction(xd);
					}
				}
			}
            else
			{
                if(onError != null)
				{
					var onErrorFunction = window[onError];
					onErrorFunction();
				}
			}
        }
    }; 

	xhr.open(Method, URL, Async);
	if(Method == 'POST')
	{	
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	}
	(Query != null) ? xhr.send(Query) : xhr.send(null); 
}
