startList = function() {
	if (document.all&&document.getElementById) {
	navRoot = document.getElementById("nav");
	for (i=0; i<navRoot.childNodes.length; i++) {
	node = navRoot.childNodes[i];
	if (node.nodeName=="LI") {
	node.onmouseover=function() {
	this.className+=" over";
	  }
	  node.onmouseout=function() {
	  this.className=this.className.replace(" over", "");
	   }
	   }
	  }
	 }
	}
	window.onload=startList;

function abreImagem(indice) {
		indiceGeral=indice;
		$('foto_grande'		).innerHTML='<img src="upload/mural/foto'+arrayFoto[indice]+'.jpg" />';
		$('navegador'		).innerHTML=parseInt(indice)+1+' / '+ indiceTotal;
		$('link_download'	).innerHTML='<a href="upload/mural/'+arrayFoto[indice]+'.jpg" target="_blank">download da foto</a>';
	}
	
function fotoAnterior() {
	if(indiceGeral > 0)	abreImagem(parseInt(indiceGeral)-1);
}

function fotoProxima() {
	if(indiceGeral < indiceTotal-1) abreImagem(parseInt(indiceGeral)+1);
}
// ------------------------------------------------
function buscaNoticia() {
	var url = '';
	
	if($('mes_not').value != '') url = '&mes='+$('mes_not').value;
	
	window.location = '?on=noticias&ano='+$('ano_not').value+url;
	
}

function goto(on,interna) {
	var url;
	
	if(on) 		url = '?on='+on;
	if(interna) url = url+'&in='+interna;
	
	var wind = window.location = url;
	
}

function busca_associado(id) {
    if(id)
        window.location = '?on=associados&in=detalhe&id='+id;
    else
        alert('Selecione um Associado.');
}
// ------------------------------------------------
function selecionaValor(disparador,alvo,label,value, hidden, flag) {
    var campo = document.getElementById(alvo);
    var lista = document.getElementById(disparador);
    var busca_secao = document.getElementById(hidden);
    
    campo.innerHTML = label;
    busca_secao.value = value;
    lista.style.display = 'none';
    campo.parentNode.parentNode.style.position = 'static';
    
    if(flag == 'TRUE'){
        
        campoEntidade = document.getElementById('simula_campo_outra_univ');
        inputEntidade = document.getElementById('outra_universidade');
        classeEntidade = campoEntidade.className;
        
        if(label == 'Outra Entidade'){
            campoEntidade.className = "sim_campo_enable";
            inputEntidade.disabled = false;
            inputEntidade.focus();
        }
        else {
            campoEntidade.className = "sim_campo_disable";
            inputEntidade.value = "";
            inputEntidade.disabled = true;
        }
    }
}
// ------------------------------------------------
function abreSelect(field) {
    var campo = document.getElementById(field);
    campo.style.display=(campo.style.display == 'none' || campo.style.display == '')?'block':'none';
    campo.parentNode.style.position = 'relative';
}
//------------------------------------------------
function abre_diretorio() {
       window.open('?on=diretorio','revista','toolbar=0, location=0, directories=0, menubar=0, resizable=0, scrollbars=0, width=1020px, height=720px, top=0, left=0');
}
function drag_drop(id) {
   var descricao = $('descricao_'+id);
   var tbl       = $('tbl_'+id);
   var conteudo  = $('conteudo_'+id);
   var imagem    = $('seta_'+id);
   
   
   if(descricao.style.display == 'block') {
       imagem.src = 'resources/images/arrow_1.gif';
        descricao.style.display = 'none';
        conteudo.style.background = 'url(resources/images/bg_declaracao1.jpg)';
        tbl.style.color = '#002C77';
        
   } else {
     imagem.src = 'resources/images/arrow_2.gif';
     descricao.style.display = 'block';
     conteudo.style.background = '#41629A';
     tbl.style.color = '#FFFFFF';
   }
                    
}
 //--------------------------------------------------
 function busca() {
     if($('busca').value != '') 
        window.location = '?on=lista&in=busca&busca='+$('busca').value;
 }
 
 function open_info(id,img) {
    $('imprensa').style.display     = 'none';
    $('midia').style.display        = 'none';
    $('anuncios').style.display     = 'none';
	$('publicacoes').style.display  = 'none';
    
    $(id).style.display  = 'block';
   
	if(img == 'bt_imprensa1')
	   $('info').innerHTML = '<img src="resources/images/menu_saladeimprensa1.gif" border="0" id="bt_imprensa1" usemap="#saladeimprensa">';
	else if(img == 'bt_imprensa2') 
       $('info').innerHTML = '<img src="resources/images/menu_saladeimprensa2.gif" border="0" id="bt_imprensa2" usemap="#saladeimprensa">';
    else  if(img == 'bt_imprensa3') 
       $('info').innerHTML = '<img src="resources/images/menu_saladeimprensa3.gif" border="0" id="bt_imprensa3" usemap="#saladeimprensa">';
    else  if(img == 'bt_imprensa4') 
       $('info').innerHTML = '<img src="resources/images/menu_saladeimprensa4.gif" border="0" id="bt_imprensa4" usemap="#saladeimprensa">';
      
}
//--------------------------------------------------
function scroll(position,id) {
    var timerTexto;
    var valor = 24;
    var total = 504;
    var cont = 0;
   
    if(position == 'right') {
        timerTexto =  setInterval(function () { 
	                                $(id).scrollLeft += valor;
	                                cont += valor;
	                                if(cont == total) { clearInterval(timerTexto) };
                                },10);
    }
    
    if(position == 'left') {
        timerTexto =  setInterval(function () { 
	                                $(id).scrollLeft -= valor;
	                                cont += valor;
	                                if(cont == total) clearInterval(timerTexto);
                                },10);
    }
}
//------------------------------------------------
function abreChat() {
	//window.open('chat/admin_chat.php?do_Activate=activate','chat','toolbar=0, location=0, directories=0, menubar=0, resizable=0, scrollbars=0, width=400px, height=490px, top=100, left=240');
	window.open('chat/cust_chat.php','chat','toolbar=0, location=0, directories=0, menubar=0, resizable=0, scrollbars=0, width=400px, height=490px, top=100, left=240');
}

//------------------------------------------------
function Filtra(campo) {
	var digits="ABCDEFGHIJKLMNOPQRSTUVXYWZabcdefghijklmnopqrstuvwxyz0123456789"
	var campo_temp
	
	for (var i=0;i<campo.value.length;i++){
	  campo_temp=campo.value.substring(i,i+1)
	  if (digits.indexOf(campo_temp)==-1){
	     campo.value = campo.value.substring(0,i);
	     break;
	  }
	}
}
//-------------------------------------------------
function isAlpha(valor){
	var digits="ABCDEFGHIJKLMNOPQRSTUVXYWZabcdefghijklmnopqrstuvwxyz0123456789";
	var campo_temp;
	
	var achou;
	for (var i=0;i<valor.length;i++) {
	  campo_temp=valor.substring(i,i+1)
	  if (digits.indexOf(campo_temp)==-1)
	  	achou = '1';
	}
	
	if(achou == '1') return false
	else return true;
}

//-------------------------------------------------

function abreJanela(url,pagina,detalhe) {
	window.open(url,pagina,detalhe);
}
// ------------------------------------------------
function abreSelect(field) {
	var campo = document.getElementById(field);
	campo.style.display=(campo.style.display == 'none' || campo.style.display == '')?'block':'none';
	campo.parentNode.style.position = 'relative';
}

// ------------------------------------------------
function limpaCampos(campo,padrao){
	
	var obj = document.getElementById(campo);
	obj.select();
	if (obj.value == padrao)
		obj.value = '';
	
}

// ------------------------------------------------
function restauraCampos(campo,padrao){
	
	var obj = document.getElementById(campo);
	if (obj.value == '')
		obj.value = padrao;
	
}

// ------------------------------------------------
function validaEmail(val){
	var rep=val.replace(/^[^0-9a-zA-Z_\[\]\.\-@]+$/,"");
	return(val==""||(val==rep&&(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(val))));
}

// ------------------------------------------------
function formataCampo(e,src,mask) {
	
	if(window.event) 
		_TXT = e.keyCode;
	else if(e.which)
		_TXT = e.which;
		
	if(_TXT > 47 && _TXT < 58) { 
		var i = src.value.length; 
		var saida = mask.substring(0,1); 
		var texto = mask.substring(i)
		if (texto.substring(0,1) != saida) { 
			src.value += texto.substring(0,1); 
		} 
	return true; 
	} else { 
		if (_TXT != 8) { 
			return false; 
		} 
		else { 
			return true; 
		}
	}
}

// ------------------------------------------------
function somenteNumero(e) {
	var tecla=(window.event)?event.keyCode:e.which;
	
	if ((tecla > 47) && (tecla < 58))
		return true;
	else{
		if (tecla != 8 && tecla != 0) 
			return false;
		else
			return true;
	}
}

// ------------------------------------------------
function checkCPFCNPJ(obj,tipo) {

	var cnpj = document.getElementById(obj).value;
	
	vr = cnpj;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	cnpj = vr;
	
	if (tipo == 'cnpj') {
		   soma1 = (cnpj.charAt(0) * 5) +
			   (cnpj.charAt(1) * 4) +
			   (cnpj.charAt(2) * 3) +
			   (cnpj.charAt(3) * 2) +
			   (cnpj.charAt(4) * 9) +
			   (cnpj.charAt(5) * 8) +
			   (cnpj.charAt(6) * 7) +
			   (cnpj.charAt(7) * 6) +
			   (cnpj.charAt(8) * 5) +
			   (cnpj.charAt(9) * 4) +
			   (cnpj.charAt(10) * 3) +
			   (cnpj.charAt(11) * 2);
	   resto = soma1 % 11;
	   digito1 = resto < 2 ? 0 : 11 - resto;
	   soma2 = (cnpj.charAt(0) * 6) +
			   (cnpj.charAt(1) * 5) +
			   (cnpj.charAt(2) * 4) +
			   (cnpj.charAt(3) * 3) +
			   (cnpj.charAt(4) * 2) +
			   (cnpj.charAt(5) * 9) +
			   (cnpj.charAt(6) * 8) +
			   (cnpj.charAt(7) * 7) +
			   (cnpj.charAt(8) * 6) +
			   (cnpj.charAt(9) * 5) +
			   (cnpj.charAt(10) * 4) +
			   (cnpj.charAt(11) * 3) +
			   (cnpj.charAt(12) * 2);
	   resto = soma2 % 11;
	   digito2 = resto < 2 ? 0 : 11 - resto;
	   return ((cnpj.charAt(12) == digito1) && (cnpj.charAt(13) == digito2));
	}
	else
	
		if (cnpj.length == 11)	{
		   soma1 = (cnpj.charAt(0) * 10) +
				   (cnpj.charAt(1) * 9) +
				   (cnpj.charAt(2) * 8) +
				   (cnpj.charAt(3) * 7) +
				   (cnpj.charAt(4) * 6) +
				   (cnpj.charAt(5) * 5) +
				   (cnpj.charAt(6) * 4) +
				   (cnpj.charAt(7) * 3) +
				   (cnpj.charAt(8) * 2);
		   resto = soma1 % 11;
		   digito1 = resto < 2 ? 0 : 11 - resto;
		   soma2 = (cnpj.charAt(0) * 11) +
				   (cnpj.charAt(1) * 10) +
				   (cnpj.charAt(2) * 9) +
				   (cnpj.charAt(3) * 8) +
				   (cnpj.charAt(4) * 7) +
				   (cnpj.charAt(5) * 6) +
				   (cnpj.charAt(6) * 5) +
				   (cnpj.charAt(7) * 4) +
				   (cnpj.charAt(8) * 3) +
				   (cnpj.charAt(9) * 2);
		   resto = soma2 % 11;
		   digito2 = resto < 2 ? 0 : 11 - resto;
		   return ((cnpj.charAt(9) == digito1) && (cnpj.charAt(10) == digito2));	
		}
		else 
		   return false;
	
	return true;
		   
}


function dataValida(val) {
	var reDate = /^(0?[1-9]|[12]\d|3[01])\/(0?[1-9]|1[0-2])\/(19|20)?\d{2}$/;
	
	return reDate.test(val);
	//return false;
}

String.prototype.capitalize = function(){ //v1.0
return this.replace(/\w+/g, function(a){
    return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
    });
};

function slideMenu(source) {
	var calc;
	
	if($(source).style.display == 'none')
		Effect.SlideDown(source, {duration:0.2});
	else 
		Effect.SlideUp(source, {duration:0.2});
}


function dica () {
	
	if($('dica_1').style.display == 'block') {
		$('dica_1').style.display = 'none';
		$('dica_4').style.display = 'block';
	}
		
	if($('dica_2').style.display == 'block') {
		$('dica_2').style.display = 'none';
		$('dica_1').style.display = 'block';
	}
	
	if($('dica_3').style.display == 'block') {
		$('dica_3').style.display = 'none';
		$('dica_2').style.display = 'block';
	}
	
	if($('dica_4').style.display == 'block') {
		$('dica_4').style.display = 'none';
		$('dica_3').style.display = 'block';
	}
	
}

function dica_prox () {
	
	if($('dica_1').style.display == 'block') {
		$('dica_1').style.display = 'none';
		$('dica_2').style.display = 'block';
	}
		
	if($('dica_2').style.display == 'block') {
		$('dica_2').style.display = 'none';
		$('dica_3').style.display = 'block';
	}
	
	if($('dica_3').style.display == 'block') {
		$('dica_3').style.display = 'none';
		$('dica_4').style.display = 'block';
	}
	
	if($('dica_4').style.display == 'block') {
		$('dica_4').style.display = 'none';
		$('dica_1').style.display = 'block';
	}
	
}

function bg1(valor) { $(valor).style.background = '#FFFFFF'; }
function bg2(valor) { if($(valor).value == '') $(valor).style.background = '#E9E9E9'; }
/*
over = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" over";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" over\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", over);
*/

