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.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.Remetente.value.length < 10)
   {
    alert("Preencha o campo 'Nome' com pelo menos 10 caracteres/espaços!");
    f.Remetente.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.Mae.value.length < 10)
   {
    alert("Preencha o campo 'Filiação (Nome da Mãe)' com pelo menos 10 caracteres/espaços!");
    f.Mae.focus();
    return false;
   }
  if (document.f.dia_nasc.value.length != 2)
   {
    alert("Preencha o dia de nascimento com 2 (dois) dígitos!");
    f.dia_nasc.focus();
    return false;
   }
  if (document.f.mes_nasc.value.length != 2)
   {
    alert("Preencha o mês de nascimento com 2 (dois) dígitos!");
    f.mes_nasc.focus();
    return false;
   }
  if (document.f.ano_nasc.value.length != 4)
   {
    alert("Preencha o ano de nascimento com 4 (quatro) dígitos!");
    f.ano_nasc.focus();
    return false;
   }
  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.correspondencia(0).checked) //Residencial
   {
    opc_corres = 0;
    if (document.f.End_res.value.length == "")
     {
      alert("Preencha o campo 'Endereço' do Endereço Residencial!");
      f.End_res.focus();
      return false;
     }
    if (document.f.Bairro_res.value.length == "")
     {
      alert("Preencha o campo 'Bairro' do Endereço Residencial!");
      f.Bairro_res.focus();
      return false;
     }
    if (document.f.CEP_res.value.length != 9)
     {
      alert("Preencha o campo 'CEP' do Endereço Residencial com 8 (oito) dígitos numéricos!");
      f.CEP_res.focus();
      return false;
     }
    if (document.f.Cidade_res.value.length == "")
     {
      alert("Preencha o campo 'Cidade' do Endereço Residencial!");
      f.Cidade_res.focus();
      return false;
     }
    if (document.f.UF_res.value.length == "")
     {
      alert("Preencha o campo 'UF' do Endereço Residencial!");
      f.UF_res.focus();
      return false;
     } 
   }
  if (document.f.correspondencia(1).checked) //Comercial
   {
    opc_corres = 1;
    if (document.f.End_com.value.length == "")
     {
      alert("Preencha o campo 'Endereço' do Endereço Comercial!");
      f.End_com.focus();
      return false;
     }
    if (document.f.Bairro_com.value.length == "")
     {
      alert("Preencha o campo 'Bairro' do Endereço Comercial!");
      f.Bairro_com.focus();
      return false;
     }
    if (document.f.CEP_com.value.length != 9)
     {
      alert("Preencha o campo 'CEP' do Endereço Comercial com 8 (oito) dígitos numéricos!");
      f.CEP_com.focus();
      return false;
     }
    if (document.f.Cidade_com.value.length == "")
     {
      alert("Preencha o campo 'Cidade' do Endereço Comercial!");
      f.Cidade_com.focus();
      return false;
     }
    if (document.f.UF_com.value.length == "")
     {
      alert("Preencha o campo 'UF' do Endereço Comercial!");
      f.UF_com.focus();
      return false;
     } 
   }
  
  alert("Confira os dados informados abaixo: \n\nCRC: "+document.f.UF_Registro.value+"-"+document.f.Num_Registro.value+"/"+document.f.Tipo_Registro.value+"\nNome: " +document.f.Remetente.value+ "\nE-mail: " +document.f.emailremetente.value+ "\nPai: " +document.f.pai.value+ "\nMãe: " +document.f.Mae.value+ "\nData de Nasc.: " +document.f.dia_nasc.value+ "/" +document.f.mes_nasc.value+ "/" +document.f.ano_nasc.value+ "\nIdentidade: " +document.f.CI.value+ "\nCPF: " +document.f.CPF.value+ "\n\n:: Endereço Residencial ::\n\nEndereço: " +document.f.End_res.value+ "\nBairro: " +document.f.Bairro_res.value+ "\nCEP: " +document.f.CEP_res.value+ "\nCidade - UF: " +document.f.Cidade_res.value+ "-" +document.f.UF_res.value+ "\nTelefone: (" +document.f.DDD_Tel_res.value+ ") " +document.f.Tel_res.value+ "\n\n:: Endereço Comercial ::\n\nEndereço: " +document.f.End_com.value+ "\nBairro: " +document.f.Bairro_com.value+ "\nCEP: " +document.f.CEP_com.value+ "\nCidade - UF: " +document.f.Cidade_com.value+ "-" +document.f.UF_com.value+ "\nTelefone: (" +document.f.DDD_Tel_com.value+ ") " +document.f.Tel_com.value+ "\n\n::Opção de Correspondência::\n " +document.f.correspondencia[opc_corres].value+ "\n\n");
  
  if(confirm("Deseja enviar a solicitação de Alteração de Endereço?"))
   {
    alert("                              Obrigado pelo contato!\n\nSua solicitação foi enviada para a Divisão de Registro e Cadastro\n\n                                 para Processamento!")
    return true
   }
  else
   {
    alert("Envio de dados cancelado!!")
    return false
   }

 }

