function AJAX() {
	this.Chk = verificarDados;
	function verificarDados(caminhoRetorno,metodo,mensagem) {
		var xmlhttp = getXmlHttp();

		//Abre a url
		xmlhttp.open(metodo.toUpperCase(), caminhoRetorno,true);

		//Executada quando o navegador obtiver o código
		xmlhttp.onreadystatechange = function() {
			if (document.getElementById)
			{
			  var splash = document.getElementById("splashScreen");	
			  var splashIframe= document.getElementById("SplashIframe");	
			}
			else
			{	
			  var splash = document.all.splashScreen;	
			  var splashIframe= document.all.SplashIframe;	
			}
			splashIframe.style.display="none";

			if (xmlhttp.readyState==1){
				splash.style.visibility = "visible";	
				splashIframe.style.display = "block";
				var topo = parseInt(document.body.scrollTop);
				var extra = 200;
				splash.style.top = (topo + extra)+'px';
				splashIframe.style.top = (topo + extra)+'px';
				splashIframe.style.width = '175px'; 
				splashIframe.style.height = '191px';  	
			}
			
			if (xmlhttp.readyState==4){
	
				//Lê o texto
				var texto=xmlhttp.responseText;
	
				//Desfaz o urlencode
				texto=texto.replace(/\+/g," ");
				texto=unescape(texto);
				
				txt = texto.split("|:|");
				if(txt[0]=="mostraParcelas" || txt[0]=="informacoesGerais" || txt[0]=="lblidade" || txt[0]=="mostraemprestado" || txt[0]=="mostrareservado"){
					document.getElementById(txt[0]).innerHTML = txt[1];
				
					//-- Habilita | Desabilita campos
					if(txt[0]=="lblidade"){
						//-- Habilita | Desabilita campos
						var loc = location.toString();
						if(loc.indexOf("bolsa_alunonovo.asp")>-1){
							ObrigatoriosBolsa();
						}else{
							Obrigatorios();
						}	
					}
				
				}else if(txt[0]=="dadosResponsavel"){
					document.forms[0].elements["nomeresp"].value = txt[1];	
					document.forms[0].elements["RGRESPONSAVEL"].value = txt[2];
					document.forms[0].elements["CODOCUPACAORESP"].value = txt[3];
					document.forms[0].elements["parentesco"].value = txt[4];
					document.forms[0].elements["DTNASCRESPONS"].value = txt[5];
					document.forms[0].elements["e_mailresp"].value = txt[6];
					document.forms[0].elements["ve_mailresp"].value = txt[7];
					document.forms[0].elements["ESTADOCIVILRESP"].value = txt[8];
					
					//-- Bloqueio edição do nome em 29/07/2009:
					if(document.forms[0].elements["nomeresp"].value==""){
						document.forms[0].nomeresp.setAttribute('readOnly',false);
						document.forms[0].nomeresp.disabled = false;
						document.forms[0].elements["nomeresp"].className = "";
					}else{
						document.forms[0].nomeresp.setAttribute('readOnly',true);
						document.forms[0].nomeresp.disabled = true;
						document.forms[0].elements["nomeresp"].className = "readonly";
					}
					//--
					
					if(txt[9]>4){
						alert('ERRO: Existe mais de um cadastro relacionado com este CPF!\n\nVerifique os cadastros relacionados com o mesmo:\n'+txt[10]);
						document.forms[0].elements["cpfresponsavel"].focus();	
						
					}
					
				}else if(txt[0]=="dadosEnderecoCEP"){
					tipo = txt[2];
					if(txt[7] == "988"){
						document.forms[0].elements["end"+tipo+"cep"].value = txt[1];
						document.forms[0].elements["end"+tipo+"logradouro"].value = txt[3];
						document.forms[0].elements["end"+tipo+"bairro"].value = txt[4];
						document.forms[0].elements["end"+tipo+"cidade"].value = txt[5];
						document.forms[0].elements["end"+tipo+"estado"].value = txt[6];

					}else{
						url = "pop_endereco.asp?cep="+txt[1]+"&tipo="+tipo;
						win=window.open(url,"ACBEU","toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,scrollbars=yes,left=0,top=0,width=500,height=300");
						win.focus();

					}
					
				}else if(document.forms[0].elements[txt[0]].type=="textarea"){
					document.forms[0].elements[txt[0]].value = txt[1];
				
				}else{
					if (document.getElementById(txt[0])==null){
						document.forms[0].elements[txt[0]].value = txt[1];
					}else{
						document.getElementById(txt[0]).value = txt[1];
					}	
					/*
					if(txt[0]=="valorapagar") {
						if(ConverteVal(txt[1]) == 0) {
							documento.forms[0].formapagamento0.disabled = true;
						}else{
							documento.forms[0].formapagamento0.disabled = false;
						}	
					}
					*/	

				}	
	
				//-- finalizaSplash();	
				splash.style.visibility = "hidden";	
				splashIframe.style.display = "none";
				splashIframe.style.width='0px'; 
				splashIframe.style.height='0px';  	
				//--

			}
		}
		xmlhttp.send(null);
	}
}

function AJAXCombo() {

	this.Chk = verificarDados;

	function verificarDados(caminhoRetorno,metodo,mensagem) {
		var xmlhttp = getXmlHttp();

		//Abre a url
		xmlhttp.open(metodo.toUpperCase(), caminhoRetorno,true);

		//Executada quando o navegador obtiver o código
		xmlhttp.onreadystatechange = function() {
			if (document.getElementById){
				var splash = document.getElementById("splashScreen");	
				var splashIframe= document.getElementById("SplashIframe");	
			} else {	
				var splash = document.all.splashScreen;	
				var splashIframe= document.all.SplashIframe;	
			}
			splashIframe.style.display="none";

			if (xmlhttp.readyState == 1){
				splash.style.visibility = "visible";	
				splashIframe.style.display = "block";
				var topo = parseInt(document.body.scrollTop);
				var extra = 200;
				splash.style.top = (topo + extra)+'px';
				splashIframe.style.top = (topo + extra)+'px';
				splashIframe.style.width='175px'; 
				splashIframe.style.height='191px';  	
			}
			
			if (xmlhttp.readyState==4){
				//Lê o texto
				var texto=xmlhttp.responseText;
	
				//Desfaz o urlencode
				texto = texto.replace(/\+/g," ");
				texto = unescape(texto);
				txt = texto.split("|:|");
				var obj = document.forms[0].elements[txt[0]];
				//limpa combo 
				while(obj.options.length > 0){
					obj.options[obj.options.length-1] = null;
				}

				//monta combo
				if(txt[0]=="exemplar"){
					eval(txt[1]);
				}else{
					if (txt[0]=="turma"){
						obj.options[0] = new Option('TODOS','0');
						
					}else{
						obj.options[0] = new Option('','0');
	
					}
					eval(txt[1]);
					if(obj.size!=1) //Adiciona valor nulo
					{
						obj.options[0] = null;
					}
				}

				//-- finalizaSplash();	
				splash.style.visibility = "hidden";	
				splashIframe.style.display = "none";
				splashIframe.style.width='0px'; 
				splashIframe.style.height='0px';  	
				//--
			}
		}
		xmlhttp.send(null);
	}
}

function getXmlHttp() {
	var xmlhttp;
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}
	return xmlhttp;
}

function alertContents(){
	if(http_request.readyState == 4) {
	    if(http_request.status == 200) {
	        alert(http_request.responseText);
	    } else {
	        alert('There was a problem with the request.');
	    }
	}
}
