function SomenteNumeros()
 {
  if (((event.keyCode >= 48) && (event.keyCode <= 57)) || (event.keyCode == 13))
   {
    return true;
   }
  else
   {
    if (event.keyCode != 8)
     {
      alert("                Erro!\n Valor de entrada inválido!\nCampo deve ser numérico!");
      event.keyCode = 0
      return false;
     }
   }
 }


function isMail(obj)
 { 
  arroba = "@";
  mail = obj.value;
  if (mail == "")
    return false;
     
  A1 = mail.indexOf(arroba);
  if (A1 < 0)
    return false;  
     
  cliente = mail.substring(0,A1);
  provedor = mail.substring(A1+1,mail.length);
  ponto = ".";
  P1 = provedor.indexOf(ponto);
         
  if (P1 < 0)
    return false;
  
  return true;
 }


function checkForm()
 {
  if (document.f.tp_contato.selectedIndex <= 0)
   {
    alert("Escolha o tipo de contato que irá fazer com a Ouvidoria!");
    f.tp_contato.focus();
    return false;
   }

  if (document.f.tp_interessado(0).checked) //contabilista
   {
    opc_tp_interessado = 0;
    if (document.f.UF_Registro.selectedIndex <= 0)
     {
      alert("Escolha a UF do número de registro!");
      f.UF_Registro.focus();
      return false;
     }
    if (document.f.Num_Registro.value.length != 6)
     {
      alert("Preencha o número de registro com 6 (seis) dígitos!\n\nEx.: Registro n.º 1 originário do CRCBA.\nO preenchimento deverá ser: BA-000001/O");
      f.Num_Registro.focus();
      return false;
     }
    if (document.f.Tipo_Registro.selectedIndex <= 0)
     {
      alert("Escolha o tipo do registro!");
      f.Tipo_Registro.focus();
      return false;
     }
   }

  if (document.f.tp_interessado(1).checked) //nao contabilista
    opc_tp_interessado = 1;


  if (document.f.interessado.value.length < 10)
   {
    alert("Preencha o campo 'Nome' com pelo menos 10 caracteres/espaços!");
    f.interessado.focus();
    return false;
   }
  
  if (document.f.sexo(0).checked) //masculino
    opc_sexo = 0;

  if (document.f.sexo(1).checked) //feminino
    opc_sexo = 1;

  if (document.f.CI.value.length == "")
   {
    alert("Preencha o campo 'Cart. de Identidade'!");
    f.CI.focus();
    return false;
   }

  if (document.f.CPF.value.length != 14)
   {
    alert("Preencha o campo 'CPF' com 11 (onze) dígitos numéricos!");
    f.CPF.focus();
    return false;
   }

  if (document.f.End.value.length == "")
   {
    alert("Preencha o campo 'Endereço'!");
    f.End.focus();
    return false;
   }

  if (document.f.Bairro.value.length == "")
   {
    alert("Preencha o campo 'Bairro'!");
    f.Bairro.focus();
    return false;
   }

  if (document.f.CEP.value.length != 9)
   {
    alert("Preencha o campo 'CEP' com 8 (oito) dígitos numéricos!");
    f.CEP.focus();
    return false;
   }

  if (document.f.Cidade.value.length == "")
   {
    alert("Preencha o campo 'Cidade'!");
    f.Cidade.focus();
    return false;
   }

  if (document.f.UF.value.length == "")
   {
    alert("Preencha o campo 'UF' do Endereço!");
    f.UF.focus();
    return false;
   } 
  
  val_email = isMail(f.emailremetente);
  if (val_email == false)
   {
    alert("Formato de E-mail inválido!\nFormato válido: conta@provedor.tipo\nEx: usuário@provedor.com.br");
    f.emailremetente.focus();
    return false;
   }

  if (document.f.txt_interessado.value == "" || document.f.txt_interessado.value.length < 10) {
   alert("Digite o seu pronunciamento!");
   f.txt_interessado.focus();
   return false;
  }

  if (document.f.resposta(0).checked) //eletronico
    opc_resposta = 0;

  if (document.f.resposta(1).checked) //postal
    opc_resposta = 1;

 
  if(confirm("Deseja realmente enviar o seu pronunciamento ao CRCBA?"))
   {
    alert("          Obrigado pelo contato!\n\nSeu pronunciamento está sendo enviado para a Ouvidoria!")
    return true
   }
  else
   {
    alert("Envio de dados cancelado!!")
    return false
   }

 }

