function getXMLHTTPRequest(){
	try{
		req = new XMLHttpRequest();
	} catch(err1){
  		try{
  			req = new ActiveXObject("Msxml2.XMLHTTP");
  		} catch (err2){
    		try{
    			req = new ActiveXObject("Microsoft.XMLHTTP");
    		}catch (err3){
      			req=false;
    		}
  		}
	}
	return req;
}

function ajaxRun(url, funcCarregando, funcAcao, tipo)
{
		if( typeof tipo == 'undefined')
			tipo = 'GET';

		var xmlhttp = getXMLHTTPRequest();
		if (xmlhttp!=null)
		{
    		xmlhttp.onreadystatechange=function() {
		        if (xmlhttp.readyState==4){
					funcAcao(xmlhttp);
        		}
    		}    		
	 		xmlhttp.open(tipo,url,true);
	 		
	 		funcCarregando(url);
	 			 		
	 		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	       	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	       	xmlhttp.setRequestHeader("Pragma", "no-cache");  					
			xmlhttp.send(null);
	 	}
		else
	 		alert("Seu navegador não suporta XMLHTTP. Por favor, contacte o administrador do site.");
}