
//ajax('pesqcliente.asp', 'GET', 'true', 'pesq', 'pagina=1&Reload=Yes&'+xnome)
function AbreUrlAjax(url, metodo, modo, tagId, parametros)
{
	
    goAjax( url+"?"+parametros+"&rnd"+ Math.random() , metodo, modo , tagId);
    if (tagId == ''){
		return retornoajax
    }
}

function goAjax(url, metodo, modo, tagRetorno, parametros) {
	
	rajax = ''
	
    if (tagRetorno != ''){
		document.getElementById(tagRetorno).innerHTML='<div align="center" class="carregando"><font size="2" face="Trebuchet MS"><img src="./Imagens/aguardando2.gif"><br><br>carregando...<br>&nbsp;</div>'
	}
	
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	 
    if(metodo == "GET") {
        xmlhttp.open("GET", url, modo);
    } else {        
        xmlhttp.open("POST", url, modo);
        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
        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.onreadystatechange = function() {
        if(xmlhttp.readyState == 4) {
            retornoajax=xmlhttp.responseText
            if (tagRetorno != ''){
				document.getElementById(tagRetorno).innerHTML=retornoajax
			}else{
				//alert(retorno);
			}
			//alert(retornoajax)
			rajax = retornoajax
			return retornoajax
            //findScript(retorno)
        }
    }
    if(metodo == "GET") {
        xmlhttp.send(null);
    } else {        
        xmlhttp.send(parametros);
    }
    //alert(retornoajax);
    if (tagRetorno != ''){
		return rajax 
		//retornoajax
    }
}
