// JavaScript Document
function limpa_campo(qual, texto, tipo){
		var element = document.getElementById(qual);
	if(element.value=='' && tipo=='out'){
		element.value=texto;
	}else if(element.value==texto && tipo=='in'){
		element.value='';
	}
}

// Início do código de Aumentar/ Diminuir a letra
 
// Para usar coloque o comando: "javascript:mudaTamanho('tag_ou_id_alvo', -1);" para diminuir
// e o comando "javascript:mudaTamanho('tag_ou_id_alvo', +1);" para aumentar
 
var tagAlvo = new Array('p'); //pega todas as tags p//
 
// Especificando os possíveis tamanhos de fontes, poderia ser: x-small, small...
var tamanhos = new Array( '9px','10px','11px','12px','13px','14px','15px' );
var tamanhoInicial = 2;
 
function mudaTamanho( idAlvo,acao ){
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 6 ) tamanho = 6;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  
  selecionados.style.fontSize = tamanhos[ tamanho ];
  
  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ];
  }
}


//script para abrir popup
function OpenWindow(FileNameToOpen,janela,largura,altura,scrollbar)
{
newWindow = window.open(FileNameToOpen,janela, 'width='+largura+', height='+altura+', toolbar=no, scrollbars='+scrollbar+', location=no, left=100, top=100')
if (newWindow.open)
{
newWindow.focus()
}
}

function Validar_Email(email){

    if(email.length < 6) {
            return false;
    }

    var x = 0;
    for (var c=0;c<email.length;c++) {
            if (email.substring(c,c+1) == '@') {
                    x = c;
            }
    }
    var y = 0;
    if (x > 0) {
            for (c=x;c<email.length;c++) {
                    if (email.substring(c,c+1)=='.') {
                            y = c;
                            var valida = 1;
                    }
            }
            if (y > 0) {
                    var dominio = '';
                    for (c=x;c<y;c++) {
                            dominio = dominio + email.substring(1,c);
                    }
            }
    }
    else {
            return false;
    }
    if (y <= x+2){
            return false;
    }
    if (valida == 1){
            return true;
    }
}

function Validar_Cadastro(){
    
	if (document.formCad.matricula.value=="") {
        document.formCad.matricula.focus();
        alert("Digite seu código de matrícula!");
        return false;
	}	
	
	if (document.formCad.nome.value=="") {
            document.formCad.nome.focus();
            alert("Digite seu nome!");
            return false;
    }	
	
    if (document.formCad.email.value=="") {
            document.formCad.email.focus();
            alert("Informe o seu e-mail!");
            return false;
    } else {
            if (!Validar_Email(document.formCad.email.value)) {
                    document.formCad.email.focus();
                    alert("Digite um e-mail válido!");
                    return false;
            }
    }	        
	   
	if (document.formCad.senha01.value=="") {
            document.formCad.senha01.focus();
            alert("Digite a sua senha!");
            return false;
    }        
        
    
	if (document.formCad.senha02.value=="") {
            document.formCad.senha02.focus();
            alert("Confirme a sua senha!");
            return false;
    }  

	if (document.formCad.senha01.value!="" && document.formCad.senha02.value!="") {
        
		var senha01 = document.formCad.senha01.value;    
		var senha02 = document.formCad.senha02.value;
		
		if(senha01 != senha02) {
			document.formCad.senha01.focus();
            alert("As senhas não são iguais!");
            return false;
		}
    }                 
            
}


function Validar_EditCadastro(){
    
	if (document.formCad.matricula.value=="") {
        document.formCad.matricula.focus();
        alert("Digite seu código de matrícula!");
        return false;
	}	
	
	if (document.formCad.nome.value=="") {
            document.formCad.nome.focus();
            alert("Digite seu nome!");
            return false;
    }	
	
    if (document.formCad.email.value=="") {
            document.formCad.email.focus();
            alert("Informe o seu e-mail!");
            return false;
    } else {
            if (!Validar_Email(document.formCad.email.value)) {
                    document.formCad.email.focus();
                    alert("Digite um e-mail válido!");
                    return false;
            }
    }	        
	
    if (document.formCad.senha01.value!="" || document.formCad.senha02.value!="") {
        
		var senha01 = document.formCad.senha01.value;    
		var senha02 = document.formCad.senha02.value;
		
		if(senha01 != senha02) {
			document.formCad.senha01.focus();
            alert("As senhas não são iguais!");
            return false;
		}
    }                 
            
}	
	
//script que rediciona as caixas de artigos
//Funcao que redireciona 
function navegaBoxGeral(url){
     if(url != ""){
     window.location.assign(url);
     } else {
     return false;
     }
}

function Validar_Testemunho(){
    
	if (document.formCad.nome.value=="") {
            document.formCad.nome.focus();
            alert("Digite seu nome!");
            return false;
    }	
	
    if (document.formCad.email.value=="") {
            document.formCad.email.focus();
            alert("Informe o seu e-mail!");
            return false;
    } else {
            if (!Validar_Email(document.formCad.email.value)) {
                    document.formCad.email.focus();
                    alert("Digite um e-mail válido!");
                    return false;
            }
    }
	
	if (document.formCad.testemunho.value=="") {
            document.formCad.testemunho.focus();
            alert("Digite seu testemunho!");
            return false;
    }		
	
}
