okespec=false;
okcat=false;
oksub=false;
function CheckEspec() {
    if(!okespec){
      for (var i=0;i<document.form_cad_produto.elements.length;i++) {
        var x = document.form_cad_produto.elements[i];
        if (x.name == 'checkespec[]') {        
                x.checked = true;
                okespec=true;
            }
        }
    }
    else{
    for (var i=0;i<document.form_cad_produto.elements.length;i++) {
        var x = document.form_cad_produto.elements[i];
        if (x.name == 'checkespec[]') {        
                x.checked = false;
                okespec=false;
            }
        }    
    }
}

function CheckCat() {
    if(!okcat){
      for (var i=0;i<document.form_cad_produto.elements.length;i++) {
        var x = document.form_cad_produto.elements[i];
        if (x.name == 'checktipo[]') {        
                x.checked = true;
                okcat=true;
            }
        }
    }
    else{
    for (var i=0;i<document.form_cad_produto.elements.length;i++) {
        var x = document.form_cad_produto.elements[i];
        if (x.name == 'checktipo[]') {        
                x.checked = false;
                okcat=false;
            }
        }    
    }
}
function CheckSub() {
    if(!oksub){
      for (var i=0;i<document.form_cad_produto.elements.length;i++) {
        var x = document.form_cad_produto.elements[i];
        if (x.name == 'checksub[]') {        
                x.checked = true;
                oksub=true;
            }
        }
    }
    else{
    for (var i=0;i<document.form_cad_produto.elements.length;i++) {
        var x = document.form_cad_produto.elements[i];
        if (x.name == 'checksub[]') {        
                x.checked = false;
                oksub=false;
            }
        }    
    }
}

function hideForm() {
  document.getElementById('DIVFORM').style.display = 'none';
}
function showForm() {
  document.getElementById('DIVFORM').style.display = 'block';
}
function hidep() {
  document.getElementById('DIVp').style.display = 'none';
  document.getElementById('DIVp2').style.display = 'none';
}
function showp() {
  document.getElementById('DIVp').style.display = 'block';
  document.getElementById('DIVp2').style.display = 'block';
}
function hideclass() {
  document.getElementById('DIVclass').style.display = 'none';
}
function showclass() {
  document.getElementById('DIVclass').style.display = 'block';
}


function ExibirCampo(Opcao){
if (Opcao == "9999") {
document.getElementById("divoutro").style.display = "block";
} else {
document.getElementById("divoutro").style.display = "none";
}
}

function ExibirRegiao(Opcao){
if (Opcao == "cidade") {
document.getElementById("divcid").style.display = "block";
document.getElementById("divest").style.display = "none";
} else if (Opcao == "estado"){
document.getElementById("divcid").style.display = "none";
document.getElementById("divest").style.display = "block";
} else {
document.getElementById("divcid").style.display = "none";
document.getElementById("divest").style.display = "none";	
}
}

function FormataCNPJ(Campo, teclapres){

   if(window.event){
    var tecla = teclapres.keyCode;
   }else  tecla = teclapres.which;

   var vr = new String(Campo.value);
   vr = vr.replace(".", "");
   vr = vr.replace(".", "");
   vr = vr.replace("/", "");
   vr = vr.replace("-", "");

   tam = vr.length + 1;

  
   if (tecla != 9 && tecla != 8){
      if (tam > 2 && tam < 6)
         Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
      if (tam >= 6 && tam < 9)
         Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
      if (tam >= 9 && tam < 13)
         Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
      if (tam >= 13 && tam < 15)
         Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
      }
}

function FormataCPF(Campo, teclapres){

   if(window.event){
    var tecla = teclapres.keyCode;
   }else  tecla = teclapres.which;

   var vr = new String(Campo.value);
   vr = vr.replace(".", "");
   vr = vr.replace(".", "");
   vr = vr.replace("-", "");

   tam = vr.length + 1;

  
   if (tecla != 9 && tecla != 8){
      if (tam > 3 && tam < 7)
         Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam);
      if (tam >= 7 && tam < 10)
         Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
      if (tam >= 10 && tam < 14)
         Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
   }
}

function checa_mudar_login(cadastro){
if (cadastro.login.value == ""){
alert("O campo Login está vazio.");
cadastro.login.focus();
return (false);
}
var ver_numero = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
var valor = cadastro.login.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Login deve conter apenas números, letras e sublinhado (_).");
cadastro.login.focus();
return (false);
}
if (cadastro.pass.value == ""){
alert("O campo Senha está vazio.");
cadastro.pass.focus();
return (false);
}
return (true);
}

function checa_mudar_senha(cadastro){
if (cadastro.pass.value == ""){
alert("O campo Senha está vazio.");
cadastro.pass.focus();
return (false);
}
var ver_numero = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
if (cadastro.senha1.value == ""){
alert("O campo Nova Senha está vazio.");
cadastro.senha1.focus();
return (false);
}
if (cadastro.senha1.value.length < 4){
alert("O campo Senha deve ter no mínimo 4 caracteres.")
cadastro.senha1.focus();
return (false);
}
if (cadastro.senha1.value.length > 10){
alert("O campo Senha deve ter no máximo 10 caracteres.")
cadastro.senha1.focus();
return (false);
}

var valor = cadastro.senha1.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Senha deve conter apenas números, letras e sublinhado (_).");
cadastro.senha1.focus();
return (false);
}

if (cadastro.senha2.value == ""){
alert("O campo Confirmação de Senha está vazio.");
cadastro.senha2.focus();
return (false);
}
if (cadastro.senha1.value != cadastro.senha2.value){
alert("A Confirmação de Senha é diferente da senha.");
cadastro.senha2.focus();
return (false);
}
return (true);
}

function checa_checks(cadastro){
var el = document.form_orca.elements;
for(var i = 0; i < el.length; ++i) 
{
	if(el[i].type == "checkbox") 
	{
		var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
		var itemchecked = false;
		for(var j = 0; j < radiogroup.length; ++j) 
		{
			if(radiogroup[j].checked) 
			{
				itemchecked = true;
				break;
			}
		}
		if(!itemchecked) 
		{
			if (el[i].name == "checksub[]")
			{
				alert("Para continuar você deve escolher pelo menos uma categoria");
				if(el[i].focus)
					el[i].focus();
				return false;
			} 
		}
	}
}
return (true);
}

function checa_cks(cadastro){
if (!cadastro.checktermo.checked){
alert("Você deve ler e aceitar os Termos de Uso");
cadastro.checktermo.focus();
return (false);
}
var el = document.form_orca.elements;
for(var i = 0; i < el.length; ++i) 
{
	if(el[i].type == "checkbox") 
	{
		var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
		var itemchecked = false;
		for(var j = 0; j < radiogroup.length; ++j) 
		{
			if(radiogroup[j].checked) 
			{
				itemchecked = true;
				break;
			}
		}
		if(!itemchecked) 
		{
			if (el[i].name == "checksub[]")
			{
				alert("Para continuar você deve escolher pelo menos uma categoria");
				if(el[i].focus)
					el[i].focus();
				return false;
			} 
		}
	}
}
return (true);
}

function checa_termo(cadastro){
if (!cadastro.checktermo.checked){
alert("Você deve ler e aceitar os Termos de Uso");
cadastro.checktermo.focus();
return (false);
}

return (true);
}


/*
Formulário para Pessoas Físicas
*/

function checa_formulario_fisica(cadastro){
if (cadastro.nome.value == ""){
alert("Por favor coloque seu Nome Completo!!!");
cadastro.nome.focus();
return (false);
}
if (cadastro.email.value == ""){
alert("O campo email está vazio!!!");
cadastro.email.focus();
return (false);
}
if (cadastro.email.value.indexOf('@', 0) == -1){
alert("O email é inválido!!!");
cadastro.email.focus();
return (false);
}
if (cadastro.rua.value == ""){
alert("O campo Rua está vazio!!!");
cadastro.rua.focus();
return (false);
}
if (cadastro.num.value == ""){
alert("O campo Número está vazio!!!");
cadastro.num.focus();
return (false);
}
var ver_numero = "1234567890";
var valor = cadastro.num.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo nº deve conter apenas números!!!");
cadastro.num.focus();
return (false);
}

if (cadastro.bairro.value == ""){
alert("O campo Bairro está vazio!!!");
cadastro.bairro.focus();
return (false);
}
if (cadastro.cep.value == ""){
alert("O campo CEP está vazio!!!");
cadastro.cep.focus();
return (false);
}
var ver_numero = "1234567890-";
var valor = cadastro.cep.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo CEP deve conter apenas números e hífem(-)!!!");
cadastro.cep.focus();
return (false);
}

if (cadastro.cidade.value == ""){
alert("O campo Cidade está vazio!!!");
cadastro.cidade.focus();
return (false);
}
if (cadastro.estado.value == ""){
alert("Escolha um Estado!!!");
cadastro.estado.focus();
return (false);
}

if (cadastro.ddd.value == ""){
alert("O campo ddd está vazio!!!");
cadastro.ddd.focus();
return (false);
}
var ver_numero = "1234567890";
var valor = cadastro.ddd.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo ddd deve conter apenas números!!!");
cadastro.ddd.focus();
return (false);
}

if (cadastro.telefone.value == ""){
alert("O campo telefone está vazio!!!");
cadastro.telefone.focus();
return (false);
}
var ver_numero = "1234567890-";
var valor = cadastro.telefone.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo telefone deve conter apenas números e hífem(-)!!!");
cadastro.telefone.focus();
return (false);
}

if (cadastro.cpf.value == ""){
alert("O campo CPF está vazio!!!");
cadastro.cpf.focus();
return (false);
}
var ver_numero = "1234567890.-";
var valor = cadastro.cpf.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo CPF deve conter apenas números!!!");
cadastro.cpf.focus();
return (false);
}

if (cadastro.login_user.value == ""){
alert("O campo Login está vazio!!!");
cadastro.login_user.focus();
return (false);
}
var ver_numero = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
var valor = cadastro.login_user.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Login deve conter apenas números e letras!!!");
cadastro.login_user.focus();
return (false);
}

if (cadastro.senha1.value == ""){
alert("O campo Senha está vazio !!!");
cadastro.senha1.focus();
return (false);
}
if (cadastro.senha1.value.length < 4){
alert("O campo Senha deve ter no mínimo 4 caracteres!!!")
cadastro.senha1.focus();
return (false);
}
if (cadastro.senha1.value.length > 10){
alert("O campo Senha deve ter no máximo 10 caracteres!!!")
cadastro.senha1.focus();
return (false);
}

var valor = cadastro.senha1.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Senha deve conter apenas números e letras!!!");
cadastro.senha1.focus();
return (false);
}

if (cadastro.senha2.value == ""){
alert("O campo Confirmação de Senha está vazio !!!");
cadastro.senha2.focus();
return (false);
}
if (cadastro.senha1.value != cadastro.senha2.value){
alert("A Confirmação de Senha é diferente da senha!!!");
cadastro.senha2.focus();
return (false);
}

var ver_numero = "1234567890";
var valor = cadastro.idade.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Idade deve conter apenas números!!!");
cadastro.idade.focus();
return (false);
}

var ver_numero = "1234567890";
var valor = cadastro.dddfax.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo ddd/Fax deve conter apenas números!!!");
cadastro.dddfax.focus();
return (false);
}

var ver_numero = "1234567890-";
var valor = cadastro.fax.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Fax deve conter apenas números e hífem(-)!!!");
cadastro.fax.focus();
return (false);
}

var ver_numero = "1234567890";
var valor = cadastro.dddcelular.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo ddd/Celular deve conter apenas números!!!");
cadastro.dddcelular.focus();
return (false);
}

var ver_numero = "1234567890-";
var valor = cadastro.celular.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Celular deve conter apenas números e hífem(-)!!!");
cadastro.celular.focus();
return (false);
}
if (!cadastro.checktermo.checked){
alert("Você deve ler e aceitar os Termos de Uso");
cadastro.checktermo.focus();
return (false);
}
return (true);
}


/**********************************************************************************
***********************************************************************************
***********************************************************************************


Formulário para Pessoas Jurídicas


**********************************************************************************
***********************************************************************************
***********************************************************************************/
function checa_formulario_juridica(cadastro){
if (cadastro.empresa.value == ""){
alert("Por favor, informe o nome da Empresa!!!");
cadastro.empresa.focus();
return (false);
}
if (cadastro.nome.value == ""){
alert("Por favor coloque seu Nome para futuros contatos!!!");
cadastro.nome.focus();
return (false);
}
if (cadastro.email.value == ""){
alert("O campo email está vazio!!!");
cadastro.email.focus();
return (false);
}
if (cadastro.email.value.indexOf('@', 0) == -1){
alert("O email é inválido!!!");
cadastro.email.focus();
return (false);
}
if (cadastro.rua.value == ""){
alert("O campo Rua está vazio!!!");
cadastro.rua.focus();
return (false);
}
if (cadastro.num.value == ""){
alert("O campo Número está vazio!!!");
cadastro.num.focus();
return (false);
}
var ver_numero = "1234567890";
var valor = cadastro.num.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo nº deve conter apenas números!!!");
cadastro.num.focus();
return (false);
}

if (cadastro.bairro.value == ""){
alert("O campo Bairro está vazio!!!");
cadastro.bairro.focus();
return (false);
}
if (cadastro.cep.value == ""){
alert("O campo CEP está vazio!!!");
cadastro.cep.focus();
return (false);
}
var ver_numero = "1234567890-";
var valor = cadastro.cep.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo CEP deve conter apenas números e hífem(-)!!!");
cadastro.cep.focus();
return (false);
}

if (cadastro.cidade.value == ""){
alert("O campo Cidade está vazio!!!");
cadastro.cidade.focus();
return (false);
}
if (cadastro.estado.value == ""){
alert("Escolha um Estado!!!");
cadastro.estado.focus();
return (false);
}

if (cadastro.ddd.value == ""){
alert("O campo ddd está vazio!!!");
cadastro.ddd.focus();
return (false);
}
var ver_numero = "1234567890";
var valor = cadastro.ddd.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo ddd deve conter apenas números!!!");
cadastro.ddd.focus();
return (false);
}

if (cadastro.telefone.value == ""){
alert("O campo telefone está vazio!!!");
cadastro.telefone.focus();
return (false);
}
var ver_numero = "1234567890-";
var valor = cadastro.telefone.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo telefone deve conter apenas números e hífem(-)!!!");
cadastro.telefone.focus();
return (false);
}

if (cadastro.cnpj.value == ""){
alert("O campo CNPJ está vazio!!!");
cadastro.cnpj.focus();
return (false);
}
var ver_numero = "1234567890./-";
var valor = cadastro.cnpj.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo CNPJ deve conter apenas números!!!");
cadastro.cnpj.focus();
return (false);
}

if (cadastro.login_user.value == ""){
alert("O campo Login está vazio!!!");
cadastro.login_user.focus();
return (false);
}
var ver_numero = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
var valor = cadastro.login_user.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Login deve conter apenas números e letras!!!");
cadastro.login_user.focus();
return (false);
}

if (cadastro.senha1.value == ""){
alert("O campo Senha está vazio !!!");
cadastro.senha1.focus();
return (false);
}
if (cadastro.senha1.value.length < 4){
alert("O campo Senha deve ter no mínimo 4 caracteres!!!")
cadastro.senha1.focus();
return (false);
}
if (cadastro.senha1.value.length > 10){
alert("O campo Senha deve ter no máximo 10 caracteres!!!")
cadastro.senha1.focus();
return (false);
}

var valor = cadastro.senha1.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Senha deve conter apenas números e letras!!!");
cadastro.senha1.focus();
return (false);
}

if (cadastro.senha2.value == ""){
alert("O campo Confirmação de Senha está vazio !!!");
cadastro.senha2.focus();
return (false);
}
if (cadastro.senha1.value != cadastro.senha2.value){
alert("A Confirmação de Senha é diferente da senha!!!");
cadastro.senha2.focus();
return (false);
}
if (!cadastro.checktermo.checked){
alert("Você deve ler e aceitar os Termos de Uso");
cadastro.checktermo.focus();
return (false);
}
return (true);
}



/**********************************************************************************
***********************************************************************************
***********************************************************************************


Formulário para Médicos(as)


**********************************************************************************
***********************************************************************************
***********************************************************************************/
function checa_formulario_medico(cadastro){
if (cadastro.nome.value == ""){
alert("Por favor coloque seu Nome Completo!!!");
cadastro.nome.focus();
return (false);
}
if (cadastro.email.value == ""){
alert("O campo email está vazio!!!");
cadastro.email.focus();
return (false);
}
if (cadastro.email.value.indexOf('@', 0) == -1){
alert("O email é inválido!!!");
cadastro.email.focus();
return (false);
}
if (cadastro.rua.value == ""){
alert("O campo Rua está vazio!!!");
cadastro.rua.focus();
return (false);
}
if (cadastro.num.value == ""){
alert("O campo Número está vazio!!!");
cadastro.num.focus();
return (false);
}
var ver_numero = "1234567890";
var valor = cadastro.num.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo nº deve conter apenas números!!!");
cadastro.num.focus();
return (false);
}

if (cadastro.bairro.value == ""){
alert("O campo Bairro está vazio!!!");
cadastro.bairro.focus();
return (false);
}
if (cadastro.cep.value == ""){
alert("O campo CEP está vazio!!!");
cadastro.cep.focus();
return (false);
}
var ver_numero = "1234567890-";
var valor = cadastro.cep.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo CEP deve conter apenas números e hífem(-)!!!");
cadastro.cep.focus();
return (false);
}

if (cadastro.cidade.value == ""){
alert("O campo Cidade está vazio!!!");
cadastro.cidade.focus();
return (false);
}
if (cadastro.estado.value == ""){
alert("Escolha um Estado!!!");
cadastro.estado.focus();
return (false);
}

if (cadastro.ddd.value == ""){
alert("O campo ddd está vazio!!!");
cadastro.ddd.focus();
return (false);
}
var ver_numero = "1234567890";
var valor = cadastro.ddd.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo ddd deve conter apenas números!!!");
cadastro.ddd.focus();
return (false);
}

if (cadastro.telefone.value == ""){
alert("O campo telefone está vazio!!!");
cadastro.telefone.focus();
return (false);
}
var ver_numero = "1234567890-";
var valor = cadastro.telefone.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo telefone deve conter apenas números e hífem(-)!!!");
cadastro.telefone.focus();
return (false);
}

if (cadastro.cpf.value == ""){
alert("O campo CPF está vazio!!!");
cadastro.cpf.focus();
return (false);
}
var ver_numero = "1234567890.-";
var valor = cadastro.cpf.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo CPF deve conter apenas números!!!");
cadastro.cpf.focus();
return (false);
}

if (cadastro.crm.value == ""){
alert("O campo CRM está vazio!!!");
cadastro.crm.focus();
return (false);
}
var ver_numero = "1234567890";
var valor = cadastro.crm.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo CRM deve conter apenas números!!!");
cadastro.crm.focus();
return (false);
}

if (cadastro.login_user.value == ""){
alert("O campo Login está vazio!!!");
cadastro.login_user.focus();
return (false);
}
var ver_numero = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
var valor = cadastro.login_user.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Login deve conter apenas números e letras!!!");
cadastro.login_user.focus();
return (false);
}

if (cadastro.senha1.value == ""){
alert("O campo Senha está vazio !!!");
cadastro.senha1.focus();
return (false);
}
if (cadastro.senha1.value.length < 4){
alert("O campo Senha deve ter no mínimo 4 caracteres!!!")
cadastro.senha1.focus();
return (false);
}
if (cadastro.senha1.value.length > 10){
alert("O campo Senha eeve ver no máximo 10 caracteres!!!")
cadastro.senha1.focus();
return (false);
}

var valor = cadastro.senha1.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Senha deve conter apenas números e letras!!!");
cadastro.senha1.focus();
return (false);
}

if (cadastro.senha2.value == ""){
alert("O campo Confirmação de Senha está vazio !!!");
cadastro.senha2.focus();
return (false);
}
if (cadastro.senha1.value != cadastro.senha2.value){
alert("A Confirmação de Senha é diferente da senha!!!");
cadastro.senha2.focus();
return (false);
}

var ver_numero = "1234567890";
var valor = cadastro.idade.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Idade deve conter apenas números!!!");
cadastro.idade.focus();
return (false);
}

var ver_numero = "1234567890";
var valor = cadastro.dddfax.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo ddd/Fax deve conter apenas números!!!");
cadastro.dddfax.focus();
return (false);
}

var ver_numero = "1234567890-";
var valor = cadastro.fax.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Fax deve conter apenas números e hífem(-)!!!");
cadastro.fax.focus();
return (false);
}

var ver_numero = "1234567890";
var valor = cadastro.dddcelular.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo ddd/Celular deve conter apenas números!!!");
cadastro.dddcelular.focus();
return (false);
}

var ver_numero = "1234567890-";
var valor = cadastro.celular.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Celular deve conter apenas números e hífem(-)!!!");
cadastro.celular.focus();
return (false);
}
if (!cadastro.checktermo.checked){
alert("Você deve ler e aceitar os Termos de Uso");
cadastro.checktermo.focus();
return (false);
}
return (true);
}


/**********************************************************************************
***********************************************************************************
***********************************************************************************


Formulário Cadastro de Produto


**********************************************************************************
***********************************************************************************
***********************************************************************************/

function checa_formulario_produto(cadastro){
	
if (document.getElementById("r_n_prod1").checked){
	if (cadastro.list_nome_prod.value == ""){
	alert("Escolha um Nome de Produto.");
	cadastro.list_nome_prod.focus();
	return (false);
	}
} else if (document.getElementById("r_n_prod2").checked){
	if (cadastro.txt_nome_prod.value == ""){
	alert("Digite um Nome de Produto.");
	cadastro.txt_nome_prod.focus();
	return (false);
	}
}

if (cadastro.modelo.value == ""){
alert("O campo Modelo e Marca do Produto está vazio.");
cadastro.modelo.focus();
return (false);
}

if (cadastro.fabricante.value == ""){
alert("O campo Fabricante está vazio.");
cadastro.fabricante.focus();
return (false);
}

if (document.getElementById("novo").checked){

} else if (document.getElementById("usado").checked){
	if (cadastro.ano_fab.value == ""){
	alert("O campo Ano de Fabricação está vazio.");
	cadastro.ano_fab.focus();
	return (false);
	}


	if (cadastro.pintura.value == ""){
	alert("Escolha uma opção de Pintura.");
	cadastro.pintura.focus();
	return (false);
	}
	
	if (cadastro.estado_funcionamento.value == ""){
	alert("Escolha uma opção de Estado de Funcionamento.");
	cadastro.estado_funcionamento.focus();
	return (false);
	}
	
	if (cadastro.garantia.value == ""){
	alert("Escolha uma opção de Garantia.");
	cadastro.garantia.focus();
	return (false);
	}
} else {
alert("Escolha uma opção de Conservação.");
cadastro.novo.focus();
return (false);
}

var el = document.form_cad_produto.elements;
for(var i = 0; i < el.length; ++i) 
{
	if(el[i].type == "checkbox") 
	{
		var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
		var itemchecked = false;
		for(var j = 0; j < radiogroup.length; ++j) 
		{
			if(radiogroup[j].checked) 
			{
				itemchecked = true;
				break;
			}
		}
		if(!itemchecked) 
		{
			if (el[i].name == "checkespec[]")
			{
				alert("Escolha pelo menos uma Especialidade");
				if(el[i].focus)
					el[i].focus();
				return false;
			} 
			else if (el[i].name == "checktipo[]") 
			{
				alert("Escolha pelo menos uma Categoria");
				if(el[i].focus)
					el[i].focus();
				return false;
			}
		}
	}
}

if (cadastro.preco.value == ""){
alert("O campo Preço está vazio.");
cadastro.preco.focus();
return (false);
}

var ver_numero = "1234567890,";
var valor = cadastro.preco.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Preco deve conter apenas números e vírgula(,).");
cadastro.preco.focus();
return (false);
}
var valor = cadastro.promocao.value;
var invalido = true;
for (i = 0;  i < valor.length;  i++){
ch = valor.charAt(i);
for (j = 0;  j < ver_numero.length;  j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O campo Promoção deve conter apenas números e vírgula(,).");
cadastro.preco.focus();
return (false);
}
if (document.getElementById("r_parc1").checked){

} else if (document.getElementById("r_parc2").checked){
	if (cadastro.s_parc.value == ""){
	alert("Escolha um Número de Parcelas.");
	cadastro.s_parc.focus();
	return (false);
	}
} else {
alert("Escolha uma opção de Parcelamento");
cadastro.r_parc1.focus();
return (false);
}

if (cadastro.prazo.value == ""){
alert("O campo Prazo de Entrega está vazio.");
cadastro.prazo.focus();
return (false);
}

if (cadastro.cidade_prod.value == ""){
alert("O campo 'cidade de' em Local de Entrega está vazio.");
cadastro.cidade_prod.focus();
return (false);
}

if (cadastro.estado.value == ""){
alert("Escolha um Estado.");
cadastro.estado.focus();
return (false);
}

if (cadastro.local_entrega.value == ""){
alert("Escolha um Local de Entrega.");
cadastro.local_entrega.focus();
return (false);
}

if (document.getElementById("cond_1").checked){

} else if (document.getElementById("cond_2").checked){

} else if (document.getElementById("cond_3").checked){

} else {
alert("Escolha uma Condição de Entrega");
cadastro.cond_1.focus();
return (false);
}

if (!cadastro.checktermo.checked){
alert("Você deve ler e aceitar os Termos de Uso");
cadastro.checktermo.focus();
return (false);
}

return (true);
}