<!--
//VALIDA NÚMERO DO CPF
function validaCPF(formulario) {
var CPF = formulario.cpf.value; // Recebe o valor digitado no campo

// Aqui começa a checagem do CPF
var POSICAO, I, SOMA, DV, DV_INFORMADO;
var DIGITO = new Array(10);
DV_INFORMADO = CPF.substr(9, 2); // Retira os dois últimos dígitos do número informado

// Desemembra o número do CPF na array DIGITO
for (I=0; I<=8; I++) 
{
  DIGITO[I] = CPF.substr( I, 1);
}

// Calcula o valor do 10º dígito da verificação
POSICAO = 10;
SOMA = 0;
for (I=0; I<=8; I++) {
      SOMA = SOMA + DIGITO[I] * POSICAO;
      POSICAO = POSICAO - 1;
   }
DIGITO[9] = SOMA % 11;
   if (DIGITO[9] < 2) {
        DIGITO[9] = 0;
}
   else{
       DIGITO[9] = 11 - DIGITO[9];
}

// Calcula o valor do 11º dígito da verificação
POSICAO = 11;
SOMA = 0;
   for (I=0; I<=9; I++) {
      SOMA = SOMA + DIGITO[I] * POSICAO;
      POSICAO = POSICAO - 1;
   }
DIGITO[10] = SOMA % 11;
   if (DIGITO[10] < 2) {
        DIGITO[10] = 0;
   }
   else {
        DIGITO[10] = 11 - DIGITO[10];
   }

// Verifica se os valores dos dígitos verificadores conferem
DV = DIGITO[9] * 10 + DIGITO[10];
   if (DV != DV_INFORMADO) 
   {
      alert('O CPF digitado é inválido!');
      formulario.CPF.value = '';
      formulario.CPF.focus();
      return false;
   } 
}

//VALIDA CNPJ
function validaCNPJ(cnpj) {

  var i = 0;
  var l = 0;
  var strNum = "";
  var strMul = "6543298765432";
  var character = "";
  var iValido = 1;
  var iSoma = 0;
  var strNum_base = "";
  var iLenNum_base = 0;
  var iLenMul = 0;
  var iSoma = 0;
  var strNum_base = 0;
  var iLenNum_base = 0;

  if (cnpj == "")
        alert('Preencha o campo CNPJ.');

  l = cnpj.length;
  for (i = 0; i < l; i++) {
        caracter = cnpj.substring(i,i+1)
        if ((caracter >= '0') && (caracter <= '9'))
           strNum = strNum + caracter;
  };

  if(strNum.length != 14)
        alert('CNPJ deve conter 14 caracteres.');

  strNum_base = strNum.substring(0,12);
  iLenNum_base = strNum_base.length - 1;
  iLenMul = strMul.length - 1;
  for(i = 0;i < 12; i++)
        iSoma = iSoma +
                        parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) *
                        parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10);

  iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11);
  if(iSoma == 11 || iSoma == 10)
        iSoma = 0;

  strNum_base = strNum_base + iSoma;
  iSoma = 0;
  iLenNum_base = strNum_base.length - 1
  for(i = 0; i < 13; i++)
        iSoma = iSoma +
                        parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) *
                        parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10)

  iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11);
  if(iSoma == 11 || iSoma == 10)
        iSoma = 0;
  strNum_base = strNum_base + iSoma;
  if(strNum != strNum_base)
        alert('CNPJ inválido.');

  return (true);
}

//ABRE JANELA DO NAVEGADOR --> VÁRIAS PÁGINAS UTILIZAM
function abreJanela(theURL,winName,features) 
{  
  window.open(theURL,winName,features);
}  

//ENVIA SENHA PARA USUÁRIO --> conteudo/identificacao.php
function enviaSenha()
{
	if (document.formIndex.emailEnvioSenha.value == "")
	{
		alert('E-mail deve ser informado!');
		document.formIndex.emailEnvioSenha.focus();
	}
	else
	{
		document.formIndex.action = "recuperar_senha.php";
		document.formIndex.submit();
	}
}

//LOGA USUÁRIO NA ÁREA ADMINISTRATIVA DO SITE
function loginCliente()
{
	if (document.formIndex.emailLogin.value == "")
	{
		alert('E-mail deve ser informado!');
		document.formIndex.emailLogin.focus();
	}
	else if (document.formIndex.senhaLogin.value == "")
	{
		alert('Senha deve ser informada!');
		document.formIndex.senhaLogin.focus();
	}
	else
	{
		document.formIndex.action = "index.php?secao=login&acao=login";
		document.formIndex.submit();
	}
}

//LOGA USUÁRIO E REDIRECIONA PARA A PÁGINA DE FINALIZAÇÃO DE PEDIDO
function finalizaPedido()
{
	if (document.formIndex.emailLogin.value == "")
	{
		alert('E-mail deve ser informado!');
		document.formIndex.emailLogin.focus();
	}
	else if (document.formIndex.senhaLogin.value == "")
	{
		alert('Senha deve ser informada!');
		document.formIndex.senhaLogin.focus();
	}
	else
	{
		document.formIndex.action = "index.php?secao=login&acao=login&from=carrinho";
		document.formIndex.submit();
	}
}

//INSERE ITEM NO CARRINHO DE COMPRAS --> conteudo/detalhes_produto.php
function comprar(idProduto)
{
	document.formIndex.action = "carrinho.php?p="+idProduto;
	document.formIndex.submit();
}

//ALTERA EMAIL DO USUÁRIO --> conteudo/userEditEmail.php
function alteraEmail()
{
	if (document.formIndex.senhaAlteraEmail.value == ""){
	alert('Senha é obrigatória.');
	document.formIndex.senhaAlteraEmail.focus();
	}
	else if (document.formIndex.emailAtualAlteraEmail.value == ""){
		alert('E-mail atual é obrigatório.');
		document.formIndex.emailAtualAlteraEmail.focus();
	}
	else if (document.formIndex.emailNovoAlteraEmail.value == ""){
		alert('Novo e-mail é obrigatório.');
		document.formIndex.emailNovoAlteraEmail.focus();
	}
	else if (document.formIndex.email2NovoAlteraEmail.value == ""){
		alert('Confirme o novo e-mail.');
		document.formIndex.email2NovoAlteraEmail.focus();
	}
	else if (document.formIndex.emailNovoAlteraEmail.value != document.formIndex.email2NovoAlteraEmail.value){
		alert('E-mails digitados não são iguais.');
		document.formIndex.emailNovoAlteraEmail.focus();
	}
	else{
		document.formIndex.acao.value = "alteraEmail";
		document.formIndex.submit();
	}
	
}

//ALTERA SENHA DO USUÁRIO --> conteudo/userEditPass.php
function alteraSenha()
{
	if (document.formIndex.senhaAtualAlteraSenha.value == ""){
	alert('Senha atual é obrigatória.');
	document.formIndex.senhaAtualAlteraSenha.focus();
	}
	else if (document.formIndex.senhaNovaAlteraSenha.value == ""){
		alert('Nova senha é obrigatória.');
		document.formIndex.senhaNovaAlteraSenha.focus();
	}
	else if (document.formIndex.senha2NovaAlteraSenha.value == ""){
		alert('Confirme a nova senha.');
		document.formIndex.senha2NovaAlteraSenha.focus();
	}
	else if (document.formIndex.senhaNovaAlteraSenha.value != document.formIndex.senha2NovaAlteraSenha.value){
		alert('Senhas digitadas não são iguais.');
		document.formIndex.senhaNovaAlteraSenha.focus();
	}
	else{
		document.formIndex.acao.value = "alteraSenha";
		document.formIndex.submit();
	}
	
}

//ALTERA DADOS DO USUÁRIO --> conteudo/userEditData.php
function alteraDados(tipoCliente)
{
	document.formIndex.acao.value = "alteraDados";
	document.formIndex.tipocadastro.value = tipoCliente;
	document.formIndex.submit();
}	


//ALTERA ENDEREÇO DO USUÁRIO --> conteudo/userNewAdress.php
function alteraEndereco()
{
	document.formIndex.acao.value = "alteraDados";
	document.formIndex.submit();
}


//INSERE NOVO ENDEREÇO DO USUÁRIO --> conteudo/userNewAdress.php
function insereEndereco()
{
	document.formIndex.acao.value = "insereDados";
	document.formIndex.submit();
}


//BUSCA POR COTAÇAO --> conteudo/userViewOrder.php
function buscaCotacao()
{
	document.formIndex.acao.value = "buscaCotacao";
	document.formIndex.target = "_self";
	document.formIndex.action = "index.php?secao=userViewOrder";
	document.formIndex.submit();
}

//INSERE OBSERVAÇÃO NA COTAÇÃO --> conteudo/userViewOrder.php
function inserirObservacao(pedido)
{
	document.formIndex.acao.value = "inserirObservacao";
	document.formIndex.action = "index.php?secao=userViewOrder&order="+pedido;
	document.formIndex.target = "_self";
	document.formIndex.submit();
}

//PAGINAÇÃO DE PEDIDOS --> conteudo/userViewOrder.php
function paginacao(pagina, final)
{
	document.formIndex.acao.value = "buscaCotacao";
	document.formIndex.action = "index.php?secao=userViewOrder&pagina="+pagina+"&final="+final;
	document.formIndex.target = "_self";
	document.formIndex.submit();
}

//IMPRIMI 2 VIA BOLETO
function impressaoBoleto()
{
	document.formIndex.action = "https://comercio.locaweb.com.br/comercio.comp";
	document.formIndex.target = "_blank";
	document.formIndex.submit();
}

//ABRE JANELA DE REENVIO DE DADOS DE CARTÃO
function enviaCartao()
{
	document.formIndex.action = "lib/OFFLINE/enviaForm.php";
	document.formIndex.target = "_blank";
	document.formIndex.submit();
}

//ALTERA ENDEREÇO DE ENTREGA --> pagamento.php
function alteraEnderecoEntrega(idEndereco)
{
	document.formIndex.acao.value = "alteraEndereco";
	document.formIndex.action = "pagamento.php?address="+idEndereco;
	document.formIndex.submit();
}


//BUSCA DO PRODUTO
function buscarProduto()
{
	if (document.formIndex.palavrachave.value == "")
	{
		alert('Você deve digitar uma palavra!');
		document.formIndex.palavrachave.focus();
	}
	else
	{
		var palavraChave = document.formIndex.palavrachave.value;
		document.formIndex.action = "index.php?secao=busca&tag="+palavraChave;
		document.formIndex.submit();
	}
}

//BUSCA PRODUTO AO CLICAR ENTER
function verificaTecla(evt)
{	
	//VERIFICA NAVEGADOR
	if (window.event) //IE
	{
		tecla = evt.keyCode;
		//VERIFICA TECLA
		if(tecla == 13)
		{
			buscarProduto();
		}
	}
	else//FF
	{
		tecla = evt.which;
		if(tecla == 13)
		{
			buscarProduto();
		}
	}
		
}
//-->