    try{   
        xmlhttp = new XMLHttpRequest();   
    }catch(ee){   
        try{   
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");   
        }catch(e){   
            try{   
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");   
            }catch(E){   
                xmlhttp = false;   
            }   
        }   
    } 
/*var xmlhttp = false;
if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
        xmlhttp.overrideMimeType('text/xml');
} else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}*/
function extraiScript(texto){
//Maravilhosa função feita pelo SkyWalker.TO do imasters/forum
//http://forum.imasters.com.br/index.php?showtopic=165277
    // inicializa o inicio ><
    var ini = 0;
    // loop enquanto achar um script
    while (ini!=-1){
        // procura uma tag de script
        ini = texto.indexOf('<script', ini);
        // se encontrar
        if (ini >=0){
            // define o inicio para depois do fechamento dessa tag
            ini = texto.indexOf('>', ini) + 1;
            // procura o final do script
            var fim = texto.indexOf('</script>', ini);
            // extrai apenas o script
            codigo = texto.substring(ini,fim);
            // executa o script
            //eval(codigo);
            /**********************
            * Alterado por Micox - micoxjcg@yahoo.com.br
            * Alterei pois com o eval não executava funções.
            ***********************/
            novo = document.createElement("script")
            novo.text = codigo;
            document.body.appendChild(novo);
        }
    }
}




function ajax(url,resultado) {

		document.getElementById(resultado).innerHTML = "Carregando...";
		
		xmlhttp.open('POST', url, true);

		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

		xmlhttp.send(null);

		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				document.getElementById(resultado).innerHTML = xmlhttp.responseText + ' ';
				//alert(xmlhttp.responseText);
			} else {
				document.getElementById(resultado).innerHTML = 'Carregando...';
			}
		}
}

function ajax1(url,id1,resultado) {

	var q1 = document.getElementById(id1).value;

	if(q1 !== "") {
		document.getElementById(resultado).innerHTML = "Carregando...";
		
		url = url+'?'+id1+'='+q1;
		
		xmlhttp.open('POST', url, true);

		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

		xmlhttp.send(null);

		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				document.getElementById(resultado).innerHTML = xmlhttp.responseText + ' ';
				//alert(xmlhttp.responseText);
			} else {
				document.getElementById(resultado).innerHTML = 'Carregando...';
			}
		}
	}
}

function ajax2(url,id1,id2,resultado) {

	var q1 = document.getElementById(id1).value;
	var q2 = document.getElementById(id2).value;

	if(q1 !== "" && q2 !== "") {
		document.getElementById(resultado).innerHTML = "Carregando...";
		
		url = url+'?'+id1+'='+q1+'&'+id2+'='+q2;

		xmlhttp.open('POST', url, true);

		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

		xmlhttp.send(null);
		
		xmlhttp.onreadystatechange = function() {
			//alert(xmlhttp.readyState);
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				document.getElementById(resultado).innerHTML = xmlhttp.responseText + ' ';
			} else {
				document.getElementById(resultado).innerHTML = 'Carregando...';
			}
		}
	}
}

function ajax3(url,id1,id2,id3,resultado) {

	var q1 = document.getElementById(id1).value;
	var q2 = document.getElementById(id2).value;
	var q3 = document.getElementById(id3).value;

	if(q1 !== "" && q2 !== "" && q3 !== "") {
		document.getElementById(resultado).innerHTML = "Carregando...";
		
		url = url+'?'+id1+'='+q1+'&'+id2+'='+q2+'&'+id3+'='+q3;

		
		xmlhttp.open('GET', url, true);
		
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.setRequestHeader("Content-type","text/html; charset=ISO-8859-1");
		xmlhttp.setRequestHeader("Encoding","ISO-8859-1");
		xmlhttp.setRequestHeader("CharSet", "iso-8859-1"); 
		
		
		xmlhttp.send(null);

		
		xmlhttp.onreadystatechange = function() {
			//alert(xmlhttp.readyState);
			//alert(xmlhttp.status);
			//if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				document.getElementById(resultado).innerHTML = xmlhttp.responseText + ' ';
				extraiScript(xmlhttp.responseText);
			//} else {
			//	document.getElementById(resultado).innerHTML = 'Carregando...';
			//}
		}

		
	}
}
