function confirmar(caminho,titulo)
{
	var name=confirm(titulo)
	if (name==true)
	{	
		document.location.href=caminho;
	}
}

function vai_volta(quem)
{
	if(document.getElementById(quem).style.display=='block')
	{
		document.getElementById(quem).style.display='none';
	}
	else
	{
		document.getElementById(quem).style.display='block';
	}
}

//Galeria de fotos

function vote(val, id){
	escexibir = document.getElementById("box_votar_"+id);
	ocultvot = document.getElementById("ocult_"+id);
	confirmar = document.getElementById("confirme_"+id);
	formul = document.getElementById("form_"+id);
	if(val == 1){//alert('ok');
	confirmar.style.display = 'block';
	formul.style.display = 'none';
	//document.forms[0].action = "vote.htm";  
	//document.forms[0].submit(); 
	} else{
	if(escexibir.style.display == "none")
	{
	escexibir.style.display = "block"
	ocultvot.style.display = "none"
	} else 
		{
		escexibir.style.display = "none"
		ocultvot.style.display = "none"
		}
	}
}
function vote2(val, id){
	escexibir = document.getElementById("dbox_votar_"+id);
	ocultvot = document.getElementById("docult_"+id);
	confirmar = document.getElementById("dconfirme_"+id);
	formul = document.getElementById("dform_"+id);
	if(val == 1){//alert('ok');
	confirmar.style.display = 'block';
	formul.style.display = 'none';
	//document.forms[0].action = "vote.htm";  
	//document.forms[0].submit(); 
	} else{
	if(escexibir.style.display == "none")
	{
	escexibir.style.display = "block"
	ocultvot.style.display = "none"
	} else 
		{
		escexibir.style.display = "none"
		ocultvot.style.display = "none"
		}
	}
}
function verfoto(id){
	var fotop = document.getElementById('pfoto_'+id);
	if(fotop.style.display == 'none'){
		fotop.style.display = 'block';
		} else {
			fotop.style.display = 'none';
			}
	}
	
function IniciaAjax() {
	var ajax;
	try{
		ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
	}catch(ee){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
		}catch(e){
			try{
				ajax = new XMLHttpRequest();
			}catch(E){
				ajax = false;
			}
		}
	}
	return ajax;
}	
function voto(valor,candidato,onde){
	if(document.getElementById) {		
		var ajax = IniciaAjax();  
		if(onde=='d'){
			ajax.open("GET", "computa_voto_dep.php?valor="+valor+"&candidato="+candidato, true);						 
		}else{
			ajax.open("GET", "computa_voto.php?valor="+valor+"&candidato="+candidato, true);						 
		}
		ajax.onreadystatechange = function() {				
			if(ajax.readyState == 4) {					
				if(ajax.status == 200) {
					if(onde=='d'){
						vote2(1,candidato);
					}else{
						vote(1,candidato);
					}
				} else {
					alert("ERRO: (Chamada Ajax) voto");
				}
			}				 
		} 
		ajax.send(null);
	}
}
function f_b_inst(tipo,valor){
	if(document.getElementById) {		
		var ajax = IniciaAjax();  
		ajax.open("GET", "cadastro_apoio2.php?tipo="+tipo+"&valor="+valor, true);						 
		ajax.onreadystatechange = function() {				
			if(ajax.readyState == 4) {					
				if(ajax.status == 200) {
					var resultado = ajax.responseText; 
					resultado = resultado.replace(/\+/g," "); 
					resultado = unescape(resultado); 
					document.getElementById('b_res').innerHTML=resultado;
				} else {
					alert("ERRO: (Chamada Ajax) b_inst");
				}
			}				 
		} 
		ajax.send(null);
	}
}
function g_b_inst(tipo,valor, gin){
	if(document.getElementById) {		
		var ajax = IniciaAjax();  
		ajax.open("GET", "cadastro_gincanas_apoio.php?tipo="+tipo+"&valor="+valor+"&codg="+gin, true);						 
		ajax.onreadystatechange = function() {				
			if(ajax.readyState == 4) {					
				if(ajax.status == 200) {
					var resultado = ajax.responseText; 
					resultado = resultado.replace(/\+/g," "); 
					resultado = unescape(resultado); 
					document.getElementById('b_res').innerHTML=resultado;
				} else {
					alert("ERRO: (Chamada Ajax) b_inst");
				}
			}				 
		} 
		ajax.send(null);
	}
}

function sel_inst_chave(cod)
{
	document.getElementById('palavra').innerHTML="<font color='red'><h1><b>"+document.getElementById('inst_'+cod).value+"</b></h1></font>";
	document.getElementById('instituicoes').value=cod;
	document.getElementById('palavrachave').value=document.getElementById('inst_'+cod).value;
	if(document.getElementById('guarda_cor').value!='0')
	{
		document.getElementById('linha_1_'+document.getElementById('guarda_cor').value).color='black';
		document.getElementById('linha_2_'+document.getElementById('guarda_cor').value).color='black';
		document.getElementById('linha_3_'+document.getElementById('guarda_cor').value).color='black';
		document.getElementById('linha_4_'+document.getElementById('guarda_cor').value).color='black';
	}
	document.getElementById('linha_1_'+cod).color='red';
	document.getElementById('linha_2_'+cod).color='red';
	document.getElementById('linha_3_'+cod).color='red';
	document.getElementById('linha_4_'+cod).color='red';
	document.getElementById('guarda_cor').value=cod;
	
}
function sel_inst_cad_user(cod)
{
	document.getElementById('entidade_nome').innerHTML=document.getElementById('inst_'+cod).value;
	document.getElementById('instituicoes').value=cod;
	document.getElementById('entidade').value=cod;
	document.getElementById('_inst_busca').style.display='none';
	document.getElementById('entidade_nome').style.display='inline';
	document.getElementById('inst_button').style.display='inline';
	document.getElementById('tutor_').src="cadastro_apoio.php?tipo=tut&cod="+document.getElementById('entidade').value;
	
}
function coloca_arq(cod)
{
	try
	{
		document.getElementById('linha_['+cod+']').style.display='block;';
		document.getElementById('arq_['+cod+']').value=cod;
	}
	catch(err)
	{
		document.getElementById('arquivos').innerHTML=document.getElementById('arquivos').innerHTML +"<div name='linha_["+cod+"]' id='linha_["+cod+"]' style='display:block'>"+document.getElementById('geral_['+cod+']').innerHTML+"<input type='hidden' name='arq_["+cod+"]' id='arq_["+cod+"]' value='"+cod+"'></div>";
	}
}
function tira_arq(cod)
{
	document.getElementById('linha_['+cod+']').style.display='none;';
	document.getElementById('arq_['+cod+']').value='0';
}
function formatar_mascara(src, mascara) 
{
 	var campo = src.value.length;
 	var saida = mascara.substring(0,1);
 	var texto = mascara.substring(campo);
 	if(texto.substring(0,1) != saida) 
 	{
  		src.value += texto.substring(0,1);
 	}
}
