// JavaScript Document

	var host = 'http://'+this.location.hostname+'/site/';

	/*
		----------------------------------------------
		Funcoes que necessitam do HOST
		----------------------------------------------
	*/
	
	function abrirGaleria(id) {
		window.open(host+'galeria/engine/index.php?id='+id+' ', '_janela', 'width=600, height=400');						
	}
	function central() {
		window.open(host+'central/mensagem.php', '_central', 'width=310, height=350');				
	}

	function autenticaAluno(formulario) {
		var cpf = formulario.cpf.value;
		var matricula = formulario.matricula.value;
		var imagem = formulario.img.value; 

		if ((matricula == '') || (matricula.length < 8 )) {
			alert('Por gentileza, digitar o número de matrícula');
			formulario.matricula.focus();
		}
		else {
			if ((cpf == '') || (cpf.length < 11 )) {
				alert('Por gentileza, digitar o número do CPF do responsável financeiro corretamente');				
				formulario.cpf.focus();
			} else {
				if ((imagem == '') || (imagem.length < 5 )) {
					alert('Por gentileza, digitar o código alfanumérico descrito na imagem corretamente');
					formulario.img.focus();
				} else {
					formulario.method='post';
					formulario.action=host+'conteudoexclusivo/autenticar.php';
					formulario.submit();
				}
			}  
		} 		
	}
	
	
	function autenticaAlunoBoletim(formulario) {
		var cpf = formulario.cpf.value;
		var matricula = formulario.matricula.value;
		var imagem = formulario.img.value; 

		if ((matricula == '') || (matricula.length < 8 )) {
			alert('Por gentileza, digitar o número de matrícula');
			formulario.matricula.focus();
		}
		else {
			if ((cpf == '') || (cpf.length < 11 )) {
				alert('Por gentileza, digitar o número do CPF do responsável financeiro corretamente');				
				formulario.cpf.focus();
			} else {
				if ((imagem == '') || (imagem.length < 5 )) {
					alert('Por gentileza, digitar o código alfanumérico descrito na imagem corretamente');
					formulario.img.focus();
				} else {
					formulario.method='post';
					formulario.action='autenticar_boletim.php';
					formulario.submit();
				}
			}  
		} 		
	}	

	function imagemdodia(id) {
		window.open(host+'imagemdodia/files/galeria.php?id='+id+' ', '_imagemdodia', 'width=580, height=320');		
	}

	/*
		----------------------------------------------
		Funcoes que não necessitam do HOST
		----------------------------------------------
	*/

	// Aceitar apenas NUMEROS
	function numero(e) {
		var tecla = e.keyCode;
		if ((tecla > 47 && tecla < 58) || (tecla == 8) || (tecla == 46)) { return true; }
		else { return false; } 
	}
	
	
	function numero1(e) {
		
		//var tecla = window.event?event.keyCode:event.which;
		var tecla = e.keyCode;
		alert(tecla);
		if ((tecla > 47 && tecla < 58) || (tecla == 8) || (tecla == 46)) { return true; }
		else { return false; } 
	}
	
	
	function Numerico(event)
    {
        //
        // Bloqueia teclas alfanuméricas.
        //    
        Tecla = event.which;
        if (Tecla == null)
           Tecla = event.keyCode;
           //
        //incluido o tratamento para a Tecla = 8 (backspace)
        //e Tecla == 0 (seta direcionais, delete e tab) para rodar no Firefox
        //
        if ((Tecla >= 48 && Tecla <= 57) || (Tecla == 46) || Tecla == 0 || Tecla == 8)
           return true;
        return false;
    }


	// valida campos do conteudo exclusivo

	function validaCamposConteudoExclusivo(valorMatricula, valorCpf) {
		var frm = frmConteudoExclusivo;
		var strMatricula = valorMatricula.value;
		var strCpf = valorCpf.value;
			
		if (strMatricula.length < 8) { alert('Matricula inválida. Tente novamente'); }
		else { 
			if (strCpf.length < 11) { alert('CPF inválido. Tente novamente'); }
			else { 
				frm.method='post';
				frm.action='autenticarAluno.php';
				frm.submit(); 
			}
		} 
	} 


	function formataData(campo) {
		var x = campo.value;
		var caract = String.fromCharCode(event.keyCode);
		if(event.keyCode > 47 && event.keyCode < 58) { 
			if ((x.length==2) || (x.length==5)) {
				if (caract == '/') { return false; }
				campo.value+="/";
			}
		} else { return false; }
	}


	function enquete(tipo) {
		switch(tipo) {
			case 'votar': {
				var_path = 'enquete/enquete.php';
				break;
			}
			case 'anteriores': {
				var_path = 'enquete/enquete_anteriores.php';				
				break;
			}

		}
		window.open(var_path, '_enquetes', 'width=310, height=400, scrollbars=yes');
	}

	function VotarEnquete() {
		var frm = frmEnquete;
		var indFalse = 1;
		var opcao = ' ';
		for (var i = 0; i < frm.resposta_id.length; i++) {
			if (frm.resposta_id[i].checked) {
				opcao = frm.resposta_id[i].value;
			}
		}
		if (opcao != ' ') {
			var url ='enquete.php?ok=votar&opcao='+opcao+' ';
			window.open(url, '_self');
		} else {
			alert('Para votar, você deve selecionar uma opção');
		}
	}

	function enviarNoticia(id) {
		window.open('enviarnoticia.php?id='+id+' ', '_janela', 'width=310, height=410');				
	}
		
	function tratarEmail(email) {
		if (email.search('@') == -1) {
			alert('ATENÇÃO!\nO formato deve ser login@empresa.com(.br). Por favor, digite corretamente.');
			return false;
		} else {
			var x = email.split('@');
			var login = x[0];
			if (x[1].search('.') == -1) {
				alert('ATENÇÃO!\nO formato deve ser login@empresa.com(.br). Por favor, digite corretamente.');		
				return false;
			} else {
				return true;
			}
		}
	}