var objAjax;
var responseAjax;

function runAjax()
{
	try
	{
		objAjax = new XMLHttpRequest();
	}
	catch(e)
	{
		try
		{
			objAjax = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(ex)
		{
			try
			{
				objAjax = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(exc)
			{
				objAjax = null;
			}
		}
	}
}

function doAjaxRequest(url, method, params, objLoad, callBackFunction)
{
	runAjax();
	
	if(objAjax == null)
	{
		alert('Seu navegador não possui recursos de ActiveX, o site pode não funcionar corretamente!');
		return false;
	}

	objAjax.open(method, url, true);
	
	if(method == 'POST')
		objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		
	objAjax.onreadystatechange = function()
	{
		if(objAjax.readyState == 1)
		{
			if(objLoad != null)
				document.getElementById(objLoad).innerHTML = 'Carregando...';
		}
			
		if(objAjax.readyState == 4)
		{
			responseAjax = objAjax.responseXML;
			eval(callBackFunction);
			
			if(objLoad != null)
				document.getElementById(objLoad).innerHTML = '';
		}
	}
	
	objAjax.send(params);
}