//AJAX
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.");
} 


function chamaHTTP(endereco,variaveis,divid,mensa,divtmp) {
	var strSaida = "";
	if (divid!="" && mensa!="") {
		document.getElementById(divid).innerHTML = mensa;
	}
	var oHTTPRequest = createXMLHTTP(); 
	oHTTPRequest.open("post", endereco, true);
	oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");
	oHTTPRequest.setRequestHeader("encoding", "iso-8859-1");
	oHTTPRequest.onreadystatechange=function() {
		if (oHTTPRequest.readyState==4){
			if (divid!="") {
				document.getElementById(divid).innerHTML = oHTTPRequest.responseText;
				if (divtmp!="") {
					objdiv = window.parent.oculto.document.getElementById(divtmp);
					if (objdiv) {
						objdiv.innerHTML = document.getElementById(divid).innerHTML;
					}
				}
			}
		//alert(oHTTPRequest.responseText);
		}
	}
	oHTTPRequest.send(variaveis);
}

function chamaHTTPbus(endereco,variaveis,divid,mensa,divtmp,funcao,metodo) {
	var strSaida = "";
	if (divid!="" && mensa!="") {
		document.getElementById(divid).innerHTML = mensa;
	}
	var oHTTPRequest = createXMLHTTP(); 
	oHTTPRequest.open(metodo, endereco, true);
	oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");
	oHTTPRequest.setRequestHeader("encoding", "iso-8859-1");
	oHTTPRequest.onreadystatechange=function() {
		if (oHTTPRequest.readyState==4){
			if (divid!="") {
				document.getElementById(divid).innerHTML = oHTTPRequest.responseText;
				if (divtmp!="") {
					objdiv = window.parent.oculto.document.getElementById(divtmp);
					if (objdiv) {
						objdiv.innerHTML = document.getElementById(divid).innerHTML;
					}
				}
			}
			if (funcao!="") eval(funcao);
		//alert(oHTTPRequest.responseText);
		}
	}
	oHTTPRequest.send(variaveis);
}

