var cand_marcado;

function arvore(can_p){
	if (can_p == cand_marcado && document.getElementById(cand_marcado).style.display == 'block') {
		document.getElementById(can_p).style.display = 'none';	
	}else {
		try{ document.getElementById(cand_marcado).style.display = 'none';}catch(e) {}
		document.getElementById(can_p).style.display = 'block';
		cand_marcado = can_p;
	}
}

function carregarPagina(modulo,acao,aba){	
	window.location="?modulo="+modulo+"&template="+acao+"&aba="+aba+"&Folha=0";
}

function Preloading(){
	document.getElementById("load").style.display = "none";
	document.getElementById("painel").style.display = "block";
}

function FuncaoStatus(urlHost,status,id){
	url = urlHost;
	if(status == 0){
		newstatus = 1;
	}else if(status == 1){
		newstatus = 0;
	}
	window.location=urlHost+"&acao=mudarstatus&status="+newstatus+"&id="+id;
}

function FuncaoDelete(url,id,acao,msg){
	if(confirm("Deseja excluir "+msg)){
		if(true){	
			window.location=url+"&acao="+acao+"&id="+id;
		}
	}
}

function FuncaoDeleteFoto(url,id,idf,acao,msg){
	if(confirm("Deseja excluir "+msg)){
		if(true){	
			window.location=url+"&acao="+acao+"&id="+id+"&idf="+idf;
		}
	}
}

function FuncaoDeleteResp(url,id,idr,acao,msg){
	if(confirm("Deseja excluir "+msg)){
		if(true){	
			window.location=url+"&acao="+acao+"&id="+id+"&idresp="+idr;
		}
	}
}

function FuncaoRespostas(url,id){
	window.location=url+"&id="+id;
}

function FuncaoEditar(url,id,acao){
	window.location=url+"&id="+id;
}

function FuncaoFoto(url,id,acao){
	window.location=url+"&id="+id;
}

function FuncaoAmigo(url,id,acao){
	window.location=url+"&id="+id;
}

function AddFoto(url,id){
	window.location=url+"&acao=deletar&id="+id;
}

function RetornoAutomatico(url){
	window.location=url;
}

function Focus(template){
	if(template == ""){
		
	}else{
		if(template != "listar" && template != "addamigo" && template != "respostas"){
			var Campos = document.cadastrar;
			Campos.elements[0].focus();
		}
	}
}

function AmpliarFoto(foto){
	document.getElementById("foto_ampliada").src = "images/loading.gif";
	document.getElementById("foto_ampliada").src = foto;
	document.getElementById("ampliada").style.display = "block";
}

function FechaFoto(){
	document.getElementById("ampliada").style.display = "none";
}

function Votar(idioma) {
	var FORM = document.enquete;
	for(i=0; i<FORM.elements.length; i++){
		if(FORM.elements[i].type == "radio"){
			if(FORM.elements[i].checked == 1){
				var valor = FORM.elements[i].value;
			}
		}
	}
	if(document.getElementById) { 
		var exibeResultado = document.getElementById('areaEnquete');
		if(valor != "") {
			var ajax = openAjax(); 
			ajax.open("GET", "votar.php?voto="+valor+"&idioma="+idioma,true); 
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { 
					exibeResultado.innerHTML = "<div style='text-align:center; margin-top:80px;'><img src='images/loading.gif'></div>";
				}
				if(ajax.readyState == 4) { 
					if(ajax.status == 200) {
						var resultado = ajax.responseText; 
						resultado = resultado.replace(/\+/g," "); 
						resultado = unescape(resultado); 
						exibeResultado.innerHTML = resultado;
					} else {
						exibeResultado.innerHTML = "Erro: ";
					}
				}
			}
			ajax.send(null); 
		}
	}
}
function CadNews(idioma) {
	if(document.getElementById) { 
		var exibeResultado = document.getElementById('areaInfo');
		var nome = document.getElementById('nome').value;
		var email = document.getElementById('email').value;
		var pais = document.getElementById('pais').value;
		var nome2 = document.getElementById('nome');
		var email2 = document.getElementById('email');
		if(nome2.value == "") {
			nome2.focus();
		}else if(email2.value == ""){
			email2.focus();
		}else{
			var ajax = openAjax(); 
			ajax.open("GET", "informativo.php?nome="+nome+"&email="+email+"&pais="+pais+"&idioma="+idioma,true); 
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { 
					exibeResultado.innerHTML = "<div style='margin-top100px; text-align:center;'>cadastrando...</div>";
				}
				if(ajax.readyState == 4) { 
					if(ajax.status == 200) {
						var resultado = ajax.responseText; 
						resultado = resultado.replace(/\+/g," "); 
						resultado = unescape(resultado); 
						exibeResultado.innerHTML = resultado;
					} else {
						exibeResultado.innerHTML = "Erro: ";
					}
				}
			}
			ajax.send(null); 
		}
	}
}
function AmpliarFoto(id) {
	if(document.getElementById) { 
		var exibeResultado = document.getElementById('ampliar');
		exibeResultado.style.display = "block";
		if(id != "") {
			var ajax = openAjax(); 
			ajax.open("GET", "foto.php?id="+id,true); 
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { 
					exibeResultado.innerHTML = "Carregando..";
				}
				if(ajax.readyState == 4) { 
					if(ajax.status == 200) {
						var resultado = ajax.responseText; 
						resultado = resultado.replace(/\+/g," "); 
						resultado = unescape(resultado); 
						exibeResultado.innerHTML = resultado;
					} else {
						exibeResultado.innerHTML = "Erro: ";
					}
				}
			}
			ajax.send(null); 
		}
	}
}
function AbrirHotSite(theURL,winName,features) {
  window.open(theURL,winName,features);
}


function Close(){
	document.getElementById("ampliar").innerHTML = '';
	document.getElementById("ampliar").style.display = 'none';
}


navHover = function() {
	var lis = document.getElementById("menu").getElementsByTagName("LI");
    for (var i=0; i<lis.length; i++) {
        lis[i].onmouseover=function() {
            this.className+=" iehover";
        }
        lis[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" iehover\\b"), "");
        }
    }
}

var Fade = 3;
function AbrirFoto(foto,texto){
	
	document.getElementById("grande").src = "images/loading.gif";
	document.getElementById("titulo_foto").innerHTML = texto;
	
	altura = 280;
	largura = 380;
	
	w = screen.width;
	h = screen.height;
	
	meio_w = w/2;
	meio_h = h/2;
	
	altura2 = altura/2;
	largura2 = largura/2;
	
	meio1 = meio_h-altura2;
	meio2 = meio_w-largura2;
	
	document.getElementById("Ampliar").style.top = meio1;
	document.getElementById("Ampliar").style.left = meio2;
	document.getElementById("Ampliar").style.display = "block";
	
	document.getElementById("grande").src = foto;
	window.scroll(0,1);
}
function AbrirFotoSurf(foto,texto,titulo){
	document.getElementById("grande").src = "images/loading.gif";
	document.getElementById("texto").innerHTML = texto;
	document.getElementById("titulo_foto").innerHTML = titulo;
	document.getElementById("grande").src = foto;
}
function FecharFoto(){
	document.getElementById("Ampliar").style.display = "none";
	document.getElementById("grande").src = "";
	window.scroll(1,0);
}

function limparCombo(combo,inicio){
    var tamanho=combo.options.length;
    for (i=tamanho-1;i>=inicio;i--)
        combo.remove(i) ;
}

function addCombo(valor,texto,combo) {
    var opcao = new Option(texto, valor);
    combo.options[combo.length] = opcao;
}

function ValidarLogin(form){
		if(form.login.value == ""){
			form.login.focus();
			form.login.style.background = '#CCCCCC'
			return false;
		}
		if(form.senha.value == ""){
			form.senha.focus();
			form.senha.style.background = '#CCCCCC'
			return false;
		}
		return true;
}
function OpemMenur(sub,acao){
	if(acao == "Over"){
		document.getElementById(sub).style.display = "block";
	}else if(acao == "Out"){
		document.getElementById(sub).style.display = "none";
	}
}