function concatenaDesc(form){
	with (document.forms[form]){
		if(elements[0].value==""){
			alert("Digite seu sobrenome.");
			elements[0].focus();
			return false;
		}
		else if(elements[0].value!=""){
			var rand = Math.floor(Math.random()*20);
			item_id.value=rand*9-rand;
			item_descr.value=item_descr.value+" - "+elements[0].value;
			submit();
			history.go(0);
			return true;
		}
		else{
			return false;
		}
	}
}

function concatenaDesc2 (form, idf){
	
	if(idf==1){
		with (document.forms[form-1]){
			if(elements[0].value==""){
				alert("Digite seu sobrenome.");
				elements[0].focus();
				return false;
			}
			else{
				var rand = Math.floor(Math.random()*11);
				document.forms[form].elements[3].value=rand*9-rand;
				document.forms[form].elements[4].value=document.forms[form].elements[4].value+" - "+document.forms[form-1].elements[0].value;
				alert(document.forms[form].elements[4].value);
				submit();
				return true;
			}
		}
	}
	else if (idf==2){
		with (document.forms[form-2]){
			if(elements[0].value==""){
				alert("Digite seu sobrenome.");
				elements[0].focus();
				return false;
			}
			else{
				var rand = Math.floor(Math.random()*11);
				document.forms[form].elements[3].value=rand*9-rand;
				document.forms[form].elements[4].value=document.forms[form].elements[4].value+" - "+document.forms[form-2].elements[0].value;
				alert(document.forms[form].elements[4].value);
				submit();
				return true;
			}
		}
	}
}

function camada(abre) {
	if(abre==1)
	{
		document.getElementById("divoculta").style.display="";
	}
	if(abre==2)
	{
		document.getElementById("divoculta").style.display="none";
        document.getElementById("divoculta1").style.display="none";
        document.getElementById("divoculta2").style.display="none";
	}
    if(abre==3)
	{
		document.getElementById("divoculta1").style.display="";
	}
	if(abre==4)
	{
		document.getElementById("divoculta2").style.display="";
	}
}

function validaCampos(qual){
	
		if(qual == "5"){
			with (document.formulario-brasoes){
			
			if(nome.value == ""){
				alert('Por favor informe seu nome');
				nome.focus();
				return false;
			}
			if(email.value == ""){
				alert('Por favor informe seu e-mail');
				email.focus();
				return false;
				}else if (!validaEmail(email, "formulario-brasoes", 2)){
					email.focus();
					email.select();
					return false;
			}
			else{
				alert('idiota!');
				submit();
				return true;
			}
		}
	}
	
		if(qual == "4"){
			with (document.certidao_imigrante){
			if(txt_nome.value == ""){
				alert('Por favor informe seu nome');
				txt_nome.focus();
				return false;
			}
			if(txt_email.value == ""){
				alert('Por favor informe seu e-mail');
				txt_email.focus();
				return false;
				}else if (!validaEmail(txt_email, "certidao-imigrante", 2)){
					txt_email.focus();
					txt_email.select();
					return false;
			}
			if(italiano.value == ""){
 				alert('Por favor informe o nome do italiano');
 				italiano.focus();
 				return false;
			}
			else{
				submit();
				return true;
			}
		}
	}
	
	if(qual == "3"){
		with (document.processo_italia){
			if(txt_nome.value == ""){
				alert('Por favor informe seu nome');
				txt_nome.focus();
				return false;
			}
			if(txt_email.value == ""){
				alert('Por favor informe seu e-mail');
				txt_email.focus();
				return false;
				}else if (!validaEmail(txt_email, "processo_italia", 2)){
					txt_email.focus();
					txt_email.select();
					return false;
			}
			if(txt_uf.value == ""){
				alert('Por favor informe seu estado');
				txt_uf.focus();
				return false;
			}
			if(txt_mensagem.value == ""){
 				alert('Por favor informe sua mensagem');
 				txt_mensagem.focus();
 				return false;
 			}else{
				submit();
				return true;
			}
		}
	}
	
	if(qual == "2"){
		with (document.frm_contato){
			if(txt_nome.value == ""){
				alert('Por favor informe seu nome');
				txt_nome.focus();
				return false;
			}
			if(txt_email.value == ""){
				alert('Por favor informe seu e-mail');
				txt_email.focus();
				return false;
				}else if (!validaEmail(txt_email, "frm_contato", 2)){
					txt_email.focus();
					txt_email.select();
					return false;
			}
			if(txt_uf.value == ""){
				alert('Por favor informe seu estado');
				txt_uf.focus();
				return false;
			}
			if(txt_mensagem.value == ""){
 				alert('Por favor informe sua mensagem');
 				txt_mensagem.focus();
 				return false;
 			}else{
				submit();
				return true;
			}
		}
		
	}else if(qual == "1"){
		with (document.frm_contato){
			if(txt_nome.value == ""){
				alert('Por favor informe seu nome');
				txt_nome.focus();
				return false;
			}
			if(txt_email.value == ""){
				alert('Por favor informe seu e-mail');
				txt_email.focus();
				return false;
				}else if (!validaEmail(txt_email, "frm_contato", 2)){
					txt_email.focus();
					txt_email.select();
					return false;
			}
 			if(txt_nome_ita.value == ""){
 				alert('Por favor informe o nome do Italiano');
 				txt_nome_ita.focus();
 				return false;
			}
 			if(txt_data_ita.value == ""){
 				alert('Por favor informe a data de nascimento do Italiano');
 				txt_data_ita.focus();
 				return false;
 			}
			if(txt_pai_ita.value == ""){
				alert('Por favor informe o pai do Italiano');
				txt_pai_ita.focus();
				return false;
			}
			if(txt_mae_ita.value == ""){
				alert('Por favor informe a mãe do Italiano');
				txt_mae_ita.focus();
				return false;
			}else{
				submit();
				return true;
			}
		}
	}
}

function mostraImagem(a,l,pg){
	l = eval(l) + 17;
	a = eval(a) + 4;
	if(a > 520) a = 520
	if(l > 650) l = 650
	nova_janela = window.open('','mostra_imagem','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,menubar=no,width=' +l+ ',height=' + a);
	nova_janela.document.writeln('<HTML><HEAD><TITLE></TITLE></HEAD><BODY style="margin=0px;text-align=center;"><IMG style="cursor=hand;" src="'+pg+'" onClick="window.close()" alt="Clique na imagem para fechar"></BODY></HTML>');
	nova_janela.document.close();
}

function validaEmail(email, formu, tipo){
	var sMail = new String(email.value)
	var index = sMail.indexOf("@");
	if (index > 0){
		var pindex = sMail.indexOf(".",index);
		if ((pindex > index+1) && (sMail.length > pindex+1)){
			result = true;
		}else{
			result = false;
		}
	}else{
		result = false;
	}
	if(!result){
		alert('EMAIL inexistente, por favor insira um e-mail válido.');
		if(tipo == 1){
			formu.elements[0].focus();
			formu.elements[0].select();
		}
	}else{
		if(tipo == 1){
			formu.submit();
		}else{
			return result;
		}
	}
}

function mostrar(tempId){
	var element=null;
	var id=tempId;

	clearTimeout(tempoLimite);

	if(document.getElementById){
		element=document.getElementById(id);

	}else if(document.all){
		element=document.all[id];

	}else if(document.layers){
		element=document.layers[id];
	}

	if(element){
		if(posIncialY==-200){
			posIncialY=0;
		}
		
		element.style.visibility="visible";
		levaTopoPos(id);
	}
}

function levaTopoPos(tempId){
	var id=tempId;

	var inicioX=0;

	if(aux){
		inicioY=0;

	}else{
		if(realTi){
			inicioY=-520;

		}else{
			inicioY=0;
		}
	}

	var ns=(navigator.appName.indexOf("Netscape")!=-1);
	var x=inicioX;
	var y=inicioY;

	function ml(id){
		var el;
		if(aux6){
			el=document.getElementById(id);

		}else if(initVal){
			el=document.all[id];

		}else if (aux){
			el.style=el;
		}

		el.sP=function(x,y){
			if(y>=posIncialY){
				if(el.style){
					el.style.left=x+"px";
					el.style.top=y+"px";

				}else{
					el.left=x;
					el.top=y;
				}
			}
		}

		el.x=inicioX;
		if(posicaoVert=="acima"){
			el.y=inicioY;

		}else{
			el.y=(ns)?pageYOffset+innerHeight:document.body.scrollTop+document.body.clientHeight;
			el.y-=inicioY;
		}

		return el;
	}

	window.manterEsquerda=function(){
		if(posicaoVert=="acima"){
			if(document.documentElement && document.documentElement.scrollTop){
				var pY=document.documentElement.scrollTop;
				objFlutuante.y+=(pY+inicioY-objFlutuante.y)/10;
				if(objFlutuante.y<posIncialY){
					objFlutuante.y=posIncialY
				}

			}else if(document.body){
				var pY=document.body.scrollTop;
				objFlutuante.y+=(pY+inicioY-objFlutuante.y)/10;
				if(objFlutuante.y<=posIncialY){
					objFlutuante.y=posIncialY
				}

			}else if(aux){
				var pY=window.pageYOffset;
				objFlutuante.y+=(pY+inicioY-objFlutuante.y)/10;
				if(objFlutuante.y<posIncialY){
					objFlutuante.y=posIncialY
				}
			}

		}else{
			pY=(ns)?window.pageYOffset+innerHeight:document.documentElement.scrollTop;
			objFlutuante.y+=(pY-inicioY-objFlutuante.y)/20;
		}

		objFlutuante.sP(objFlutuante.x,objFlutuante.y);
		setTimeout("manterEsquerda()", 10);
	}

	var objFlutuante=ml(id);
	manterEsquerda();
}

function ajustarFone(input, evento){
	var ie = (typeof window.ActiveXObject != 'undefined');  
	var tecla;  
	if (ie)
		tecla = evento.keyCode;
	else
		tecla = evento.which; 

	valor = input.value;
	valor = valor.replace( "(", "" );
	valor = valor.replace( ")", "" );
	valor = valor.replace( " ", "" );
	valor = valor.replace( "-", "" );
	tamanhoMaximo = 10;
	tamanho = valor.length;
	if(!soNumero(evento)){
		return false;
	} else { 
		if (tamanho < tamanhoMaximo && tecla != 8) {
		tamanho = valor.length + 1 ;
		}
		if (tecla == 8 ) {
			tamanho = tamanho - 1 ;
		}
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
			if ( tamanho <= 4 ) { 
				input.value = valor ;
			}
			if ( (tamanho > 4) && (tamanho <= 8) ) {
				input.value = valor.substr(0,tamanho-4) + '-' + valor.substr( tamanho - 4, tamanho ) ;
			}
			if ( (tamanho >= 9) && (tamanho <= 10) ) {
				input.value = '(' + valor.substr(0,2) + ') ' + valor.substr(2,tamanho-6) + '-' + valor.substr(tamanho-4,tamanho) ;			
			}
		}
	}
	return true;
}

//Completa a data com as barras "/"
function ajustarData(input, evento){
    if(!soNumero(evento)){
	    return false;
	} else { 
		if ((input.value.length == 2)||(input.value.length == 5)) {
		   input.value = input.value + "/" ;
		   }
	}
	return true;
}

function soNumero(evento){
	var BACKSPACE=  8; 
	var TAB= 9;
    var DEL=  46; 
    var FRENTE=  39; 
    var TRAS=  37; 
    var tecla= (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode)
    
    if (( tecla == BACKSPACE )||(tecla == DEL)||(tecla == FRENTE)||(tecla == TRAS)||(tecla == TAB)){
         return true; 
	}
    if ( tecla == 13 )     return false; 

	if ((tecla >= 48 && tecla <= 57) || (tecla == 44)) {
		return true;
	}else{
		evento.returnValue = false; 
		return false;
	}
}

function validaNome(){
	if(document.frm_busca.sobrenome.value.length < 4){
		alert('Atenção! Os sobrenomes têm no mínimo 4 letras.'); 
		return false;
	}else{
		document.frm_busca.submit();
		return true;
	}
}

// function addFavoritos(url, titulo){
//     if (window.sidebar) 
// 		window.sidebar.addPanel(titulo, url,"");
//     else if(window.opera && window.print)
// 	    {
// 		    var mbm = document.createElement('a');
// 			mbm.setAttribute('rel','sidebar');
// 			mbm.setAttribute('href',url);
// 			mbm.setAttribute('title',titulo);
// 			mbm.click();
// 		}else if(document.all)
// 		    {
// 			    window.external.AddFavorite(url, titulo);
// 			}
// }

function addFavoritos(url, title) {

        if (window.sidebar) { // Mozilla Firefox Bookmark
                window.sidebar.addPanel(title, url,"http://www.ferraracidadaniaitaliana.com.br/figuras/bandeira-icon.ico");
                return false;
        } 
        else if( window.external ) { // IE Favorite
                window.external.AddFavorite( url, title); 
                return false;
        }
        else if(window.opera && window.print) { // Opera Hotlist
                var elem = document.createElement('a');
                elem.setAttribute('href',url);
                elem.setAttribute('title',title);
                elem.setAttribute('rel','sidebar');
                elem.setAttribute('ico','http://www.ferraracidadaniaitaliana.com.br/figuras/bandeira-icon.ico');
                elem.click();
                return false;
        }
 }
 
var newWindow
function mostraExemplo(){
	newWindow = window.open("","");
    var newContent = "<HTML><HEAD><TITLE>Exemplo CNN</TITLE></HEAD>";
    newContent += "<BODY BGCOLOR='#dddddd'><img src = 'figuras/exemplo_cnn.jpg' border= '0'/>";
    newContent += "</BODY></HTML>";
    newWindow.document.write(newContent);
    newWindow.document.close();
}

function validaCampo(){
	with(document.frmbuscar){
		if (suggest1.value == ""){
			alert("Digite o sobrenome e depois clique no botão OK");
			return false;
		}else{
			submit();
			return true;
		}	
	}

}

function alteraReferencias(t,total){
	var i,dep,foto;
	id = parseFloat(document.getElementById("ref_controle").value); 
	//dep = arDep.split("|");
	//foto = arFoto.split("|");
	
	if (t == "d" && id > 1){
		//alert("Diminuir");
		//diminuir
		x = id - 1;
		document.getElementById("ref_controle").value = x;
		//document.getElementById("ref_depoimento").innerHTML = dep[x-1] + "...";
		//document.getElementById("ref_foto").innerHTML = foto[x-1];
		//document.getElementById("ref_foto").innerHTML = '<img style="border: 1px solid #27416f" src="fig_referencia/imagens.php?' + foto[x-1] + '" border="0">';
		document.getElementById("ref_depoimento").innerHTML = " " + document.getElementById("ref_depo_"+ x).value + "...";
		document.getElementById("ref_foto").innerHTML = '<img style="border: 1px solid #27416f" src="fig_referencia/imagens.php?' + document.getElementById("ref_foto_"+ x).value + '" border="0">';

	}else if(t == "a" && id < total){
		//alert("Aumentar");
		//aumentar
		x = id + 1;
		document.getElementById("ref_controle").value = x;
		//document.getElementById("ref_depoimento").innerHTML = dep[id] + "...";
		//document.getElementById("ref_foto").innerHTML = foto[id];
		//document.getElementById("ref_foto").innerHTML = '<img src="fig_referencia/imagens.php?' + foto[id] + '" border="0">';
		
		document.getElementById("ref_depoimento").innerHTML = document.getElementById("ref_depo_"+ x).value + "...";
		document.getElementById("ref_foto").innerHTML = '<img style="border: 1px solid #27416f" src="fig_referencia/imagens.php?' + document.getElementById("ref_foto_"+ x).value + '" border="0">';
	}else{
		//alert("Nada");
	}
	//alert(id);
}

/* Funções para mover caixa de banners da direita - até a linha 719 */

		function verificaCarga(){
			/*funcao presente no rodape*/
					
			
			if(document.documentElement && document.documentElement.scrollTop){
				var scrollCurrent = document.documentElement.scrollTop;

			}else if(document.body && document.body.scrollTop){
				var scrollCurrent = document.body.scrollTop;

			}else if(navigator.appName == "Netscape"){
				var scrollCurrent = window.pageYOffset;
			}

			if(scrollCurrent != iniciaSc){
				mostraTempo = setTimeout("mostraFlutuante()",50);

			}else{
				tempoLimite = setTimeout("verificaCarga()",50);
			}
		}

		function mostraFlutuante(){
			mostrar("flutuante");
		}

		function mostrar(tempId){
			var element = null;
			var id = tempId;

			clearTimeout(tempoLimite);

			if(document.getElementById){
				element = document.getElementById(id);

			}else if(document.all){
				element = document.all[id];

			}else if(document.layers){
				element = document.layers[id];
			}

			if(element){
				if(posIncialY == fixedYPosition){
					posIncialY = 0;
				}

				element.style.visibility = "visible";
				levaTopoPos(id);
			}
		}


		function levaTopoPos(tempId){
			var id = tempId;

			var inicioX = 0;

			if(aux){
				inicioY = -340;

			}else{
				if(realTi){
					inicioY = -340;

				}else{
					inicioY = -340;
				}
			}

			var ns = (navigator.appName.indexOf("Netscape")!=-1);
			var x = inicioX;
			var y = inicioY;

			function ml(id){
				var el;
				if(aux6){
					el = document.getElementById(id);

				}else if(initVal){
					el = document.all[id];

				}else if (aux){
					el.style = el;
				}

				el.sP = function(x,y){
					if(y >= posIncialY){
						if(el.style){
							el.style.left = x+"px";
							el.style.top = y+"px";

						}else{
							el.left = x;
							el.top = y;
						}
					}
				}

				el.x = inicioX;
				if(posicaoVert == "acima"){
					el.y = inicioY;
				}else{
					el.y = (ns) ? pageYOffset+innerHeight : document.body.scrollTop+document.body.clientHeight;
					el.y -= inicioY;
				}

				return el;
			}

			window.manterEsquerda = function(){
				if(posicaoVert == "acima"){
					if(document.documentElement && document.documentElement.scrollTop){
						var pY = document.documentElement.scrollTop;
						objFlutuante.y += (pY+inicioY-objFlutuante.y)/10;
						if(objFlutuante.y < posIncialY){
							objFlutuante.y = posIncialY
						}

					}else if(document.body){
						var pY = document.body.scrollTop;
						objFlutuante.y += (pY+inicioY-objFlutuante.y)/10;
						if(objFlutuante.y <= posIncialY){
							objFlutuante.y = posIncialY
						}

					}else if(aux){
						var pY = window.pageYOffset;
						objFlutuante.y += (pY+inicioY-objFlutuante.y)/10;
						if(objFlutuante.y < posIncialY){
							objFlutuante.y = posIncialY
						}
					}

				}else{
					pY = (ns) ? window.pageYOffset+innerHeight : document.documentElement.scrollTop;
					objFlutuante.y += (pY-inicioY-objFlutuante.y)/20;
				}

				objFlutuante.sP(objFlutuante.x,objFlutuante.y);
				setTimeout("manterEsquerda()", 10);
			}

			var objFlutuante = ml(id);
			manterEsquerda();
		}

/* Fim das funções de movimento da caixa direita de banners */

/* funcoes da arvore genealogica*/

function verificaSelect(tipo){
	var url;
	document.getElementById("btn_arvore").style.display = "";
	url = "cria_selects.php?tipo="+tipo;
		$("#outrosSelects").load(url);
		

}

function gerarArvore(){
	var select01;
	var select02;
	var select03;
	var select04;
	var img="";	

	//imagem carregandooo
	select01 = document.getElementById("se_01").value;
	//cada select gera uma imagem diferente
	if (select01 != "")
		document.getElementById("mostraArvore").innerHTML = '<img name="carregando" id="carregando" src="figuras/processando.gif">';


	switch(select01){
		case "0": 
			select02 = document.getElementById("se_02").value;
			select03 = document.getElementById("se_03").value;	
			select04 = document.getElementById("se_04").value;
			break;	
		case "1":
			select02 = document.getElementById("se_02").value;
			select03 = document.getElementById("se_03").value;	
			select04 = document.getElementById("se_04").value;
			break;
		case "2":
			select02 = document.getElementById("se_02").value;
			select03 = document.getElementById("se_03").value;	
			break;
		case "3":
			select02 = document.getElementById("se_02").value;
			select03 = document.getElementById("se_03").value;	
			break;
		case "4":
			select02 = document.getElementById("se_02").value;
			break;
		case "5": 
			select02 = document.getElementById("se_02").value;
			break;
	}

	//se for mae
	if (select01 == "7")
		img =  "1.jpg";

	//se for pai	
	if (select01 == "6")
		img =  "0.jpg";

	//se for avó
	if (select01 == "5"){
		//se for mae
		if (select02 == "1")
			img =  "11.jpg";
		//se for pai	
		if (select02 == "0")
			img =  "10.jpg";
	}

	//se for avô	
	if (select01 == "4"){
		//se for mae
		if (select02 == "1")
			img =  "01.jpg";
		//se for pai	
		if (select02 == "0")
			img =  "00.jpg";
	}

	//se for bisavó
	if (select01 == "3"){
		//se for avó
		if (select02 == "1"){
			//se for mae
			if (select03 == "1")
				img =  "111.jpg";
			//se for pai	
			if (select03 == "0")
				img =  "110.jpg";
		}else{
				//se for mae
			if (select03 == "1")
				img =  "101.jpg";
			//se for pai	
			if (select03 == "0")
				img =  "100.jpg";
		}
	}

	//se for bisavô
	if (select01 == "2"){
		//se for avó
		if (select02 == "1"){
			//se for mae
			if (select03 == "1")
				img =  "011.jpg";
			//se for pai	
			if (select03 == "0")
				img =  "010.jpg";
		}else{
				//se for mae
			if (select03 == "1")
				img =  "001.jpg";
			//se for pai	
			if (select03 == "0")
				img =  "000.jpg";
		}
	}	

	//se for tataravó
	if (select01 == "1"){
		//se for bisavó
		if (select02 == "1"){
			//se for avó
			if (select03 == "1"){
				//se for mae
				if (select04 == "1")
					img =  "1111.jpg";
				//se for pai	
				if (select04 == "0")
					img =  "1110.jpg";
			}else{
					//se for mae
				if (select04 == "1")
					img =  "1101.jpg";
				//se for pai	
				if (select04 == "0")
					img =  "1100.jpg";
			}
		}else{
			//se for avó
			if (select03 == "1"){
				//se for mae
				if (select04 == "1")
					img =  "1011.jpg";
				//se for pai	
				if (select04 == "0")
					img =  "1010.jpg";
			}else{
					//se for mae
				if (select04 == "1")
					img =  "1001.jpg";
				//se for pai	
				if (select04 == "0")
					img =  "1000.jpg";
			}		
		}
	}

	//se for tataravô
	if (select01 == "0"){
		//se for bisavó
		if (select02 == "1"){
			//se for avó
			if (select03 == "1"){
				//se for mae
				if (select04 == "1")
					img =  "0111.jpg";
				//se for pai	
				if (select04 == "0")
					img =  "0110.jpg";
			}else{
					//se for mae
				if (select04 == "1")
					img =  "0101.jpg";
				//se for pai	
				if (select04 == "0")
					img =  "0100.jpg";
			}
		}else{
			//se for avó
			if (select03 == "1"){
				//se for mae
				if (select04 == "1")
					img =  "0011.jpg";
				//se for pai	
				if (select04 == "0")
					img = "0010.jpg";
			}else{
					//se for mae
				if (select04 == "1")
					img = "0001.jpg";
				//se for pai	
				if (select04 == "0")
					img = "0000.jpg";
			}		
		}
	}

	if (select01 != ""){
		//carregar as imagens para visualização
		document.getElementById("imagem").value = img;
		var url;
		url = "imagens_arvore/" + img;
		document.getElementById("mostraArvore").innerHTML = '<img src="'+url+'" border="0" title="Árvore Genealógica">';
		document.getElementById("btn_imprime").style.display = "";
	}else{
		alert("Por favor selecione o seu ascendente italiano.");
	}	
}

function imprimeArvore()
{
		   var img;
		   img = document.getElementById("imagem").value;
		   var total = img.length - 4;
		   img = img.substr(0,total) + ".gif";
		   var url = "cidadania-italiana-impressao-arvore-genealogica.php?img="+img;
		   myWindow = window.open(url,"ArvoreGenealogica","width=650,height=700,scrollbars=yes");
		   
		   //myWindow.document.write(texto);		  
		   //myWindow.history.go(0);
}
/*fim das funcores da arvore genealogica*/


/*funcoes da pagina quem tem direito com Ajax*/

function geraSelectQuemTemDireito(tipo){
	var url;
	if (tipo != ""){
		url = "ifr-quem-tem-direito.php?tipo="+tipo;
		$("#proximosSelects").show();
		$("#proximosSelects").load(url);
	}else{		
		$("#proximosSelects").hide();
		$("#primeiraResposta").hide();
		$("#segundaResposta").hide();
		$("#terceiraResposta").hide();
		$("#quartaResposta").hide();
		$("#quintaResposta").hide();
	}	
}


function geraResultadoQTD(){
	var texto = 0;
	var ano;
	var sel1,sel2,sel3,sel4;
	
	sel1 = document.getElementById("se_01").value;
	if (sel1 == "1" || sel1 == "0"){
		sel2 = document.getElementById("se_02").value;
		sel3 = document.getElementById("se_03").value;
		sel4 = document.getElementById("se_04").value;
		
		ano1 = parseInt(document.getElementById("ano1").value);
		ano2 = parseInt(document.getElementById("ano2").value);
		ano3 = parseInt(document.getElementById("ano3").value);
		ano4 = parseInt(document.getElementById("ano4").value);
		
		if ((sel1 == "1" && ano1 < 1948) || (sel2 == "1" && ano2 < 1948) || (sel3 == "1" && ano3 < 1948) || (sel4 == "1" && ano4 < 1948))
			texto = 1;
				
	}else if (sel1 == "3" || sel1 == "2"){
		sel2 = document.getElementById("se_02").value;
		sel3 = document.getElementById("se_03").value;

		ano1 = parseInt(document.getElementById("ano1").value);
		ano2 = parseInt(document.getElementById("ano2").value);
		ano3 = parseInt(document.getElementById("ano3").value);

		if ((sel1 == "3" && ano1 < 1948) || (sel2 == "1" && ano2 < 1948) || (sel3 == "1" && ano3 < 1948))
			texto = 1;
				
	}else if (sel1 == "5" || sel1 == "4"){
		sel2 = document.getElementById("se_02").value;

		ano1 = parseInt(document.getElementById("ano1").value);
		ano2 = parseInt(document.getElementById("ano2").value);

		if ((sel1 == "5" && ano1 < 1948) || (sel2 == "1" && ano2 < 1948))
			texto = 1;
				
	}else if (sel1 == "7" || sel1 == "6"){
		ano1 = parseInt(document.getElementById("ano1").value);
		if (sel1 == "7" && ano1 < 1948)
			texto = 1;
	}	
	
	
	if (texto == 0)	{	
		$("#primeiraResposta").show();
		$("#segundaResposta").hide();
		$("#terceiraResposta").hide();
		$("#quartaResposta").hide();
		$("#quintaResposta").hide();
	}else{
		$("#primeiraResposta").hide();
		$("#segundaResposta").hide();
		$("#terceiraResposta").hide();
		$("#quartaResposta").hide();
		$("#quintaResposta").show();
	}
}

function geraResultadoNat(){
	var radio;
	if (document.form_brasil.nat_brasil[0].checked){
		$("#segundaResposta").show();
		$("#quartaResposta").hide();
	}else{
		$("#segundaResposta").hide();
		$("#terceiraResposta").hide();
		$("#quintaResposta").hide();
		$("#quartaResposta").show();		
	}
}

function geraResultadoDoc(){
	dt1 = parseFloat(document.getElementById("dtano1").value);
	dt2 = parseFloat(document.getElementById("dtano2").value);
	if (dt2 < dt1){
		//alert("Ter"+dt1+"-"+dt2);
		$("#terceiraResposta").show();
		$("#sextaResposta").hide();
	}else{
		//alert("Sex"+dt1+"-"+dt2);
		$("#sextaResposta").show();
		$("#terceiraResposta").hide();			
	}
}


function verificaCampo(campo){
	var div;
	if (campo.name == "se_02"){
		div = document.getElementById("nasceu2");
		if (campo.value == "0")
			div.style.display = "none";
		else
			div.style.display = ""
	}else if(campo.name == "se_03"){
		div = document.getElementById("nasceu3");
		if (campo.value == "0")
			div.style.display = "none";
		else
			div.style.display = "";
	}else if (campo.name == "se_04"){
		div = document.getElementById("nasceu4");
		if (campo.value == "0")
			div.style.display = "none";
		else
			div.style.display = "";	
	}
	
}

/*fim das funcoes da pagina quem tem direito com Ajax*/

/*Funcoes da banco de dados*/

function verificaSobrenome(){
	with(document.frm_sobrenome){
		if(suggest5.value == ""){
			alert("Digite seu sobrenome!");
			suggest5.focus();
			return false;
		}else{
			submit();
			return true;
		}
	}
}
/*fm das funcoes do banco de dados*/


/*funcoes da doc exigidos*/
function verificaSelectDoc(id){
	var url;
	if (id == "")
		alert("Selecione o seu ascedente italiano.");
	else{	
		//document.getElementById("carregando").style.display = "";
		url = "div_docs_exigidos.php?id="+id;
		$("#conteudo_docs").load(url);
		//document.getElementById("carregando").style.display = "none";	
	}
}

function verifica_casouse(id){
	if(id == 0){
		var select02 = document.getElementById("select02").value;
		if (select02 == "S"){
			document.getElementById("select03").style.display = "";
			document.getElementById("select04").style.display = "";
			document.getElementById("span03").style.display = "";
			document.getElementById("span04").style.display = "";
		}else{
			document.getElementById("select03").style.display = "none";
			document.getElementById("select04").style.display = "none";
			document.getElementById("span03").style.display = "none";
			document.getElementById("span04").style.display = "none";
		}
	}else if(id == 1){			
		var select12 = document.getElementById("select12").value;
		if (select12 == "S"){
			document.getElementById("select14").style.display = "";
			document.getElementById("span14").style.display = "";
		}else{
			document.getElementById("select14").style.display = "none";
			document.getElementById("span14").style.display = "none";
		}
	}else if(id == 2){
		var select22 = document.getElementById("select22").value;
		if (select22 == "S"){
			document.getElementById("select24").style.display = "";
			document.getElementById("span24").style.display = "";
		}else{
			document.getElementById("select24").style.display = "none";
			document.getElementById("span24").style.display = "none";
		}
	}else if(id == 3){
		var select32 = document.getElementById("select32").value;
		if (select32 == "S"){
			document.getElementById("select34").style.display = "";
			document.getElementById("span34").style.display = "";
		}else{
			document.getElementById("select34").style.display = "none";
			document.getElementById("span34").style.display = "none";
		}
	}
}

/*
function geraDocsExigidos(){
	var select01 = document.getElementById("select01").value;
	var select02;
	var select03;
	var select04;
	var x = 0;
	if (select01 == ""){
		alert("Selecione seu ascedente italiano.");
		x = 1;
	}else{
		//se for avoh ou avo
		if (select01 == "4" || select01 == "5"){
			select11 = document.getElementById("select11").value;
			if (select11 == ""){
				alert("Selecione seu Próximo ascedente italiano.");
				x = 1;
			}
		}
		//se for bisavo ou bisavoh
		if (select01 == "2" || select01 == "3"){
			select11 = document.getElementById("select11").value;
			select21 = document.getElementById("select21").value;
			if (select11 == "" || select21 == ""){
				alert("Selecione seu Próximo ascedente italiano.");
				x = 1;
			}
		}
		//se for trisavo ou trisavoh
		if (select01 == "0" || select01 == "1"){
			select11 = document.getElementById("select11").value;
			select21 = document.getElementById("select21").value;
			select31 = document.getElementById("select31").value;
			if (select11 == "" || select21 == "" || select31 == ""){
				alert("Selecione seu Próximo ascedente italiano.");
				x = 1;
			}
		}

	}
	//todos os dados requeridos foram preenchidos
	if (x == 0){
		//url = "div_docs_exigidos.php?mostra=1";
		//$("#mostra_docs").load(url);
		//mae ou pai
		var texto = "";
		if (select01 == "7" || select01 == "6"){
			if (select01 == "7")
				texto += '<img src="doc_exigidos/mae.gif">';
			else
				texto += '<img src="doc_exigidos/pai.gif">';
			if (select02 == "S"){
				if (select04 == "S"){
						texto += '<br> - 1° Casamento (com averbação de Divorcio)';
						texto += '<br> - 2° Casamento (se ocorreu)';
				}else{
					if (select03 == "B")
						texto += '<br> - Casamento (no Brasil)';
					else
						texto += '<br> - Matrimonio (na Itália)';
				}					
			}else{
				texto += '<br> - Nascita ou battesimo(na Itália)';
			}
			if (select04 == "S")
				texto += '<br> - Óbito';
		}
		//se eh vo ou voh
		if (select01 == "5" || select01 == "4"){
			if (select01 == "5")
				texto += '<img src="doc_exigidos/mae.gif">';
			else
				texto += '<img src="doc_exigidos/pai.gif">';
			if (select02 == "S"){
				if (select04 == "S"){
						texto += '<br> - 1° Casamento (com averbação de Divorcio)';
						texto += '<br> - 2° Casamento (se ocorreu)';
				}else{
					if (select03 == "B")
						texto += '<br> - Casamento (no Brasil)';
					else
						texto += '<br> - Matrimonio (na Itália)';
				}					
			}else{
				texto += '<br> - Nascita ou battesimo(na Itália)';
			}
			if (select04 == "S")
				texto += '<br> - Óbito';
		}			
	}	
}*/


function geraDocsExigidos(){
	var select01 = document.getElementById("select01").value;
	var img;
	
		var x = 0;
	if (select01 == ""){
		alert("Selecione seu ascedente italiano.");
		x = 1;
	}else{
		//se for avoh ou avo
		if (select01 == "4" || select01 == "5"){
			select11 = document.getElementById("select11").value;
			if (select11 == ""){
				alert("Selecione seu Próximo ascedente italiano.");
				x = 1;
			}
		}
		//se for bisavo ou bisavoh
		if (select01 == "2" || select01 == "3"){
			select11 = document.getElementById("select11").value;
			select21 = document.getElementById("select21").value;
			if (select11 == "" || select21 == ""){
				alert("Selecione seu Próximo ascedente italiano.");
				x = 1;
			}
		}
		//se for trisavo ou trisavoh
		if (select01 == "0" || select01 == "1"){
			select11 = document.getElementById("select11").value;
			select21 = document.getElementById("select21").value;
			select31 = document.getElementById("select31").value;
			if (select11 == "" || select21 == "" || select31 == ""){
				alert("Selecione seu Próximo ascedente italiano.");
				x = 1;
			}
		}

	}
	
	
	
if (x == 0){	
	document.getElementById("id0e").value = "";
	document.getElementById("id1e").value = "";
	document.getElementById("id2e").value = "";
	document.getElementById("id3e").value = "";
	document.getElementById("id0d").value = "";
	document.getElementById("id1d").value = "";
	document.getElementById("id2d").value = "";
	document.getElementById("id3d").value = "";
	
	
	document.getElementById("img_processando").style.display = "";
	//mae=7
	if (select01 == "7")
		img = "1.jpg";
	//pai=6
	if (select01 == "6")
		img = "0.jpg";
	//avoh=5
	if (select01 == "5"){
		var select11 = document.getElementById("select11").value;
		if (select11 == "0")
			img = "10.jpg";
		else
			img = "11.jpg";	
	}
	//avo=4
	if (select01 == "4"){
		var select11 = document.getElementById("select11").value;
		if (select11 == "0")
			img = "00.jpg";
		else
			img = "01.jpg";	
	}
	//bisavoh=3
	if (select01 == "3"){
		var select11 = document.getElementById("select11").value;
		if (select11 == "0"){
			var select21 = document.getElementById("select21").value;
			if (select21 == "0")
				img = "100.jpg";
			else
				img = "101.jpg";	
		}else{
			var select21 = document.getElementById("select21").value;
			if (select21 == "0")
				img = "110.jpg";
			else
				img = "111.jpg";
		}
	}
	//bisavo=2
	if (select01 == "2"){
		var select11 = document.getElementById("select11").value;
		if (select11 == "0"){
			var select21 = document.getElementById("select21").value;
			if (select21 == "0")
				img = "000.jpg";
			else
				img = "001.jpg";	
		}else{
			var select21 = document.getElementById("select21").value;
			if (select21 == "0")
				img = "010.jpg";
			else
				img = "011.jpg";
		}
	}

	//trisavoh=1
	if (select01 == "1"){
		var select11 = document.getElementById("select11").value;
		if (select11 == "0"){
			var select21 = document.getElementById("select21").value;
			if (select21 == "0"){
				var select31 = document.getElementById("select31").value;
				if (select31 == "0")
					img = "1000.jpg";
				else
					img = "1001.jpg";	
			}else{
				var select31 = document.getElementById("select31").value;
				if (select31 == "0")
					img = "1010.jpg";
				else
					img = "1011.jpg";
			}
		}else{
			var select21 = document.getElementById("select21").value;
			if (select21 == "0"){
				var select31 = document.getElementById("select31").value;
				if (select31 == "0")
					img = "1100.jpg";
				else
					img = "1101.jpg";	
			}else{
				var select31 = document.getElementById("select31").value;
				if (select31 == "0")
					img = "1110.jpg";
				else
					img = "1111.jpg";
			}

		}
	}
	//trisavoh=1
	if (select01 == "0"){
		var select11 = document.getElementById("select11").value;
		if (select11 == "0"){
			var select21 = document.getElementById("select21").value;
			if (select21 == "0"){
				var select31 = document.getElementById("select31").value;
				if (select31 == "0")
					img = "0000.jpg";
				else
					img = "0001.jpg";	
			}else{
				var select31 = document.getElementById("select31").value;
				if (select31 == "0")
					img = "0010.jpg";
				else
					img = "0011.jpg";
			}
		}else{
			var select21 = document.getElementById("select21").value;
			if (select21 == "0"){
				var select31 = document.getElementById("select31").value;
				if (select31 == "0")
					img = "0100.jpg";
				else
					img = "0101.jpg";	
			}else{
				var select31 = document.getElementById("select31").value;
				if (select31 == "0")
					img = "0110.jpg";
				else
					img = "0111.jpg";
			}

		}
	}
	
	document.getElementById("imagem").value = img;
	//alert(img);
	//zerar as divs que recebem
	document.getElementById("d0d").innerHTML = "";
	document.getElementById("d1d").innerHTML = "";
	document.getElementById("d2d").innerHTML = "";
	document.getElementById("d3d").innerHTML = "";
	document.getElementById("d0e").innerHTML = "";
	document.getElementById("d1e").innerHTML = "";
	document.getElementById("d2e").innerHTML = "";
	document.getElementById("d3e").innerHTML = "";
	//aumentar a div de acordo comas imagens
	$("#mostra_docs").width(550);
	if (select01 == "6" || select01 == "7"){
		$("#mostra_docs").height(131);
		$("#d0e").height(61);
		$("#d0d").height(61);
		$("#d0e").css("margin-top",35);
		$("#d0d").css("margin-top",35);
	}
	if (select01 == "4" || select01 == "5"){
		$("#mostra_docs").height(232);
		$("#d0e").height(61);
		$("#d0d").height(61);
		$("#d1e").height(61);
		$("#d1d").height(61);
		$("#d0e").css("margin-top",35);
		$("#d0d").css("margin-top",35);
		$("#d1e").css("margin-top",35);
		$("#d1d").css("margin-top",35);
	}
	if (select01 == "2" || select01 == "3"){
		$("#mostra_docs").height(330);
		$("#d0e").height(61);
		$("#d0d").height(61);
		$("#d1e").height(61);
		$("#d1d").height(61);
		$("#d2e").height(61);
		$("#d2d").height(61);
		$("#d0e").css("margin-top",35);
		$("#d0d").css("margin-top",35);
		$("#d1e").css("margin-top",35);
		$("#d1d").css("margin-top",35);
		$("#d2e").css("margin-top",35);
		$("#d2d").css("margin-top",35);
	}
	if (select01 == "0" || select01 == "1"){
		$("#mostra_docs").height(427);	
		$("#d0e").height(61);
		$("#d0d").height(61);
		$("#d1e").height(61);
		$("#d1d").height(61);
		$("#d2e").height(61);
		$("#d2d").height(61);
		$("#d3e").height(61);
		$("#d3d").height(61);
		$("#d0e").css("margin-top",35);
		$("#d0d").css("margin-top",35);
		$("#d1e").css("margin-top",35);
		$("#d1d").css("margin-top",35);
		$("#d2e").css("margin-top",35);
		$("#d2d").css("margin-top",35);
		$("#d3e").css("margin-top",35);
		$("#d3d").css("margin-top",35);	
	}
	
	//muda o background da div com o conteudo
	var src = "url(imagens_arvore/"+img+")";
	$("#mostra_docs").css("background-image",src);
	//colocar os conteudos dentro da div
	
	//escrever os conteudos na div
	
	var texto = "";
	var select02 = document.getElementById("select02").value;
	var select03 = document.getElementById("select03").value;
	var select04 = document.getElementById("select04").value;
	var select05 = document.getElementById("select05").value;
	
	//verificando a mae ou pai
	if (select01 == "7" || select01 == "6"){		
		texto += ' - Nascita ou battesimo(na Itália)';
		if (select02 == "S"){
			if (select04 == "S"){
					texto += '<br> - 1° Casamento (com averbação de Divorcio)';
					texto += '<br> - 2° Casamento (se ocorreu)';
			}else{
				if (select03 == "B")
					texto += '<br> - Casamento (no Brasil)';
				else
					texto += '<br> - Matrimonio (na Itália)';
			}					
		}
		
		if (select05 == "S")
			texto += '<br> - Óbito';
			
		texto += '<br> - <a href="cidadania-italiana-cnn-certidao-naturalizacao.php" target="_blank" alt="Cidadania Italiana Certidão Negativa de Naturalização" title="Cidadania Italiana Certidão Negativa de Naturalização">Certidão Negativa de Naturalização</a>';	
		
		//coloca o conteudo
		if (select01 == "7"){
			document.getElementById("id0d").value = texto;
			document.getElementById("d0d").innerHTML = texto;
		}else{
			document.getElementById("d0e").innerHTML = texto;
			document.getElementById("id0e").value = texto;	
		}
	}// fim da mae e pai
	
	
	//avo e avoh
	if (select01 == "5" || select01 == "4"){
		texto += ' - Nascita ou battesimo(na Itália)';
		if (select02 == "S"){
			if (select04 == "S"){
					texto += '<br> - 1° Casamento (com averbação de Divorcio)';
					texto += '<br> - 2° Casamento (se ocorreu)';
			}else{
				if (select03 == "B")
					texto += '<br> - Casamento (no Brasil)';
				else
					texto += '<br> - Matrimonio (na Itália)';
			}					
		}
		
		if (select05 == "S")
			texto += '<br> - Óbito';
			
		texto += '<br> - <a href="cidadania-italiana-cnn-certidao-naturalizacao.php" target="_blank" alt="Cidadania Italiana Certidão Negativa de Naturalização" title="Cidadania Italiana Certidão Negativa de Naturalização">Certidão Negativa de Naturalização</a>';	
	
		//coloca o conteudo
		if (select01 == "5"){
			document.getElementById("d0d").innerHTML = texto;
			document.getElementById("id0d").value = texto;
		}else{
			document.getElementById("d0e").innerHTML = texto;
			document.getElementById("id0e").value = texto;
		}
			
		//filhos dos avos 
		texto = "";
		select11 = document.getElementById("select11").value; //pai ou mae
		select12 = document.getElementById("select12").value; //casou-se
		select14 = document.getElementById("select14").value; //divorciou-se
		select15 = document.getElementById("select15").value; //morreu	
		texto += '<br> - Nascimento';
		if (select12 == "S"){
			if (select14 == "S"){
					texto += '<br> - 1° Casamento (com averbação de Divorcio)';
					texto += '<br> - 2° Casamento (se ocorreu)';
			}else{
					texto += '<br> - Casamento';
				}					
		}
		
		if (select15 == "S")
			texto += '<br> - Óbito';
		//coloca o conteudo
		if (select11 == "1"){
			document.getElementById("d1d").innerHTML = texto;
			document.getElementById("id1d").value = texto;
		}else{
			document.getElementById("d1e").innerHTML = texto;
			document.getElementById("id1e").value = texto; 	
		}		
	}/*fim do avo ou avoh*/
	
	
	//bisavo e bisavoh
	if (select01 == "3" || select01 == "2"){
		texto += ' - Nascita ou battesimo(na Itália)';
		if (select02 == "S"){
			if (select04 == "S"){
					texto += '<br> - 1° Casamento (com averbação de Divorcio)';
					texto += '<br> - 2° Casamento (se ocorreu)';
			}else{
				if (select03 == "B")
					texto += '<br> - Casamento (no Brasil)';
				else
					texto += '<br> - Matrimonio (na Itália)';
			}					
		}
		
		if (select05 == "S")
			texto += '<br> - Óbito';
			
		texto += '<br> - <a href="cidadania-italiana-cnn-certidao-naturalizacao.php" target="_blank" alt="Cidadania Italiana Certidão Negativa de Naturalização" title="Cidadania Italiana Certidão Negativa de Naturalização">Certidão Negativa de Naturalização</a>';	
	
		//coloca o conteudo
		if (select01 == "3"){
			document.getElementById("d0d").innerHTML = texto;
			document.getElementById("id0d").value = texto;
		}else{
			document.getElementById("d0e").innerHTML = texto;
			document.getElementById("id0e").value = texto;
		}

		//filhos dos avos 
		texto = "";
		select11 = document.getElementById("select11").value; //pai ou mae
		select12 = document.getElementById("select12").value; //casou-se
		select14 = document.getElementById("select14").value; //divorciou-se
		select15 = document.getElementById("select15").value; //morreu	
		texto += '<br> - Nascimento';
		if (select12 == "S"){
			if (select14 == "S"){
					texto += '<br> - 1° Casamento (com averbação de Divorcio)';
					texto += '<br> - 2° Casamento (se ocorreu)';
			}else{
					texto += '<br> - Casamento';				
			}					
		}
		
		if (select15 == "S")
			texto += '<br> - Óbito';
		//coloca o conteudo
		if (select11 == "1"){
			document.getElementById("id1d").value = texto;
			document.getElementById("d1d").innerHTML = texto;
		}else{
			document.getElementById("d1e").innerHTML = texto;
			document.getElementById("id1e").value = texto;
		}
		
		//filhos dos avos 
		texto = "";
		select21 = document.getElementById("select21").value; //pai ou mae
		select22 = document.getElementById("select22").value; //casou-se
		select24 = document.getElementById("select24").value; //divorciou-se
		select25 = document.getElementById("select25").value; //morreu	
		texto += '<br> - Nascimento';
		if (select22 == "S"){
			if (select24 == "S"){
					texto += '<br> - 1° Casamento (com averbação de Divorcio)';
					texto += '<br> - 2° Casamento (se ocorreu)';
			}else{
				texto += '<br> - Casamento';
			}					
		}
		if (select25 == "S")
			texto += '<br> - Óbito';
		//coloca o conteudo
		if (select21 == "1"){
			document.getElementById("d2d").innerHTML = texto;
			document.getElementById("id2d").value = texto;
		}else{
			document.getElementById("d2e").innerHTML = texto;
			document.getElementById("id2e").value = texto;
		}	
					
	}/*fim do bisavo ou bisavoh*/
	
	
	
	//tataravo ou tataravoh
	if (select01 == "1" || select01 == "0"){
		texto += ' - Nascita ou battesimo(na Itália)';
		if (select02 == "S"){
			if (select04 == "S"){
					texto += '<br> - 1° Casamento (com averbação de Divorcio)';
					texto += '<br> - 2° Casamento (se ocorreu)';
			}else{
				if (select03 == "B")
					texto += '<br> - Casamento (no Brasil)';
				else
					texto += '<br> - Matrimonio (na Itália)';
			}					
		}
		if (select05 == "S")
			texto += '<br> - Óbito';
			
		texto += '<br> - <a href="cidadania-italiana-cnn-certidao-naturalizacao.php" target="_blank" alt="Cidadania Italiana Certidão Negativa de Naturalização" title="Cidadania Italiana Certidão Negativa de Naturalização">Certidão Negativa de Naturalização</a>';	
	
		//coloca o conteudo
		if (select01 == "3"){
			document.getElementById("d0d").innerHTML = texto;
			document.getElementById("id0d").value = texto;
		}else{
			document.getElementById("d0e").innerHTML = texto;
			document.getElementById("id0e").value = texto;
		}

		//filhos dos avos 
		texto = "";
		select11 = document.getElementById("select11").value; //pai ou mae
		select12 = document.getElementById("select12").value; //casou-se
		select14 = document.getElementById("select14").value; //divorciou-se
		select15 = document.getElementById("select15").value; //morreu	
		texto += '<br> - Nascimento';
		if (select12 == "S"){
			if (select14 == "S"){
					texto += '<br> - 1° Casamento (com averbação de Divorcio)';
					texto += '<br> - 2° Casamento (se ocorreu)';
			}else{
				texto += '<br> - Casamento';				
			}					
		}
		
		if (select15 == "S")
			texto += '<br> - Óbito';
		//coloca o conteudo
		if (select11 == "1"){
			document.getElementById("id1d").value = texto;
			document.getElementById("d1d").innerHTML = texto;
		}else{
			document.getElementById("d1e").innerHTML = texto;
			document.getElementById("id1e").value = texto;
		}

		//filhos dos avos 
		texto = "";
		select21 = document.getElementById("select21").value; //pai ou mae
		select22 = document.getElementById("select22").value; //casou-se
		select24 = document.getElementById("select24").value; //divorciou-se
		select25 = document.getElementById("select25").value; //morreu	
		texto += '<br> - Nascimento';
		if (select22 == "S"){
			if (select24 == "S"){
					texto += '<br> - 1° Casamento (com averbação de Divorcio)';
					texto += '<br> - 2° Casamento (se ocorreu)';
			}else{
				texto += '<br> - Casamento';
			}					
		}
		if (select25 == "S")
			texto += '<br> - Óbito';
		//coloca o conteudo
		if (select21 == "1"){
			document.getElementById("d2d").innerHTML = texto;
			document.getElementById("id2d").value = texto;
		}else{
			document.getElementById("d2e").innerHTML = texto;
			document.getElementById("id2e").value = texto;
		}
		
		//filhos dos avos 
		texto = "";
		select31 = document.getElementById("select31").value; //pai ou mae
		select32 = document.getElementById("select32").value; //casou-se
		select34 = document.getElementById("select34").value; //divorciou-se
		select35 = document.getElementById("select35").value; //morreu	
		texto += '<br> - Nascimento';
		if (select32 == "S"){
			if (select34 == "S"){
					texto += '<br> - 1° Casamento (com averbação de Divorcio)';
					texto += '<br> - 2° Casamento (se ocorreu)';
			}else{
				texto += '<br> - Casamento';
			}					
		}
		if (select35 == "S")
			texto += '<br> - Óbito';
		//coloca o conteudo
		if (select31 == "1"){
			document.getElementById("id3d").value = texto;
			document.getElementById("d3d").innerHTML = texto;
		}else{
			document.getElementById("d3e").innerHTML = texto;
			document.getElementById("id3e").value = texto;		
		}
	}
	
	document.getElementById("img_processando").style.display = "none";
	document.getElementById("btn_imprimir_lista").style.display = "";
}//fim da verificação	
	
}


function imprimeDocsExigidos(){
	var img;
   img = document.getElementById("imagem").value;
   var total = img.length - 4;
   img = img.substr(0,total) + ".gif";
   url = "pop-documentos-necessarios.php?img="+img;
   window.open(url,"_blank")	 
   //pegar valor das divs
   
   
   //texto += '<div style="margin-top:673px;height:110px;margin-left:130px;width:403px;background-color:#555;">&nbsp;</div>';
   //texto +='<div style="margin-top:58px;height:110px;margin-left:130px;width:403px;background-color:#555;">&nbsp;</div>';
   
  
  
}

/*fim das  docs exigidos*/


function mostraEst(){
	//alert(document.form_cad.pais.value);
	if (document.form_cad.pais.value == "BR"){
		document.getElementById("campo_estado").style.display = "";
	}else{
		document.getElementById("campo_estado").style.display = "none";
	}	
}		

