function validar(){


var reDigits = /^\d+$/;

var controle2 = 0;
for (i2=0;i2<document.form1.add.length;i2++){
if (document.form1.add[i2].type == "radio"){
if (document.form1.add[i2].checked == true){
controle2++;
}
}
}


if (controle2 < 1){
	if (document.form1.add1.value.length > 8 || document.form1.add2.value.length > 8 || document.form1.add3.value.length > 8 || document.form1.add4.value.length > 8 || document.form1.add5.value.length > 8){

}
else {
alert("Preencha corretamente ou cancele a lista de inscritos adicionais.");
 document.form1.add1.focus(); 
return false;
}

///////////////////////////////////////////////////////////

if (document.form1.add1.value.length < 1 && document.form1.email_add1.value.length > 0 || document.form1.add1.value.length > 0 && document.form1.email_add1.value.length < 1 ){
        alert("Preencha o nome e o e-mail dos inscritos adicionais."); 
      document.form1.add1.focus(); 
        return false; 
}


if (document.form1.add1.value.length > 8 && document.form1.email_add1.value.length > 8 ){
  
 if( document.form1.email_add1.value.length < 8 || document.form1.email_add1.value.indexOf("@")==-1 || document.form1.email_add1.value.indexOf(".")==-1){ 
        alert("Preencha corretamente o 2º campo de e-mail (referente ao 1º inscrito adicional)."); 
      document.form1.email_add1.focus(); 
        return false; 
       } 



}

///////////////////////////////////////////////// 2

if (document.form1.add2.value.length < 1 && document.form1.email_add2.value.length > 0 || document.form1.add2.value.length > 0 && document.form1.email_add2.value.length < 1 ){
        alert("Preencha o nome e o e-mail dos inscritos adicionais."); 
      document.form1.add2.focus(); 
        return false; 
}

if (document.form1.add2.value.length > 8 && document.form1.email_add2.value.length > 8){
 if(document.form1.email_add2.value.indexOf("@")==-1 || document.form1.email_add2.value.indexOf(".")==-1){ 
        alert("Preencha corretamente o 3º campo de e-mail (referente ao 2º inscrito adicional)."); 
      document.form1.email_add2.focus(); 
        return false; 
       } 

}

///////////////////////////////////////////////// 3

if (document.form1.add3.value.length < 1 && document.form1.email_add3.value.length > 0 || document.form1.add3.value.length > 0 && document.form1.email_add3.value.length < 1 ){
        alert("Preencha o nome e o e-mail dos inscritos adicionais."); 
      document.form1.add3.focus(); 
        return false; 
}

 if (document.form1.add3.value.length > 8 && document.form1.email_add3.value.length > 8){
 if(document.form1.email_add3.value.indexOf("@")==-1 || document.form1.email_add3.value.indexOf(".")==-1){ 
        alert("Preencha corretamente o 4º campo de e-mail (referente ao 3º inscrito adicional)."); 
      document.form1.email_add3.focus(); 
        return false; 
       } 


}
///////////////////////////////////////////////// 4

if (document.form1.add4.value.length < 1 && document.form1.email_add4.value.length > 0 || document.form1.add4.value.length > 0 && document.form1.email_add4.value.length < 1 ){
        alert("Preencha o nome e o e-mail dos inscritos adicionais."); 
      document.form1.add4.focus(); 
        return false; 
}

 if (document.form1.add4.value.length > 8 && document.form1.email_add4.value.length > 8){
 if(document.form1.email_add4.value.indexOf("@")==-1 || document.form1.email_add4.value.indexOf(".")==-1){ 
        alert("Preencha corretamente o 5º campo de e-mail (referente ao 4º inscrito adicional)."); 
      document.form1.email_add4.focus(); 
        return false; 
       } 


}
///////////////////////////////////////////////// 5

if (document.form1.add5.value.length < 1 && document.form1.email_add5.value.length > 0 || document.form1.add5.value.length > 0 && document.form1.email_add5.value.length < 1 ){
        alert("Preencha o nome e o e-mail dos inscritos adicionais."); 
      document.form1.add5.focus(); 
        return false; 
}

 if (document.form1.add5.value.length > 8 && document.form1.email_add5.value.length > 8){
 if(document.form1.email_add5.value.indexOf("@")==-1 || document.form1.email_add5.value.indexOf(".")==-1){ 
        alert("Preencha corretamente o 6º campo de e-mail (referente ao 5º inscrito adicional)."); 
      document.form1.email_add5.focus(); 
        return false; 
       } 


}

} //--- fecha o if do controle2


	   
       if (document.form1.nome.value.length <2) {
            alert("Preencha seu nome");
     document.form1.nome.focus();
        return false;
       }


       //email
       if(document.form1.email.value.indexOf("@")==-1 || document.form1.email.value.indexOf(".")==-1){ 
        alert("O campo e-mail não está preenchido corretamente"); 
      document.form1.email.focus(); 
        return false; 
       } 
	   
	   //curso
   campocurso = document.form1.curso.selectedIndex;
  if(campocurso == 0){
    alert('Informe o curso desejado');
    document.form1.curso.focus();
    return false;
      }


  
	  if (document.form1.responsavel.value.length <2) {
            alert("Preencha o nome do responsável pela inscrição");
     document.form1.responsavel.focus();
        return false;
       }	 
	   
       if (document.form1.profissao.value.length <2) {
            alert("Preencha sua profissão");
     document.form1.profissao.focus();
        return false;
       }


       if (document.form1.telefone.value.length <8) {
            alert("Preencha seu telefone corretamente");
     document.form1.telefone.focus();
        return false;
       }



       if (document.form1.cpf.value.length <11) {
            alert("Preencha seu cpf corretamente");
     document.form1.cpf.focus();
        return false;
       }


cpf = document.form1.cpf.value;
if (reDigits.test(cpf)) {} 
else if (cpf != null && cpf != "") {
alert("Digite apenas números no campo CPF");
document.form1.cpf.focus();
return false;
}




       if (document.form1.endereco.value.length <2) {
            alert("Preencha seu endereço");
     document.form1.endereco.focus();
        return false;
       }

       if (document.form1.numero.value.length <1) {
            alert("Preencha o número");
     document.form1.numero.focus();
        return false;
       }


       if (document.form1.bairro.value.length <1) {
            alert("Preencha o bairro");
     document.form1.bairro.focus();
        return false;
       }


       if (document.form1.cidade.value.length <1) {
            alert("Preencha a cidade");
     document.form1.cidade.focus();
        return false;
       }


  //validaçao da UF
  campouf = document.form1.uf.selectedIndex;
  if(campouf == 0){
    alert('Preencha a UF');
    document.form1.uf.focus();
    return false;
      }
	  

       if (document.form1.cep.value.length <8) {
            alert("Preencha o CEP corretamente");
     document.form1.cep.focus();
        return false;
       }



cep = document.form1.cep.value;
if (reDigits.test(cep)) {} 
else if (cep != null && cep != "") {
alert("Digite apenas números no campo CEP");
document.form1.cep.focus();
return false;
}









return true;

 }

//----------------------------------------------------------------------------------------------------


function validar2(){


var reDigits = /^\d+$/;



var controle3 = 0;
for (i2=0;i2<document.form1.add.length;i2++){
if (document.form1.add[i2].type == "radio"){
if (document.form1.add[i2].checked == true){
controle3++;
}
}
}


if (controle3 < 1){
	if (document.form1.add1.value.length > 8 || document.form1.add2.value.length > 8 || document.form1.add3.value.length > 8 || document.form1.add4.value.length > 8 || document.form1.add5.value.length > 8){

}
else {
alert("Preencha corretamente ou cancele a lista de inscritos adicionais.");
 document.form1.add1.focus(); 
return false;
}

///////////////////////////////////////////////////////////

if (document.form1.add1.value.length < 1 && document.form1.email_add1.value.length > 0 || document.form1.add1.value.length > 0 && document.form1.email_add1.value.length < 1 ){
        alert("Preencha o nome e o e-mail dos inscritos adicionais."); 
      document.form1.add1.focus(); 
        return false; 
}


if (document.form1.add1.value.length > 8 && document.form1.email_add1.value.length > 8 ){
  
 if( document.form1.email_add1.value.length < 8 || document.form1.email_add1.value.indexOf("@")==-1 || document.form1.email_add1.value.indexOf(".")==-1){ 
        alert("Preencha corretamente o 2º campo de e-mail (referente ao 1º inscrito adicional)."); 
      document.form1.email_add1.focus(); 
        return false; 
       } 


}

///////////////////////////////////////////////// 2

if (document.form1.add2.value.length < 1 && document.form1.email_add2.value.length > 0 || document.form1.add2.value.length > 0 && document.form1.email_add2.value.length < 1 ){
        alert("Preencha o nome e o e-mail dos inscritos adicionais."); 
      document.form1.add2.focus(); 
        return false; 
}

if (document.form1.add2.value.length > 8 && document.form1.email_add2.value.length > 8){
 if(document.form1.email_add2.value.indexOf("@")==-1 || document.form1.email_add2.value.indexOf(".")==-1){ 
        alert("Preencha corretamente o 3º campo de e-mail (referente ao 2º inscrito adicional)."); 
      document.form1.email_add2.focus(); 
        return false; 
       } 

}

///////////////////////////////////////////////// 3

if (document.form1.add3.value.length < 1 && document.form1.email_add3.value.length > 0 || document.form1.add3.value.length > 0 && document.form1.email_add3.value.length < 1 ){
        alert("Preencha o nome e o e-mail dos inscritos adicionais."); 
      document.form1.add3.focus(); 
        return false; 
}

 if (document.form1.add3.value.length > 8 && document.form1.email_add3.value.length > 8){
 if(document.form1.email_add3.value.indexOf("@")==-1 || document.form1.email_add3.value.indexOf(".")==-1){ 
        alert("Preencha corretamente o 4º campo de e-mail (referente ao 3º inscrito adicional)."); 
      document.form1.email_add3.focus(); 
        return false; 
       } 


}
///////////////////////////////////////////////// 4

if (document.form1.add4.value.length < 1 && document.form1.email_add4.value.length > 0 || document.form1.add4.value.length > 0 && document.form1.email_add4.value.length < 1 ){
        alert("Preencha o nome e o e-mail dos inscritos adicionais."); 
      document.form1.add4.focus(); 
        return false; 
}

 if (document.form1.add4.value.length > 8 && document.form1.email_add4.value.length > 8){
 if(document.form1.email_add4.value.indexOf("@")==-1 || document.form1.email_add4.value.indexOf(".")==-1){ 
        alert("Preencha corretamente o 5º campo de e-mail (referente ao 4º inscrito adicional)."); 
      document.form1.email_add4.focus(); 
        return false; 
       } 


}
///////////////////////////////////////////////// 5

if (document.form1.add5.value.length < 1 && document.form1.email_add5.value.length > 0 || document.form1.add5.value.length > 0 && document.form1.email_add5.value.length < 1 ){
        alert("Preencha o nome e o e-mail dos inscritos adicionais."); 
      document.form1.add5.focus(); 
        return false; 
}

 if (document.form1.add5.value.length > 8 && document.form1.email_add5.value.length > 8){
 if(document.form1.email_add5.value.indexOf("@")==-1 || document.form1.email_add5.value.indexOf(".")==-1){ 
        alert("Preencha corretamente o 6º campo de e-mail (referente ao 5º inscrito adicional)."); 
      document.form1.email_add5.focus(); 
        return false; 
       } 

}

} //--- fecha o if do controle3




           if (document.form1.nome.value.length <8) {
            alert("Preencha o nome do inscrito.");
     document.form1.nome.focus();
        return false;
       }
	   
       //email
       if(document.form1.email.value.indexOf("@")==-1 || document.form1.email.value.indexOf(".")==-1){ 
        alert("O campo e-mail não está preenchido corretamente"); 
      document.form1.email.focus(); 
        return false; 
       }
	   
	   
	   	   //curso
   campocurso = document.form1.curso.selectedIndex;
  if(campocurso == 0){
    alert('Informe o curso desejado');
    document.form1.curso.focus();
    return false;
      }

	   
       if (document.form1.organizacao.value.length <2) {
            alert("Preencha sua Organizaçao");
     document.form1.organizacao.focus();
        return false;
       }

       if (document.form1.cnpj.value.length <14) {
            alert("Preencha seu CNPJ corretamente");
     document.form1.cnpj.focus();
        return false;
       }

cnpj = document.form1.cnpj.value;
if (reDigits.test(cnpj)) {} 
else if (cnpj != null && cnpj != "") {
alert("Digite apenas números no campo CNPJ");
document.form1.cnpj.focus();
return false;
}


       if (document.form1.ramo.value.length <2) {
            alert("Preencha o ramo de atividade");
     document.form1.ramo.focus();
        return false;
       }


       if (document.form1.dirigente.value.length <2) {
            alert("Preencha o nome do Dirigente Principal");
     document.form1.dirigente.focus();
        return false;
       }


         if (document.form1.responsavel.value.length <2) {  
            alert("Preencha seu nome");
     document.form1.responsavel.focus();
        return false;
       }


       if (document.form1.cargo.value.length <2) {
            alert("Preencha o cargo");
     document.form1.cargo.focus();
        return false;
       }


       if (document.form1.endereco.value.length <2) {
            alert("Preencha seu endereço");
     document.form1.endereco.focus();
        return false;
       }

       if (document.form1.numero.value.length <1) {
            alert("Preencha o número");
     document.form1.numero.focus();
        return false;
       }


       if (document.form1.bairro.value.length <1) {
            alert("Preencha o bairro");
     document.form1.bairro.focus();
        return false;
       }


       if (document.form1.cidade.value.length <1) {
            alert("Preencha a cidade");
     document.form1.cidade.focus();
        return false;
       }


  //validaçao da UF
  campouf = document.form1.uf.selectedIndex;
  if(campouf == 0){
    alert('Preencha a UF');
    document.form1.uf.focus();
    return false;
      }


       if (document.form1.cep.value.length <8) {
            alert("Preencha o CEP corretamente");
     document.form1.cep.focus();
        return false;
       }

cep = document.form1.cep.value;
if (reDigits.test(cep)) {} 
else if (cep != null && cep != "") {
alert("Digite apenas números no campo CEP");
document.form1.cep.focus();
return false;
}





       if (document.form1.telefone.value.length <8) {
            alert("Preencha seu telefone corretamente");
     document.form1.telefone.focus();
        return false;
       }


  //email
  if(document.form1.email_responsavel.value.indexOf("@")==-1 || document.form1.email_responsavel.value.indexOf(".")==-1){ 
    alert("O e-mail do responsável pela inscrição não está preenchido corretamente."); 
    document.form1.email_responsavel.focus(); 
   return false; 
   } 


	   

return true;

 }




function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
   var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
 
   if(document.all) { // Internet Explorer
      nTecla = evtKeyPress.keyCode; }
   else if(document.layers) { // Nestcape
      nTecla = evtKeyPress.which;
   } else
      return;
 
   sValue = objForm[strField].value;
 
   // Limpa todos os caracteres de formataçao que
   // já estiverem no campo.
   sValue = sValue.toString().replace( "-", "" );
   sValue = sValue.toString().replace( "-", "" );
   sValue = sValue.toString().replace( ".", "" );
   sValue = sValue.toString().replace( ".", "" );
   sValue = sValue.toString().replace( "/", "" );
   sValue = sValue.toString().replace( "/", "" );
   sValue = sValue.toString().replace( "(", "" );
   sValue = sValue.toString().replace( "(", "" );
   sValue = sValue.toString().replace( ")", "" );
   sValue = sValue.toString().replace( ")", "" );
   sValue = sValue.toString().replace( " ", "" );
   sValue = sValue.toString().replace( " ", "" );
   fldLen = sValue.length;
   mskLen = sMask.length;
 
   i = 0;
   nCount = 0;
   sCod = "";
   mskLen = fldLen;
 
   while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
 
      if (bolMask) {
         sCod += sMask.charAt(i);
         mskLen++; }
      else {
         sCod += sValue.charAt(nCount);
         nCount++;
      }
 
      i++;
   }
 
   objForm[strField].value = sCod;
 
   if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
         return ((nTecla > 47) && (nTecla < 58));
      } // números de 0 a 9
      else if (sMask.charAt(i-1) == "X"){ // apenas letras
         return ( ( (nTecla >= 65) && (nTecla <= 90) ) || ( (nTecla >= 97) && (nTecla <= 122) ) );
      } else
         return true;
   }
   else {
       return true;
   }
}

function onlynum( e ) {
   var isNav4, isNav, isIE;
   if(event.keyCode==44) event.keyCode=46;
   if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
      isNav = (navigator.appName=="Netscape") ? true : false;
      isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
   }
   if (navigator.appName=="Netscape") {
      isNav4 = (parseInt(navigator.appVersion.charAt(0))==4);
   }
   var keyNumber = (isIE) ? event.keyCode : e.which;

   if( ( ( keyNumber < 48 ) || ( keyNumber > 57 ) ) && ( keyNumber != 13 ) &&
   ( keyNumber != "0" ) && ( keyNumber != 8 ) && ( keyNumber != 9 ) && ( keyNumber != 46 ) ) {
      if (isIE) event.keyCode=0;
      return false;
   }
}



