function goAjax(url, metodo, modo, tagRetorno, parametros) {
	document.getElementById(tagRetorno).innerHTML = '<div align="center" class="carregando"><img src="images/carregando.gif"><br /><br />carregando...</div>'
	
	function createXMLHTTP() {
		try {
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e) {
			try {
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
				alert(ajax);
			} catch(ex) {
				try {
					ajax = new XMLHttpRequest();
				} catch(exc) {
					alert("Esse browser não tem recursos para uso do Ajax");
					ajax = null;
				}
			}
			return ajax;
		}
		
		var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
												 "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
		for (var i=0; i < arrSignatures.length; i++) {
			try {
				var oRequest = new ActiveXObject(arrSignatures[i]);
				return oRequest;
			} catch (oError) {
				
			}
		}
		
		throw new Error("MSXML is not installed on your system.");
	}
	
	var xmlhttp = createXMLHTTP();
	
	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) {
			retorno=xmlhttp.responseText;
			document.getElementById(tagRetorno).innerHTML=retorno;
			findScript(tagRetorno);
		}
	}
	
	if (metodo == "GET") {
		xmlhttp.send(null);
	} else { 
		xmlhttp.send(parametros);
	}
}

function montaParametros(param, formulario) {
	parametros = param;
	for (var i=0;i<formulario.length;i++) {
		parametros += "&" + formulario.elements[i].name + "=" + formulario.elements[i].value;
  }
	return parametros;
}

function findScript(tagRetorno){
	objRetorno = document.getElementById(tagRetorno);
	var scripts = objRetorno.getElementsByTagName('script');
	for (var i=0; i<scripts.length; i++){
		if (scripts[i].innerHTML != ""){
			eval(scripts[i].innerHTML);
		}
	}
}
