/********************************************************************************
Passaporte - Arquivo de Fun??es  Javascript
********************************************************************************/

/********************************************************************************
redirecionaSelect
********************************************************************************/

function redirecionaSelect(){
	//redireciona para pg de Passaporte Padr?o ICAO
	
	alert (document.localidade.cidade.value);
	if (document.localidade.cidade.value=='1'){
		//window.location='http://www.dpf.gov.br/web/servicos/passaporte_ICAO.htm';
		window.location='passaporte_ICAO.jsp?uf='+document.all.unidadeFederativa.value+'&cd='+document.all.municipio.value;
		//window.location='http://10.61.5.12/desenvInternet/web/servicos/passaporte_ICAO.htm';
	 }else if (document.localidade.cidade.value=='2'){
		//window.location='passaporte_velho.htm';
		window.location='http://www.dpf.gov.br/web/servicos/passaporte_velho.htm?uf='+document.all.unidadeFederativa.value+'&cd='+document.all.municipio.value;
 		//window.location='http://10.61.5.12/desenvInternet/web/servicos/passaporte_velho.htm';	    		
	 }else{
	 	window.location='index.jsp';
	 }
}

/********************************************************************************
Nova Janela
********************************************************************************/
function novaJanela(pagina) { 
	window.open(pagina,'_black','width=625, height=610, top=10, left=30, screenX=100, screenY=100, toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=no, fullscreen=no, alwaysRaised=yes');
}

/********************************************************************************
MSG Barra de Status 
********************************************************************************/
function msgStatus() { 
	window.status='DPF';
}
/********************************************************************************
Função que monta combo Cidades
********************************************************************************/
var tXHR=0;
var id;
function XMLHTTPRequest() {
 if (window.XMLHttpRequest) { 
     a=new XMLHttpRequest(); } //Objeto nativo (FF/Safari/Opera7.6+)
 else {
   try { 
      a=new ActiveXObject("Msxml2.XMLHTTP");  //activeX (IE5.5+/MSXML2+)
   }   
   catch(e) {
     try { 
        a=new ActiveXObject("Microsoft.XMLHTTP"); //activeX (IE5+/MSXML1)
     }   
     catch(e) { /* O navegador nÃ£o tem suporte */ 
        a=false; 
     }
   }
 } 
 return a;
}

function atualizaCidades(uf,cidade,ident) {
	tXHR=XMLHTTPRequest();
	id=ident.id;
	if (tXHR) {
			cidade.length = 0;
			cidade.options[0] = new Option("        AGUARDE...        ","");
			//tXHR.open("GET", "servlet/Municipios?Estado="+uf.value+"&Cidades="+cidade.name, true);      
			tXHR.open("GET", "municipios?Estado="+uf.value+"&Cidades="+cidade.name, true);      
			tXHR.onreadystatechange=recebeResultado;
			tXHR.send(null);
	}
}

function recebeResultado() {
 if (!tXHR) {
	 return false;
 }
 else {
	 if (tXHR.readyState == 4) {             
		 if (tXHR.status == 200) {
       document.getElementById(id).innerHTML = tXHR.responseText;
		 }
		 else {
			 alert('Erro! "'+ tXHR.statusText +'" (erro '+ tXHR.status +')'); 
		 }
	 }    
 }
}

/********************************************************************************
redireciona
********************************************************************************/

function redireciona(){
	
	var valor 			= document.formulario.municipio.value.substr(0,1);
	var uf 				= document.all.unidadeFederativa.value;
	var valueMunicipio 	= document.all.municipio.value;
	var municipio 		= valueMunicipio.substr(2,valueMunicipio.indexOf("-")-2);
	var lotacao 		= valueMunicipio.substr(valueMunicipio.indexOf("-")+1);
	
	if (valor==0){
	 	document.formulario.action='index.jsp';
	}
	if (valor==1){
		document.formulario.action='passaporte_ICAO.jsp?UF='+uf+'&CD_MUNICIPIO='+municipio+'&CD_LOTACAO='+lotacao;
	}
	if (valor==2){
		document.formulario.action='';
		window.location = 'http://www.dpf.gov.br/web/servicos/passaporte_velho.htm?UF='+uf+'&CD_MUNICIPIO='+municipio+'&CD_LOTACAO='+lotacao;
		return false;
	}
}

/********************************************************************************
 FIM do ARQUIVO
********************************************************************************/