function AbreJanelaGaleria(URL) {
  var width = 625;
  var height = 410;
  var left = 50;
  var top = 10
  window.open(URL, 'ema3', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function ampliar(url) {
  window.open(url,'popupImageWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=640,height=480,screenX=150,screenY=150,top=150,left=150');
}

function imprimi(url) {
  window.open(url,'popupImageWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=640,height=480,screenX=150,screenY=150,top=150,left=150');
}

function indica(url) {
  window.open(url,'popupImageWindow','width=380, height=275, top=12, left=15, scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function fmsergipeonline() {
  window.open('http://emsergipe.globo.com/musicalbox/player/?aovivo=sim&chave=FM%20SERGIPE','popupImageWindow','width=600, height=325, top=12, left=15, scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function cores(url) {
  window.open(url,'popupImageWindow','width=225, height=169, top=10, left=10, scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}
	//ATIVA DIV NOTICAS, CURSOS, ALUNOS E ESTRUTURA.
	function ativanoticias(){
		 document.getElementById("noticias").style.display = 'block';
		 document.getElementById("noticias_texto").style.display = 'block';	 
		 document.getElementById("cursos").style.display = 'none';
		 document.getElementById("cursos_texto").style.display = 'none';	 	       
		 document.getElementById("alunos").style.display = 'none';	       
		 document.getElementById("alunos_texto").style.display = 'none';	       	 
		 document.getElementById("estrutura").style.display = 'none';	       	 	 
		 document.getElementById("estrutura_texto").style.display = 'none';	       	 	 	 
	}
	function ativacursos(){
		 document.getElementById("noticias").style.display = 'none';
		 document.getElementById("noticias_texto").style.display = 'none';	 	 
		 document.getElementById("cursos").style.display = 'block';	       
		 document.getElementById("cursos_texto").style.display = 'block';	 	       
		 document.getElementById("alunos").style.display = 'none';	       
		 document.getElementById("alunos_texto").style.display = 'none';	       	 
		 document.getElementById("estrutura").style.display = 'none';	       	 	 
		 document.getElementById("estrutura_texto").style.display = 'none';	       	 	 	 
	}
	function ativaalunos(){
		 document.getElementById("noticias").style.display = 'none';
		 document.getElementById("noticias_texto").style.display = 'none';	 
		 document.getElementById("cursos").style.display = 'none';	       
		 document.getElementById("cursos_texto").style.display = 'none';	 	       
		 document.getElementById("alunos").style.display = 'block';	       
		 document.getElementById("alunos_texto").style.display = 'block';	       	 
		 document.getElementById("estrutura").style.display = 'none';	       	 	 
		 document.getElementById("estrutura_texto").style.display = 'none';	       	 	 
	}
	function ativaestrutura(){
		 document.getElementById("noticias").style.display = 'none';
		 document.getElementById("noticias_texto").style.display = 'none';
		 document.getElementById("cursos").style.display = 'none';	       
		 document.getElementById("cursos_texto").style.display = 'none';	 	       
		 document.getElementById("alunos").style.display = 'none';	       
		 document.getElementById("alunos_texto").style.display = 'none';	       	 
		 document.getElementById("estrutura").style.display = 'block';	       	 	 
		 document.getElementById("estrutura_texto").style.display = 'block';	 	        	 	 
	}
	//ATIVA FORMULARIO DE BUSCAR POR DATA
	function ativabusca(){
	  if(document.busca.data.checked==true){
		  document.getElementById("filtro-busca").style.display = 'block';
	  }else{
		  document.getElementById("filtro-busca").style.display = 'none';
	  }
	}  
	//ATIVA FORMULARIO DE INDIQUE A UM AMIGO  
	function ativaindique(){
		  document.getElementById("frm-indique").style.display = 'block';		  
	}
	//FUNÇÃO PRA LIMPA INPUT
	function textClear (input) {
	if ( input.value == input.defaultValue ) {
		input.value = "";
	}
	}
	function textRestore (input) {
	if ( input.value == "" ) {
		input.value = input.defaultValue;
	}
	}
//adiciona mascara ao telefone
function MascaraTelefone(tel){    
    if(mascaraInteiro(tel)==false){
        event.returnValue = false;
    }    
    return formataCampo(tel, '(00) 0000-0000', event);
}
//valida numero inteiro com mascara
function mascaraInteiro(){
    if (event.keyCode < 48 || event.keyCode > 57){
        event.returnValue = false;
        return false;
    }
    return true;
}
//formata de forma generica os campos
function formataCampo(campo, Mascara, evento) { 
    var boleanoMascara; 
    
    var Digitato = evento.keyCode;
    exp = /\-|\.|\/|\(|\)| /g
    campoSoNumeros = campo.value.toString().replace( exp, "" ); 
   
    var posicaoCampo = 0;     
    var NovoValorCampo="";
    var TamanhoMascara = campoSoNumeros.length;; 
    
    if (Digitato != 8) { // backspace 
        for(i=0; i<= TamanhoMascara; i++) { 
            boleanoMascara  = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".")
                                || (Mascara.charAt(i) == "/")) 
            boleanoMascara  = boleanoMascara || ((Mascara.charAt(i) == "(") 
                                || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " ")) 
            if (boleanoMascara) { 
                NovoValorCampo += Mascara.charAt(i); 
                  TamanhoMascara++;
            }else { 
                NovoValorCampo += campoSoNumeros.charAt(posicaoCampo); 
                posicaoCampo++; 
             }            
          }     
        campo.value = NovoValorCampo;
          return true; 
    }else { 
        return true; 
    }
}

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