function nu(campo){
var digits="0123456789"
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 ValRG(numero){
 /*
 ##  Igor Carvalho de Escobar
 ##    www.webtutoriais.com
 ##   Java Script Developer
 */
 var numero = numero.split("");
 tamanho = numero.length;
 vetor = new Array(tamanho);

if(tamanho>=1)
{
 vetor[0] = parseInt(numero[0]) * 2; 
}
if(tamanho>=2){
 vetor[1] = parseInt(numero[1]) * 3; 
}
if(tamanho>=3){
 vetor[2] = parseInt(numero[2]) * 4; 
}
if(tamanho>=4){
 vetor[3] = parseInt(numero[3]) * 5; 
}
if(tamanho>=5){
 vetor[4] = parseInt(numero[4]) * 6; 
}
if(tamanho>=6){
 vetor[5] = parseInt(numero[5]) * 7; 
}
if(tamanho>=7){
 vetor[6] = parseInt(numero[6]) * 8; 
}
if(tamanho>=8){
 vetor[7] = parseInt(numero[7]) * 9; 
}
if(tamanho>=9){
 vetor[8] = parseInt(numero[8]) * 100; 
}

 total = 0;

if(tamanho>=1){
 total += vetor[0];
}
if(tamanho>=2){
 total += vetor[1]; 
}
if(tamanho>=3){
 total += vetor[2]; 
}
if(tamanho>=4){
 total += vetor[3]; 
}
if(tamanho>=5){
 total += vetor[4]; 
}
if(tamanho>=6){
 total += vetor[5]; 
}
if(tamanho>=7){
 total += vetor[6];
}
if(tamanho>=8){
 total += vetor[7]; 
}
if(tamanho>=9){
 total += vetor[8]; 
}


 resto = total % 11;
if(resto!=0){
document.getElementById('camada').innerHTML="<font face=verdana size=2 color=red>RG Inválido!</font><br><br>";
}
else{
document.getElementById('camada').innerHTML="<font face=verdana size=2 color=forestgreen>RG Válido!</font><br><br>";
}
}

//Função para abrir pop-up
function abrir(pagina,largura,altura, noscroll) {
	if(!noscroll){
		scrollbars = 'no';
	} else {
		scrollbars = 'yes';
	}
	config="toolbar=no,location=no,width="+largura+",height="+altura+",status=no,menubar=no,scrollbars=" + scrollbars + ",resizable=no,top=" + ((screen.height - altura) / 2) + ",left=" + ((screen.width - largura) /2);
	pop=window.open(pagina,"newwindow",config);
}


function datadoprojeto(campo) {
	var dtprojeto

	dtprojeto = campo.value.replace('(','').replace('-','').replace('/','').replace(')','');
	if(dtprojeto.length == 6){
		campo.value = dtprojeto.substr(0,2) + "/" + dtprojeto.substr(4,dtprojeto.length-4) ;
	}
}

//Função para que o campo aceite somente números inteiros
function checkIt(evt) {
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		status = "Este campo aceita somente número."
		return false
	}
	status = ""
	return true
}


//Função para que o campo aceite somente números inteiros e vírgula
function CheckNum(){
	if ((event.keyCode < 48) || (event.keyCode > 57)) {
		if ((event.keyCode != 44) && (event.keyCode != 45)) {
		return false;
		}
	}
return true;
}

//Função para que o campo aceite somente números, letras sem acento e espaço;
function CheckNumChar(){
	if ((event.keyCode < 48) || (event.keyCode > 57)){
		if ((event.keyCode < 97) || (event.keyCode > 122)) {
			if (event.keyCode != 32){
				status = "Este campo aceita somente números e letras minúsculas.";
				return false;
			}
		}
	}
	return true;
}

//Função para que o campo aceite somente números, letras e caracteres de arquivo;
function CheckFilename(){
	if ((event.keyCode < 46) || (event.keyCode > 58)){
		if ((event.keyCode < 97) || (event.keyCode > 122)) {
			if (event.keyCode != 95){
				status = "Este caracter não é válido para nome de arquivos.";
				return false;
			}
		}
	}
	return true;
}


//Função que faz uma máscara para telefone
function formataTel(campo) {
	var valor
	valor = campo.value.replace('(','').replace('-','').replace(')','');
	if(valor.length == 1){
		campo.value = "(" + valor;
	}else if(valor.length > 6){
		campo.value = "(" + valor.substr(0,2) + ")" + valor.substr(2,4) + "-" + valor.substr(6,4) ;
	}else if(valor.length == 6){
		campo.value = "(" + valor.substr(0,2) + ")" + valor.substr(2,4) ;
	}else if(valor.length > 2 ){
		campo.value = "(" + valor.substr(0,2) + ")" + valor.substr(2,valor.length-2);
	}
}
function formataTel7(campo) {
	var valor

	valor = campo.value.replace('(','').replace('-','').replace(')','');
	if(valor.length == 9){
		campo.value = "(" + valor.substr(0,2) + ")" + valor.substr(2,3) + "-" + valor.substr(5,valor.length-5) ;
	}
}


//Função que faz uma máscara para data
function formataData(campo) {
	var valor
	valor = campo.value.replace('/','').replace('/','');
	if(valor.length > 4){
		campo.value = valor.substr(0,2) + "/" + valor.substr(2,2) + "/" + valor.substr(4,4) ;
	}else if(valor.length > 2 ){
		campo.value = valor.substr(0,2) + "/" + valor.substr(2,2);
	}
}
function formataDataMesAno(campo) {
	var valor
	valor = campo.value.replace('/','');
	if(valor.length > 2){
		campo.value = valor.substr(0,2) + "/" + valor.substr(2,4);
	}
}

//Função que faz uma máscara para cep
function formataCEP(campo) {
	var valor
	valor = campo.value.replace('-','');
	 if(valor.length >= 5){
		campo.value = valor.substr(0,5) + "-" + valor.substr(5,3) ;

	}else{
		campo.value = valor;
	}
}


//Validação de data
function validDate(d) {
	var reData = /(\d{2})\/(\d{2})\/(\d{4})/;
	var datePart = d.match(reData); // datePartconterá [0]=dia, [1]=mes e [2]=ano

	if(datePart == null){
	//alert("Data Invalida");
	return false;
	}

	// passando as partes da data para variáveis mais "amigáveis":
	var dd = datePart[1], mm = datePart[2], yy = datePart[3];
	//alert(dd); // 1o. grupo //alert(mm); // 2o. grupo //alert(yy); // 3o. grupo

	//condições de datas inválidas:
	// dia menor que 1 ou maior que 31
	if (dd<1) { return false;}

	// mes fora dos limites
	if (mm<1 || mm>12) { return false;}

	// meses 4,6,9,11 nao possuem mais de 30 dias
	if ((dd > 30) && (mm == 4)) {return false;}
	if ((dd > 30) && (mm == 6)) {return false;}
	if ((dd > 30) && (mm == 9)) {return false;}
	if ((dd > 30) && (mm == 11)) {return false;}

	if ((dd > 31) && (mm == 1)) {return false;}
	if ((dd > 31) && (mm == 3)) {return false;}
	if ((dd > 31) && (mm == 5)) {return false;}
	if ((dd > 31) && (mm == 7)) {return false;}
	if ((dd > 31) && (mm == 8)) {return false;}
	if ((dd > 31) && (mm == 10)) {return false;}
	if ((dd > 31) && (mm == 12)) {return false;}

	// fevereiro não tem mais de 28 dias, exceto em ano bissexto
	if ((dd > 29) && (mm == 2) && (anobissexto(yy) )) {return false;}
	if ((dd > 28) && (mm == 2) && (!anobissexto(yy) )) {return false;}

// se passou pelos testes acima, então a data é considerada válida.
return true;
}

function validDateMesAno(d) {
	mm = d.substring(0,2);
	aaaa = d.substring(3);

	// mes fora dos limites
	if (mm<1 || mm>12) { return true;}

	// mes fora dos limites
	if (aaaa<1900 || aaaa>2100) { return true;}

// se passou pelos testes acima, então a data é considerada válida.
return false;
}

// retorna verdadeiro se for ano bissexto ou falso se não for bissexto
function anobissexto(yy){
	return (yy % 4 == 0 &&(yy % 100 != 0 || yy % 400 == 0));
}

//VERIFICA O CPF, INCLUSIVE NUMEROS IGUAIS
/*function checkCPF(whatForm, whatInput, errorMessage){
  var tmpCPF = whatForm.elements[whatInput];
  var numcpf = tmpCPF.value;*/
function checkCPF(whatInput,errorMessage){
  var tmpCPF = whatInput;
  var numcpf = tmpCPF.value;

  x = 0;
  soma = 0;
  dig1 = 0;
  dig2 = 0;
  texto = "";
  numcpf1 = "";
  len = numcpf.length;
  x = len -1;
  for (var i=0; i <= len - 3; i++) {
    y = numcpf.substring(i,i+1);
    soma = soma + ( y * x);
    x = x - 1;
    texto = texto + y;
  }
  dig1 = 11 - (soma % 11);
  if (dig1 == 10) dig1=0 ;
  if (dig1 == 11) dig1=0 ;
    numcpf1 = numcpf.substring(0,len - 2) + dig1 ;
    x = 11; soma=0;
  for (var i=0; i <= len - 2; i++) {
    soma = soma + (numcpf1.substring(i,i+1) * x);
    x = x - 1;
  }
  dig2= 11 - (soma % 11);
  if (dig2 == 10) dig2=0;
  if (dig2 == 11) dig2=0;
  if ((dig1 + "" + dig2) == numcpf.substring(len,len-2)) {
    if(numcpf % 11111111111 == 0){
      //showWarning(errorMessage, tmpCPF);
      tmpCPF.focus();
      return false;
    }
    return true;
  }
  //showWarning(errorMessage, tmpCPF);
  tmpCPF.focus();
  return false;
}

function checkCNPJ(whatInput,errorMessage){
  var tmpCNPJ = whatInput;
  CNPJ = tmpCNPJ.value;

  CNPJ = LIMP(CNPJ);
  if(isNUMB(CNPJ) != 1){
   // showWarning(errorMessage, tmpCNPJ);
    tmpCNPJ.focus();
    return false;
  }
  else{
    if(CNPJ == 0){
      //showWarning(errorMessage, tmpCNPJ);
      tmpCNPJ.focus();
      return false;
    }
    else{
      g = CNPJ.length - 2;
      if (RealTestaCNPJ(CNPJ,g) == 1){
        g = CNPJ.length - 1;
        if(RealTestaCNPJ(CNPJ,g) == 1){
          return true;
        }
        else{
          return true;
        }
      }
      else{
		//showWarning(errorMessage, tmpCNPJ);
        tmpCNPJ.focus();
        return false;
      }
    }
  }
}

//DEPENDENCIA PARA O CNPJ
function RealTestaCNPJ(CNPJ,g){
  var VerCNPJ=0;
  var ind=2;
  var tam;
  for(f = g; f > 0; f--){
    VerCNPJ+=parseInt(CNPJ.charAt(f-1))*ind;
    if(ind>8){
      ind=2;
    }
    else{
      ind++;
    }
  }
  VerCNPJ%=11;
  if(VerCNPJ==0 || VerCNPJ==1){
    VerCNPJ=0;
  }
  else{
    VerCNPJ=11-VerCNPJ;
  }
  if(VerCNPJ!=parseInt(CNPJ.charAt(g))){
    return false;
  }
  else{
    return true;
  }
}

//DEPENDENCIA PARA O CNPJ
function LIMP(c){
  while((cx=c.indexOf("-"))!=-1){
    c = c.substring(0,cx)+c.substring(cx+1);
  }
  while((cx=c.indexOf("/"))!=-1){
    c = c.substring(0,cx)+c.substring(cx+1);
  }
  while((cx=c.indexOf(","))!=-1){
    c = c.substring(0,cx)+c.substring(cx+1);
  }
  while((cx=c.indexOf("."))!=-1){
    c = c.substring(0,cx)+c.substring(cx+1);
  }
  while((cx=c.indexOf("("))!=-1){
    c = c.substring(0,cx)+c.substring(cx+1);
  }
  while((cx=c.indexOf(")"))!=-1){
    c = c.substring(0,cx)+c.substring(cx+1);
  }
  while((cx=c.indexOf(" "))!=-1){
    c = c.substring(0,cx)+c.substring(cx+1);
  }
  return(c);
}

//DEPENDENCIA PARA O CNPJ
function isNUMB(c){
  if((cx=c.indexOf(","))!=-1){
    c = c.substring(0,cx)+"."+c.substring(cx+1);
  }
  if((parseFloat(c) / c != 1)){
    if(parseFloat(c) * c == 0){
      return(1);
    }
    else{
      return(0);
    }
  }
  else{
    return(1);
  }
}

//Cria mascara para os campos
function criamascara(_RefObjeto, _Modelo, num){

         var valorAtual = _RefObjeto.value;

         //alert(valorAtual);

         var valorNumerico = '';

         var nIndexModelo = 0;

         var nIndexString = 0;

         var valorFinal = '';

         var adicionarValor = true;

         //num é um parâmetro para saber se a máscara é apenas numérica ou não

         if (num!=undefined && num!=0){num=1;}else{num=0;}

         // limpa a string valor atual para verificar

         // se todos os caracteres são números

         for (i=0;i<_Modelo.length;i++){

             if (_Modelo.substr(i,1) != '#'){

                valorAtual = valorAtual.replace(_Modelo.substr(i,1),'');

              }
         }

         // verifica se todos os caracteres são números

         for (i=0;i<valorAtual.length;i++){

             if(num==0){

                        if (!isNaN(parseFloat(valorAtual.substr(i,1)))){

                                 valorNumerico = valorNumerico + valorAtual.substr(i,1);

                         }

             }

             else{

                        valorNumerico = valorNumerico + valorAtual.substr(i,1);

             }

          }

          // aplica a máscara ao campo informado usando

          // o modelo de máscara informado no script

          for (i=0;i<_Modelo.length;i++){


              if (_Modelo.substr(i,1) == '#'){

                 if (valorNumerico.substr(nIndexModelo,1) != ''){

                    valorFinal = valorFinal + valorNumerico.substr(nIndexModelo,1);

                    nIndexModelo++;nIndexString++;

                 } else {

                    adicionarValor = false;

                 }
              } else {

                if (adicionarValor && valorNumerico.substr(nIndexModelo,1) != ''){

                   valorFinal = valorFinal + _Modelo.substr(nIndexString,1)

                              nIndexString++;
                 }
               }

           }

//alert(valorFinal)

_RefObjeto.value = valorFinal

}

function verifica_campos_imprensa(f) {

	if (document.form.txt_veiculo.value == ""){
		alert("Preencha o campo 'Veículo de Comunicação'.");
		document.form.txt_veiculo.focus();
	return false;
	}

	if (document.form.txt_veiculo.value.length < 3){
		alert("O campo 'Veículo de Comunicação' não está preenchido corretamente!");
		document.form.txt_veiculo.focus();
	return false;
	}

	if (document.form.txt_nome.value == ""){
		alert("Preencha o campo 'Nome'.");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_nome.value.length < 3){
		alert("O campo 'Nome' não está preenchido corretamente!");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_email.value < 1){
		alert("Preencha o campo 'E-Mail'.");
		document.form.txt_email.focus();
	return false;
	}


	var  exp = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z,_]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$/;

	if (!exp.test(document.form.txt_email.value)) {
		alert("E-mail inválido!");
	document.form.txt_email.focus();
	return false;
	}

	if (document.form.txt_senha.value == ""){
		alert("Preencha o campo 'Senha'.");
		document.form.txt_senha.focus();
	return false;
	}

	if (document.form.txt_senha.value.length < 4){
		alert("A 'Senha' deve ter pelo menos 4 caracteres!");
		document.form.txt_senha.focus();
	return false;
	}

	if (document.form.txt_senha.value != document.form.txt_conf_senha.value){
		alert("A confirmação não confere com a senha.");
		document.form.txt_conf_senha.focus();
	return false;
	}
return true;
}

function verifica_campos_cadastro(f) {

	if (document.form.txt_email.value < 1){
		alert("Preencha o campo 'E-Mail'.");
		document.form.txt_email.focus();
	return false;
	}

	var  exp = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z,_]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$/;

	if (!exp.test(document.form.txt_email.value)) {
		alert("E-mail inválido!");
		document.form.txt_email.focus();
	return false;
	}

	if (document.form.txt_cpf.value == ""){
	alert("Preencha o campo 'CPF'.");
		document.form.txt_cpf.focus();
	return false;
	}

	if (!checkCPF(document.form.txt_cpf, 'CPF inválido.')){
		alert("'CPF' inválido.");
		document.form.txt_cpf.focus();
		return false;
	}

	if (document.form.txt_nome.value == ""){
		alert("Preencha o campo 'Nome'.");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_nome.value.length < 3){
		alert("O campo 'Nome' não está preenchido corretamente!");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_sexo.value == "-1"){
		alert("Selecione o campo 'Sexo'.");
		document.form.txt_sexo.focus();
	return false;
	}

	if (document.form.txt_dtnasc.value.length < 1){
		alert("Preencha o campo 'Data de Nascimento'.");
		document.form.txt_dtnasc.focus();
		return false;
	}else{
		if(!validDate(document.form.txt_dtnasc.value)){
			alert("Dados inválidos no campo 'Data de Nascimento'.")
			document.form.txt_dtnasc.focus();
			return false;
		}
	}

	if (document.form.txt_instrucao.value == "-1"){
		alert("Selecione o campo 'Grau de Instrução'.");
		document.form.txt_instrucao.focus();
	return false;
	}

	if (document.form.txt_cep.value == ""){
		alert("Preencha o campo 'CEP'.");
		document.form.txt_cep.focus();
	return false;
	}

	if (document.form.txt_endereco.value == ""){
		alert("Preencha o campo 'Endereço'.");
		document.form.txt_endereco.focus();
	return false;
	}

	if (document.form.txt_endereco.value.length < 3){
		alert("O campo 'Endereço' não está preenchido corretamente!");
		document.form.txt_endereco.focus();
	return false;
	}

	if (document.form.txt_numero.value == ""){
	alert("Preencha o campo 'Número'.");
		document.form.txt_numero.focus();
	return false;
	}

	if (document.form.txt_bairro.value == ""){
		alert("Preencha o campo 'Bairro'.");
		document.form.txt_bairro.focus();
	return false;
	}

	if (document.form.txt_bairro.value.length < 3){
		alert("O campo 'Bairro' não está preenchido corretamente!");
		document.form.txt_bairro.focus();
	return false;
	}

	if (document.form.txt_cidade.value == ""){
		alert("Preencha o campo 'Cidade'.");
		document.form.txt_cidade.focus();
	return false;
	}

	if (document.form.txt_cidade.value.length < 3){
		alert("O campo 'Cidade' não está preenchido corretamente!");
		document.form.txt_cidade.focus();
	return false;
	}

	if (document.form.txt_uf.value == "-1"){
		alert("Selecione o campo 'UF'.");
		document.form.txt_uf.focus();
	return false;
	}

	if (document.form.txt_telefone.value == ""){
		alert("Preencha o campo 'Telefone'.");
		document.form.txt_telefone.focus();
	return false;
	}
return true;
}

function verifica_campos_instituicao_cat1(f) {

	
	if (document.cat1.txt1_nome.value == ""){
		alert("Preencha o campo 'Nome da Biblioteca'.");
		document.cat1.txt1_nome.focus();
	return false;
	}

	if (document.cat1.txt1_nome.value.length < 3){
		alert("O campo 'Nome' não está preenchido corretamente!");
		document.cat1.txt1_nome.focus();
	return false;
	}

	if (document.cat1.txt1_identificacao.value == "-1"){
		alert("Preencha o campo 'Identificação'.");
		document.cat1.txt1_identificacao.focus();
	return false;
	}

	if (document.cat1.txt1_localizacao.value == "-1"){
		alert("Preencha o campo 'Localização'.");
		document.cat1.txt1_localizacao.focus();
	return false;
	}
	
	if (document.cat1.txt1_mantenedora.value == "-1"){
		alert("Preencha o campo 'Mantenedora'.");
		document.cat1.txt1_mantenedora.focus();
	return false;
	}
	
	if (document.cat1.txt1_mantenedora.value == "4"){
		if (document.cat1.txt1_outros.value == ""){
			alert("Preencha o campo 'Outros'.");
			document.cat1.txt1_outros.focus();
		return false;
		}
	}
	
	if (document.cat1.txt1_endereco.value == ""){
		alert("Preencha o campo 'Endereço'.");
		document.cat1.txt1_endereco.focus();
	return false;
	}

	if (document.cat1.txt1_endereco.value.length < 3){
		alert("O campo 'Endereço' não está preenchido corretamente!");
		document.cat1.txt1_endereco.focus();
	return false;
	}

	if (document.cat1.txt1_numero.value == ""){
	alert("Preencha o campo 'Número'.");
		document.cat1.txt1_numero.focus();
	return false;
	}
	if (document.cat1.txt1_bairro.value == ""){
		alert("Preencha o campo 'Bairro'.");
		document.cat1.txt1_bairro.focus();
	return false;
	}

	if (document.cat1.txt1_bairro.value.length < 3){
		alert("O campo 'Bairro' não está preenchido corretamente!");
		document.cat1.txt1_bairro.focus();
	return false;
	}

	if (document.cat1.txt1_cidade.value == ""){
		alert("Preencha o campo 'Cidade'.");
		document.cat1.txt1_cidade.focus();
	return false;
	}

	if (document.cat1.txt1_cidade.value.length < 3){
		alert("O campo 'Cidade' não está preenchido corretamente!");
		document.cat1.txt1_cidade.focus();
	return false;
	}

	if (document.cat1.txt1_uf.value == "-1"){
		alert("Selecione o campo 'UF'.");
		document.cat1.txt1_uf.focus();
	return false;
	}
	if (document.cat1.txt1_cep.value == ""){
		alert("Preencha o campo 'CEP'.");
		document.cat1.txt1_cep.focus();
	return false;
	}

	if (document.cat1.txt1_telefone.value == ""){
		alert("Preencha o campo 'Telefone'.");
		document.cat1.txt1_telefone.focus();
	return false;
	}

	if (document.cat1.txt1_email.value < 1){
		alert("Preencha o campo 'E-Mail'.");
		document.cat1.txt1_email.focus();
	return false;
	}

	var  exp = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z,_]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$/;

	if (!exp.test(document.cat1.txt1_email.value)) {
		alert("E-mail inválido!");
		document.cat1.txt1_email.focus();
	return false;
	}

return true;
}


function verifica_campos_instituicao_cat2(f) {
	

	
	if (document.cat2.txt2_cnpj.value == ""){
	alert("Preencha o campo 'CNPJ'.");
		document.cat2.txt2_cnpj.focus();
	return false;
	}
	
	if (!checkCNPJ(document.cat2.txt2_cnpj, 'CNPJ inválido.')){
		alert("'CNPJ' inválido.");
		document.cat2.txt2_cnpj.focus();
		return false;
	}
		

	if (document.cat2.txt2_nome.value == ""){
		alert("Preencha o campo 'Nome'.");
		document.cat2.txt2_nome.focus();
	return false;
	}

	if (document.cat2.txt2_nome.value.length < 3){
		alert("O campo 'Nome' não está preenchido corretamente!");
		document.cat2.txt2_nome.focus();
	return false;
	}
	
	if (document.cat2.txt2_identificacao.value == "-1"){
		alert("Preencha o campo 'Identificação'.");
		document.cat2.txt2_identificacao.focus();
	return false;
	}
	
	if (document.cat2.txt2_localizacao.value == "-1"){
		alert("Preencha o campo 'Localização'.");
		document.cat2.txt2_localizacao.focus();
	return false;
	}

	if (document.cat2.txt2_endereco.value == ""){
		alert("Preencha o campo 'Endereço'.");
		document.cat2.txt2_endereco.focus();
	return false;
	}

	if (document.cat2.txt2_endereco.value.length < 3){
		alert("O campo 'Endereço' não está preenchido corretamente!");
		document.cat2.txt2_endereco.focus();
	return false;
	}

	if (document.cat2.txt2_numero.value == ""){
	alert("Preencha o campo 'Número'.");
		document.cat2.txt2_numero.focus();
	return false;
	}
	if (document.cat2.txt2_bairro.value == ""){
		alert("Preencha o campo 'Bairro'.");
		document.cat2.txt2_bairro.focus();
	return false;
	}

	if (document.cat2.txt2_bairro.value.length < 3){
		alert("O campo 'Bairro' não está preenchido corretamente!");
		document.cat2.txt2_bairro.focus();
	return false;
	}

	if (document.cat2.txt2_cidade.value == ""){
		alert("Preencha o campo 'Cidade'.");
		document.cat2.txt2_cidade.focus();
	return false;
	}

	if (document.cat2.txt2_cidade.value.length < 3){
		alert("O campo 'Cidade' não está preenchido corretamente!");
		document.cat2.txt2_cidade.focus();
	return false;
	}

	if (document.cat2.txt2_uf.value == "-1"){
		alert("Selecione o campo 'UF'.");
		document.cat2.txt2_uf.focus();
	return false;
	}
	if (document.cat2.txt2_cep.value == ""){
		alert("Preencha o campo 'CEP'.");
		document.cat2.txt2_cep.focus();
	return false;
	}

	if (document.cat2.txt2_telefone.value == ""){
		alert("Preencha o campo 'Telefone'.");
		document.cat2.txt2_telefone.focus();
	return false;
	}

	if (document.cat2.txt2_email.value < 1){
		alert("Preencha o campo 'E-Mail'.");
		document.cat2.txt2_email.focus();
	return false;
	}

	var  exp = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z,_]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$/;

	if (!exp.test(document.cat2.txt2_email.value)) {
		alert("E-mail inválido!");
		document.cat2.txt2_email.focus();
	return false;
	}

return true;
}

function verifica_campos_instituicao_cat3a(f) {

	if (document.cat3a.txt3a_cnpj.value == ""){
	alert("Preencha o campo 'CPF'.");
		document.cat3a.txt3a_cnpj.focus();
	return false;
	}
	
	if (!checkCPF(document.cat3a.txt3a_cnpj, 'CPF inválido.')){
		alert("'CPF' inválido.");
		document.cat3a.txt3a_cnpj.focus();
		return false;
	}
	if (document.cat3a.txt3a_nome.value == ""){
		alert("Preencha o campo 'Nome'.");
		document.cat3a.txt3a_nome.focus();
	return false;
	}

	if (document.cat3a.txt3a_nome.value.length < 3){
		alert("O campo 'Nome' não está preenchido corretamente!");
		document.cat3a.txt3a_nome.focus();
	return false;
	}

	if (document.cat3a.txt3a_identificacao.value == "-1"){
		alert("Preencha o campo 'Identificação'.");
		document.cat3a.txt3a_identificacao.focus();
	return false;
	}

	if (document.cat3a.txt3a_localizacao.value == "-1"){
		alert("Preencha o campo 'Localização'.");
		document.cat3a.txt3a_localizacao.focus();
	return false;
	}

	if (document.cat3a.txt3a_endereco.value == ""){
		alert("Preencha o campo 'Endereço'.");
		document.cat3a.txt3a_endereco.focus();
	return false;
	}

	if (document.cat3a.txt3a_endereco.value.length < 3){
		alert("O campo 'Endereço' não está preenchido corretamente!");
		document.cat3a.txt3a_endereco.focus();
	return false;
	}

	if (document.cat3a.txt3a_numero.value == ""){
	alert("Preencha o campo 'Número'.");
		document.cat3a.txt3a_numero.focus();
	return false;
	}
	if (document.cat3a.txt3a_bairro.value == ""){
		alert("Preencha o campo 'Bairro'.");
		document.cat3a.txt3a_bairro.focus();
	return false;
	}

	if (document.cat3a.txt3a_bairro.value.length < 3){
		alert("O campo 'Bairro' não está preenchido corretamente!");
		document.cat3a.txt3a_bairro.focus();
	return false;
	}

	if (document.cat3a.txt3a_cidade.value == ""){
		alert("Preencha o campo 'Cidade'.");
		document.cat3a.txt3a_cidade.focus();
	return false;
	}

	if (document.cat3a.txt3a_cidade.value.length < 3){
		alert("O campo 'Cidade' não está preenchido corretamente!");
		document.cat3a.txt3a_cidade.focus();
	return false;
	}

	if (document.cat3a.txt3a_uf.value == "-1"){
		alert("Selecione o campo 'UF'.");
		document.cat3a.txt3a_uf.focus();
	return false;
	}
	if (document.cat3a.txt3a_cep.value == ""){
		alert("Preencha o campo 'CEP'.");
		document.cat3a.txt3a_cep.focus();
	return false;
	}

	if (document.cat3a.txt3a_telefone.value == ""){
		alert("Preencha o campo 'Telefone'.");
		document.cat3a.txt3a_telefone.focus();
	return false;
	}

	if (document.cat3a.txt3a_email.value < 1){
		alert("Preencha o campo 'E-Mail'.");
		document.cat3a.txt3a_email.focus();
	return false;
	}

	var  exp = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z,_]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$/;

	if (!exp.test(document.cat3a.txt3a_email.value)) {
		alert("E-mail inválido!");
		document.cat3a.txt3a_email.focus();
	return false;
	}

return true;
}


function verifica_campos_instituicao_cat3b(f) {
	if (document.cat3b.txt3b_identificacao.value == "-1"){
		alert("Preencha o campo 'Identificação'.");
		document.cat3b.txt3b_identificacao.focus();
	return false;
	}
	
	if (document.cat3b.txt3b_identificacao.value != "5") {
		if (document.cat3b.txt3b_cnpj2.value == ""){
			alert("Preencha o campo 'CNPJ'.");
			document.cat3b.txt3b_cnpj2.focus();
			return false;

		}		
		if (!checkCNPJ(document.cat3b.txt3b_cnpj2, 'CNPJ inválido.')){
			alert("'CNPJ' inválido.");
			document.cat3b.txt3b_cnpj2.focus();
			return false;
		}			

	}else{
		
		if (document.cat3b.txt3b_cnpj3.value == ""){
			alert("Preencha o campo 'CNPJ/CPF'.");
			document.cat3b.txt3b_cnpj3.focus();
			return false;
		}		
		if(document.cat3b.txt3b_cnpj3.value.length <= 11){
			if (!checkCPF(document.cat3b.txt3b_cnpj3, 'CPF inválido.')){
				alert("'CPF' inválido.");
				document.cat3b.txt3b_cnpj3.focus();
				return false;
			}
		}else{
			if (!checkCNPJ(document.cat3b.txt3b_cnpj3, 'CNPJ inválido.')){
				alert("'CNPJ' inválido.");
				document.cat3b.txt3b_cnpj3.focus();
				return false;
			}
		}
	}
	
	if (document.cat3b.txt3b_nome.value == ""){
		alert("Preencha o campo 'Nome'.");
		document.cat3b.txt3b_nome.focus();
	return false;
	}

	if (document.cat3b.txt3b_nome.value.length < 3){
		alert("O campo 'Nome' não está preenchido corretamente!");
		document.cat3b.txt3b_nome.focus();
	return false;
	}



	if (document.cat3b.txt3b_localizacao.value == "-1"){
		alert("Preencha o campo 'Localização'.");
		document.cat3b.txt3b_localizacao.focus();
	return false;
	}

	if (document.cat3b.txt3b_endereco.value == ""){
		alert("Preencha o campo 'Endereço'.");
		document.cat3b.txt3b_endereco.focus();
	return false;
	}

	if (document.cat3b.txt3b_endereco.value.length < 3){
		alert("O campo 'Endereço' não está preenchido corretamente!");
		document.cat3b.txt3b_endereco.focus();
	return false;
	}

	if (document.cat3b.txt3b_numero.value == ""){
	alert("Preencha o campo 'Número'.");
		document.cat3b.txt3b_numero.focus();
	return false;
	}
	if (document.cat3b.txt3b_bairro.value == ""){
		alert("Preencha o campo 'Bairro'.");
		document.cat3b.txt3b_bairro.focus();
	return false;
	}

	if (document.cat3b.txt3b_bairro.value.length < 3){
		alert("O campo 'Bairro' não está preenchido corretamente!");
		document.cat3b.txt3b_bairro.focus();
	return false;
	}

	if (document.cat3b.txt3b_cidade.value == ""){
		alert("Preencha o campo 'Cidade'.");
		document.cat3b.txt3b_cidade.focus();
	return false;
	}

	if (document.cat3b.txt3b_cidade.value.length < 3){
		alert("O campo 'Cidade' não está preenchido corretamente!");
		document.cat3b.txt3b_cidade.focus();
	return false;
	}

	if (document.cat3b.txt3b_uf.value == "-1"){
		alert("Selecione o campo 'UF'.");
		document.cat3b.txt3b_uf.focus();
	return false;
	}
	if (document.cat3b.txt3b_cep.value == ""){
		alert("Preencha o campo 'CEP'.");
		document.cat3b.txt3b_cep.focus();
	return false;
	}

	if (document.cat3b.txt3b_telefone.value == ""){
		alert("Preencha o campo 'Telefone'.");
		document.cat3b.txt3b_telefone.focus();
	return false;
	}

	if (document.cat3b.txt3b_email.value < 1){
		alert("Preencha o campo 'E-Mail'.");
		document.cat3b.txt3b_email.focus();
	return false;
	}

	var  exp = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z,_]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$/;

	if (!exp.test(document.cat3b.txt3b_email.value)) {
		alert("E-mail inválido!");
		document.cat3b.txt3b_email.focus();
	return false;
	}

return true;
}


function verifica_campos_projeto_01(f) {

	if (document.form.txt_resumo.value == ""){
	alert("Preencha o campo 'Idéia do Trabalho'.");
		document.form.txt_resumo.focus();
	return false;
	}

	if (document.form.txt_respid.value == "-1"){
		alert("Selecione o campo 'Instituição'.");
		document.form.txt_respid.focus();
	return false;
	}

	if (document.form.txt_categoria.value == "-1"){
		alert("Selecione o campo 'Categoria'.");
		document.form.txt_categoria.focus();
	return false;
	}
return true;
}

function verifica_campos_projeto_cat1(f) {
	
	if (document.form.txt_resumo.value == ""){
	alert("Preencha o campo 'Idéia do Trabalho'.");
		document.form.txt_resumo.focus();
	return false;
	}
	
	if (document.form.txt_nome.value == ""){
		alert("Preencha o campo 'Título do Trabalho'.");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_nome.value.length < 3){
		alert("O campo 'Título do Trabalho' não está preenchido corretamente!");
		document.form.txt_nome.focus();
	return false;
	}
	
	if (document.form.txt_publico1.checked != true && document.form.txt_publico2.checked != true && document.form.txt_publico3.checked != true){
		alert("Selecione o campo 'Público Destinado'.");
		//document.form.txt_publico1.focus();
		return false;
	}else{
		
		if (document.form.txt_publico1.checked == true){
			document.form.txt_hdn_publico1.value = "1";
		}
		if (document.form.txt_publico2.checked == true){
			document.form.txt_hdn_publico2.value = "1";
		}		
		if (document.form.txt_publico3.checked == true){
			document.form.txt_hdn_publico3.value = "1";
		}		
	}
	
	if (document.form.txt_quantidade.value == ""){
		alert("Quantidade (Público atingido):");
		document.form.txt_quantidade.focus();
	return false;
	}
	
	if (document.form.txt_envolvidos.value == ""){
		alert("Preencha o campo 'Número de pessoas envolvidas na execução'.");
		document.form.txt_envolvidos.focus();
	return false;
	}

	if (document.form.txt_duracao.value == ""){
		alert("Preencha o campo 'Duração do Trabalho'.");
		document.form.txt_duracao.focus();
	return false;
	}

	if (document.form.txt_dtin.value.length < 1){
		alert("Preencha o campo 'Início do Trabalho'.");
		document.form.txt_dtin.focus();
		return false;
	}else{
		if(validDateMesAno(document.form.txt_dtin.value)){
			alert("Dados inválidos no campo 'Início do Trabalho'.")
			document.form.txt_dtin.focus();
			return false;
		}
	}

	if (document.form.txt_dtfim.value.length < 1){
		alert("Preencha o campo 'Fim do Trabalho'.");
		document.form.txt_dtfim.focus();
		return false;
	}else{
		if(validDateMesAno(document.form.txt_dtfim.value)){
			alert("Dados inválidos no campo 'Fim do Trabalho'.")
			document.form.txt_dtfim.focus();
			return false;
		}
	}
	if (document.form.txt_anexo.value == ""){
		alert("Insira um arquivo no campo 'Anexe aqui o seu trabalho'.");
		document.form.txt_anexo.focus();
	return false;
	}		
return true;
}
function verifica_campos_projeto_cat3(f) {
	
	if (document.form.txt_resumo.value == ""){
	alert("Preencha o campo 'Idéia do Trabalho'.");
		document.form.txt_resumo.focus();
	return false;
	}
	
	if (document.form.txt_nome.value == ""){
		alert("Preencha o campo 'Título do Trabalho'.");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_nome.value.length < 3){
		alert("O campo 'Título do Trabalho' não está preenchido corretamente!");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_publico1.checked != true && document.form.txt_publico2.checked != true && document.form.txt_publico3.checked != true){
		alert("Selecione o campo 'Público Destinado'.");
		//document.form.txt_publico1.focus();
		return false;
	}else{
		
		if (document.form.txt_publico1.checked == true){
			document.form.txt_hdn_publico1.value = "1";
		}
		if (document.form.txt_publico2.checked == true){
			document.form.txt_hdn_publico2.value = "1";
		}		
		if (document.form.txt_publico3.checked == true){
			document.form.txt_hdn_publico3.value = "1";
		}		
	}
	
	if (document.form.txt_quantidade.value == ""){
		alert("Quantidade (Público atingido):");
		document.form.txt_quantidade.focus();
	return false;
	}

	if (document.form.txt_atingidos.value == ""){
		alert("Preencha o campo 'Número de alunos atingidos'.");
		document.form.txt_atingidos.focus();
	return false;
	}

	if (document.form.txt_envolvidos.value == ""){
		alert("Preencha o campo 'Número de pessoas envolvidas na execução'.");
		document.form.txt_envolvidos.focus();
	return false;
	}

	if (document.form.txt_duracao.value == ""){
		alert("Preencha o campo 'Duração do Trabalho'.");
		document.form.txt_duracao.focus();
	return false;
	}

	if (document.form.txt_dtin.value.length < 1){
		alert("Preencha o campo 'Início do Trabalho'.");
		document.form.txt_dtin.focus();
		return false;
	}else{
		if(validDateMesAno(document.form.txt_dtin.value)){
			alert("Dados inválidos no campo 'Início do Trabalho'.")
			document.form.txt_dtin.focus();
			return false;
		}
	}

	if (document.form.txt_dtfim.value.length < 1){
		alert("Preencha o campo 'Fim do Trabalho'.");
		document.form.txt_dtfim.focus();
		return false;
	}else{
		if(validDateMesAno(document.form.txt_dtfim.value)){
			alert("Dados inválidos no campo 'Fim do Trabalho'.")
			document.form.txt_dtfim.focus();
			return false;
		}
	}
	
	if (document.form.txt_anexo.value == ""){
		alert("Insira um arquivo no campo 'Anexe aqui o seu trabalho'.");
		document.form.txt_anexo.focus();
	return false;
	}	
return true;
}

function verifica_campos_projeto_cat2(f) {

	if (document.form.txt_resumo.value == ""){
	alert("Preencha o campo 'Idéia do Trabalho'.");
		document.form.txt_resumo.focus();
	return false;
	}

	if (document.form.txt_nome.value == ""){
		alert("Preencha o campo 'Título do Trabalho'.");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_nome.value.length < 3){
		alert("O campo 'Título do Trabalho' não está preenchido corretamente!");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_atingidos.value == ""){
		alert("Preencha o campo 'Número de alunos atingidos'.");
		document.form.txt_atingidos.focus();
	return false;
	}

	if (document.form.txt_envolvidos.value == ""){
		alert("Preencha o campo 'Número de pessoas envolvidas na execução'.");
		document.form.txt_envolvidos.focus();
	return false;
	}

	if (document.form.txt_duracao.value == ""){
		alert("Preencha o campo 'Duração do Trabalho'.");
		document.form.txt_duracao.focus();
	return false;
	}

	if (document.form.txt_dtin.value.length < 1){
		alert("Preencha o campo 'Início do Trabalho'.");
		document.form.txt_dtin.focus();
		return false;
	}else{
		if(validDateMesAno(document.form.txt_dtin.value)){
			alert("Dados inválidos no campo 'Início do Trabalho'.")
			document.form.txt_dtin.focus();
			return false;
		}
	}

	if (document.form.txt_dtfim.value.length < 1){
		alert("Preencha o campo 'Fim do Trabalho'.");
		document.form.txt_dtfim.focus();
		return false;
	}else{
		if(validDateMesAno(document.form.txt_dtfim.value)){
			alert("Dados inválidos no campo 'Fim do Trabalho'.")
			document.form.txt_dtfim.focus();
			return false;
		}
	}
	if (document.form.txt_anexo.value == ""){
		alert("Insira um arquivo no campo 'Anexe aqui o seu trabalho'.");
		document.form.txt_anexo.focus();
	return false;
	}		
return true;
}

function verifica_campos_login(f) {

	if (document.form.txt_email.value < 1){
		alert("Preencha o campo 'E-Mail'.");
		document.form.txt_email.focus();
	return false;
	}

	var  exp = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z,_]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$/;

	if (!exp.test(document.form.txt_email.value)) {
		alert("E-mail inválido!");
		document.form.txt_email.focus();
	return false;
	}

	if (document.form.txt_cpf.value == ""){
	alert("Preencha o campo 'CPF'.");
		document.form.txt_cpf.focus();
	return false;
	}

	if (!checkCPF(document.form.txt_cpf, 'CPF inválido.')){
		alert("'CPF' inválido.");
		document.form.txt_cpf.focus();
		return false;
	}
return true;
}


function verifica_campos_contato(f) {


	if (document.form.txt_nome.value == ""){
		alert("Preencha o campo 'Nome'.");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_nome.value.length < 3){
		alert("O campo 'Nome' não está preenchido corretamente!");
		document.form.txt_nome.focus();
	return false;
	}

	if (document.form.txt_email.value < 1){
		alert("Preencha o campo 'E-Mail'.");
		document.form.txt_email.focus();
	return false;
	}

	var  exp = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z,_]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$/;

	if (!exp.test(document.form.txt_email.value)) {
		alert("E-mail inválido!");
		document.form.txt_email.focus();
	return false;
	}

	if (document.form.txt_cidade.value == ""){
		alert("Preencha o campo 'Cidade'.");
		document.form.txt_cidade.focus();
	return false;
	}

	if (document.form.txt_cidade.value.length < 3){
		alert("O campo 'Cidade' não está preenchido corretamente!");
		document.form.txt_cidade.focus();
	return false;
	}

	if (document.form.txt_assunto.value == ""){
		alert("Preencha o campo 'Assunto'.");
		document.form.txt_assunto.focus();
	return false;
	}

	if (document.form.txt_assunto.value.length < 4){
		alert("O campo 'Assunto' deve ter pelo menos 4 caracteres!");
		document.form.txt_assunto.focus();
	return false;
	}

	if (document.form.txt_mensagem.value == ""){
		alert("Preencha o campo 'Mensagem'.");
		document.form.txt_mensagem.focus();
	return false;
	}

	if (document.form.txt_mensagem.value.length < 4){
		alert("O campo 'mensagem' deve ter pelo menos 4 caracteres!");
		document.form.txt_mensagem.focus();
	return false;
	}


return true;
}



