<!--
function valida_duvida(theForm)
{
   if (theForm.cnpj_cpf.value == "")
  {
    alert("Digite um valor para o campo \"CNPJ_CPF\".");
    theForm.cnpj_cpf.focus();
    return (false);
  }

if (theForm.tipopessoa[0].checked == true)
	{
	wtipopessoa = "J";
	}
	
if (theForm.tipopessoa[1].checked == true)
	{
	wtipopessoa = "F";
	}


if (wtipopessoa == "F")
	{
				 cpf = theForm.cnpj_cpf.value;
                 erro = new String;
                 if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! "; 
                 var nonNumbers = /\D/;
                 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! "; 
                 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
                         erro += "Numero de CPF invalido!"
                 }
                 var a = [];
                 var b = new Number;
                 var c = 11;
                 for (i=0; i<11; i++){
                       a[i] = cpf.charAt(i);
                       if (i < 9) b += (a[i] * --c);
                 }
                 if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
                 b = 0;
                 c = 11;
                 for (y=0; y<10; y++) b += (a[y] * c--); 
                 if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
                 if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
                       erro +="Digito verificador do CPF com problema!";
                 }
                 if (erro.length > 0){
                       alert(erro);
                       return false;
					   
                 }
				// return true;
				}
else
{
	 // verifica o tamanho
			pcgc = theForm.cnpj_cpf.value
			if (pcgc.length != 14) {
				sim=false
				alert ("Tamanho Invalido do CNPJ!")
				theForm.cnpj_cpf.focus()
				return false
			}
			else {sim=true}
			if (sim )  // verifica se e numero
			{
			for (i=0;((i<=(pcgc.length-1))&& sim); i++)
			{
			val = pcgc.charAt(i)

      // alert (val)
		if
		((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4") &&
		(val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {sim=false}
		}

		if (sim)  // se for numero continua
		{
		m2 = 2
		soma1 = 0
		soma2 = 0
		for (i=11;i>=0;i--)
		{
		val = eval(pcgc.charAt(i))

      // alert ("Valor do Val: "+val)
		m1 = m2
		if (m2<9) { m2 = m2+1}
		else {m2 = 2}
		soma1 = soma1 + (val * m1)
		soma2 = soma2 + (val * m2)
		}  // fim do for de soma
		soma1 = soma1 % 11
		if (soma1 < 2) {  d1 = 0}
		else { d1 = 11- soma1}
		soma2 = (soma2 + (2 * d1)) % 11
		if (soma2 < 2) { d2 = 0}
		else { d2 = 11- soma2}

        //alert (d1)

        //alert (d2)

		if ((d1!=pcgc.charAt(12)) || (d2!=pcgc.charAt(13)))
		{
		alert("Valor do CNPJ está inválido!")
		theForm.cnpj_cpf.focus()
		return false
		}
		}
}

}


  if (theForm.cidade.value == "")
  {
    alert("Digite um valor para o campo \"Cidade\".");
    theForm.cidade.focus();
    return (false);
  }

  if (theForm.estado.value == "")
  {
    alert("Digite um valor para o campo \"Estado\".");
    theForm.estado.focus();
    return (false);
  }

  if (theForm.estado.value.length > 2)
  {
    alert("Digite no máximo 2 caracteres no campo \"Estado\".");
    theForm.estado.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz";
  var checkStr = theForm.estado.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite somente letra caracteres maiscúlas o campo \"Estado\" (ex. SP)");
    theForm.estado.focus();
    return (false);
  }

  if (theForm.cep.value == "")
  {
    alert("Digite um valor para o campo \"CEP\".");
    theForm.cep.focus();
    return (false);
  }

  if (theForm.cep.value.length > 9)
  {
    alert("Digite no máximo 9 caracteres no campo \"CEP\".");
    theForm.cep.focus();
    return (false);
  }
  
  if (theForm.cep.value.length < 8)
  {
    alert("Digite no minimo 8 caracteres no campo \"CEP\".");
    theForm.cep.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.cep.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite somente números no campo \"CEP\" (ex.: 15700-000)");
    theForm.cep.focus();
    return (false);
  }
 
  if (theForm.telefone.value == "")
  {
    alert("Digite um valor para o campo \"Telefone\".");
    theForm.telefone.focus();
    return (false);
  }

  if (theForm.telefone.value.length > 15)
  {
    alert("Digite no máximo 15 caracteres no campo \"Telefone\".");
    theForm.telefone.focus();
    return (false);
  }
  
  if (theForm.telefone.value.length < 6)
  {
    alert("Digite no minimo 6 números no campo \"Telefone\".");
    theForm.telefone.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.telefone.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite somente números no campo \"Telefone\" (ex.: 9999-9999)");
    theForm.telefone.focus();
    return (false);
  }
   
   if (theForm.ddd.value == "")
  {
    alert("Digite um valor para o campo \"DDD\".");
    theForm.ddd.focus();
    return (false);
  }

  if (theForm.ddd.value.length > 2)
  {
    alert("Digite no máximo 2 caracteres no campo \"DDD\".");
    theForm.ddd.focus();
    return (false);
  }
  
  if (theForm.ddd.value.length < 2)
  {
    alert("Digite no minimo 2 números no campo \"DDD\".");
    theForm.ddd.focus();
    return (false);
  }

  var checkOK = "0123456789";
  var checkStr = theForm.ddd.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite somente números no campo \"DDD\" (ex.: 99)");
    theForm.ddd.focus();
    return (false);
  }

    if (theForm.ramal.value.length > 4)
  {
    alert("Digite no máximo 4 caracteres no campo \"Ramal\".");
    theForm.ramal.focus();
    return (false);
  }
  
 
  var checkOK = " 0123456789";
  var checkStr = theForm.ramal.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite somente números no campo \"Ramal\" (ex.: 99999)");
    theForm.ramal.focus();
    return (false);
  }
  
 
   if (theForm.email.value == "")
  {
    alert("Digite o endereço eletrônico para o campo \"Email\".");
    theForm.email.focus();
    return (false);
  }

  if (theForm.contato.value == "")
  {
    alert("Digite um nome para o campo \"Contato\".");
    theForm.contato.focus();
    return (false);
  }

  if (theForm.contato.value.length < 2)
  {
    alert("Digite no mínimo 2 caracteres no campo \"Contato\".");
    theForm.contato.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyzwáéíóúÁÉÍÓÚÜüçÇ ";
  var checkStr = theForm.contato.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Digite somente letras no campo \"Contato\" (ex. José)");
    theForm.contato.focus();
    return (false);
  }
  return (true);
}
//-->
