function indique(codigo){
abrindopopFoto=window.open("modulo_popups/indique_produto.php?cod_produto=" + codigo,"Votar","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=600,top=10,left=250,screenX=20,screenY=20");
return false;
}

function confpgto(){
abrindopopFoto=window.open("modulo_popups/confirma_pagamento.php","Votar","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=500,height=430,top=10,left=250,screenX=20,screenY=20");
return false;
}

function rastro(){
x = event.x
y = event.y
PROC.style.posLeft = x + 10
PROC.style.posTop = y + 15
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function Mudar() {
	if (document.tipo.tipo_pessoa[0].checked){
		FISICA.style.display="block";
		JURIDICA.style.display="none";
		INTER.style.display="none";
	}
	if (document.tipo.tipo_pessoa[1].checked){
		FISICA.style.display="none";
		JURIDICA.style.display="block";
		INTER.style.display="none";
	}	
	if (document.tipo.tipo_pessoa[2].checked){
		FISICA.style.display="none";
		JURIDICA.style.display="none";
		INTER.style.display="block";
	}	
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ValidaPGTO(theForm)
{

if (Trim(theForm.nome.value) == "")
 {
  alert("Por favor, digite o seu nome")
  theForm.nome.focus();
    return (false);
  }

if (Trim(theForm.email_pagamento.value) == "") {
  	alert("Por favor, digite o seu e-mail"); 	
	theForm.email_pagamento.focus();
  	return (false);
  }   

if (Trim(theForm.numero_pedido.value) == "") {
  	alert("Por favor, digite o numero pedido"); 	
	theForm.numero_pedido.focus();
  	return (false);
  }  

if (Trim(theForm.tipo_pagamento.value) == "")
 {
  alert("Por favor, selecione o tipo do pagamento")
  theForm.tipo_pagamento.focus();
    return (false);
  } 
  return (true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ValidaFrete(theForm){
if (Trim(theForm.entrega.value) == ""){
  alert("Por favor, informe a forma de entrega!")
  theForm.entrega.focus();
    return (false);
  }

  return (true);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function VALIDA_AREARESTRITACPF(theForm){
if (Trim(theForm.cpf.value) == ""){
  alert("Por favor, digite o seu CPF")
  theForm.cpf.focus();
    return (false);
  }

if (Trim(theForm.txtCEP.value) == ""){
  	alert("Por favor, digite o seu CEP"); 	
	theForm.txtCEP.focus();
  	return (false);
  }   
  return (true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ValidaCONTATO(theForm)
{
nform =theForm
if (Trim(theForm.nome.value) == "")
 {
  alert("Por favor, digite o seu nome")
  theForm.nome.focus();
    return (false);
  }

if (Trim(theForm.telefone_ddd.value) == "") {
  	alert("Por favor, digite o seu telefone"); 	
	theForm.telefone_ddd.focus();
  	return (false);
  }   

if (Trim(theForm.telefone.value) == "") {
  	alert("Por favor, digite o seu telefone"); 	
	theForm.telefone.focus();
  	return (false);
  }  

if (Trim(theForm.email_cliente.value) == "")
 {
  alert("Por favor,  digite o seu e-mail")
  theForm.email_cliente.focus();
    return (false);
  } 
   
if (Trim(theForm.mensagem.value) == "")
 {
  alert("Por favor, digite a sua mensagem")
  theForm.mensagem.focus();
    return (false);
  }   
  if (nform.email_cliente.value == "") {
		alert("Informe seu e-mail.");
		nform.email_cliente.focus();
		nform.email_cliente.select();
		return false;
	} else {
		prim = nform.email_cliente.value.indexOf("@")
		if(prim < 2) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf("@",prim + 1) != -1) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf(".") < 1) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf(" ") != -1) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf("zipmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf("hotmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf(".@") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf("@.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf(".com.br.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf("/") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf("[") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf("]") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf("(") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf(")") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
		if(nform.email_cliente.value.indexOf("..") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email_cliente.focus();
			nform.email_cliente.select();
			return false;
		}
	}

  return (true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function VALIDA_AREARESTRITACNPJ(theForm){



if (Trim(theForm.txtCEP.value) == ""){
  	alert("Por favor, digite o seu CEP"); 	
	theForm.txtCEP.focus();
  	return (false);
  }   
  return (true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ValidaENDERECO(theForm){

if (Trim(theForm.nome_cliente.value) == ""){
  alert("Por favor, digite o seu Nome")
  theForm.nome_cliente.focus();
    return (false);
  }
if (Trim(theForm.cep.value) == ""){
  	alert("Por favor, digite o seu CEP"); 	
	theForm.cep.focus();
  	return (false);
  }   
if (Trim(theForm.endereco.value) == ""){
  	alert("Por favor, digite o seu Endereço"); 	
	theForm.endereco.focus();
  	return (false);
  }   
if (Trim(theForm.numero.value) == ""){
  	alert("Por favor, digite o Nº da residência"); 	
	theForm.numero.focus();
  	return (false);
  }   
if (Trim(theForm.bairro.value) == ""){
  	alert("Por favor, digite o seu Bairro"); 	
	theForm.bairro.focus();
  	return (false);
  }   
if (Trim(theForm.cidade.value) == ""){
  	alert("Por favor, digite a sua cidade"); 	
	theForm.cidade.focus();
  	return (false);
  }   
if (Trim(theForm.estado.value) == ""){
  	alert("Por favor, escolha seu estado"); 	
	theForm.estado.focus();
  	return (false);
  }   
if (Trim(theForm.numero_telefone.value) == ""){
  	alert("Por favor, digite o número do seu telefone"); 	
	theForm.numero_telefone.focus();
  	return (false);
  }   
if (Trim(theForm.ponto.value) == ""){
  	alert("Por favor, digite Ponto de Referência próximo a sua residência"); 	
	theForm.ponto.focus();
  	return (false);
  }   
 
return (true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ValidaCADASTRO_CPF(theForm){

if (Trim(theForm.nome_cliente.value) == ""){
  alert("Por favor, digite o seu Nome")
  theForm.nome_cliente.focus();
    return (false);
  }
if (checaCPF(theForm.cpf.value) == false){
  	alert("Por favor, informe o CPF corretamente!"); 	
	theForm.cpf.focus();
  	return (false);
  }   
if (Trim(theForm.rg.value) == ""){
  	alert("Por favor, digite o seu RG"); 	
	theForm.rg.focus();
  	return (false);
  }   
if (Trim(theForm.dia_nasc.value) == ""){
  	alert("Por favor, digite o Dia de seu nascimento"); 	
	theForm.dia_nasc.focus();
  	return (false);
}
if (Trim(theForm.mes_nasc.value) == ""){
  	alert("Por favor, digite o Mês de seu nascimento"); 	
	theForm.mes_nasc.focus();
  	return (false);
  }   
if (Trim(theForm.ano_nasc.value) == ""){
  	alert("Por favor, digite o Ano de seu nascimento"); 	
	theForm.ano_nasc.focus();
  	return (false);
  }   
if (Trim(theForm.sexo.value) == ""){
  	alert("Por favor, escolha o Sexo"); 	
	theForm.sexo.focus();
  	return (false);
  }   
if (Trim(theForm.cep.value) == ""){
  	alert("Por favor, digite o seu CEP"); 	
	theForm.cep.focus();
  	return (false);
  }   
if (Trim(theForm.endereco.value) == ""){
  	alert("Por favor, digite o seu Endereço"); 	
	theForm.endereco.focus();
  	return (false);
  }   
if (Trim(theForm.numero.value) == ""){
  	alert("Por favor, digite o Nº da residência"); 	
	theForm.numero.focus();
  	return (false);
  }   
if (Trim(theForm.bairro.value) == ""){
  	alert("Por favor, digite o seu Bairro"); 	
	theForm.bairro.focus();
  	return (false);
  }   
if (Trim(theForm.cidade.value) == ""){
  	alert("Por favor, digite a sua cidade"); 	
	theForm.cidade.focus();
  	return (false);
  }   
if (Trim(theForm.estado.value) == ""){
  	alert("Por favor, escolha seu estado"); 	
	theForm.estado.focus();
  	return (false);
  }   
if (Trim(theForm.numero_telefone.value) == ""){
  	alert("Por favor, digite o número do seu telefone"); 	
	theForm.numero_telefone.focus();
  	return (false);
  }   
if (Trim(theForm.ponto.value) == ""){
  	alert("Por favor, digite Ponto de Referência próximo a sua residência"); 	
	theForm.ponto.focus();
  	return (false);
  }   
if (Trim(theForm.email.value) == ""){
  	alert("Por favor, digite seu e-mail para autenticação da área restrita"); 	
	theForm.email.focus();
  	return (false);
  }   
if (Trim(theForm.senha_cliente.value) == ""){
  	alert("Por favor, digite uma senha"); 	
	theForm.senha_cliente.focus();
  	return (false);
  } 
  
  
  
return (true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ValidaCADASTRO_CNPJ(theForm){

if (Trim(theForm.nome_cliente.value) == ""){
  alert("Por favor, digite o seu Nome")
  theForm.nome_cliente.focus();
    return (false);
  }
 
if (Trim(theForm.razao.value) == ""){
  	alert("Por favor, digite sua Razão Social"); 	
	theForm.razao.focus();
  	return (false);
  }   
if (Trim(theForm.nome_fantasia.value) == ""){
  	alert("Por favor, digite o Nome Fantasia"); 	
	theForm.nome_fantasia.focus();
  	return (false);
}
if (Trim(theForm.inscricao_estadual.value) == ""){
  	alert("Por favor, digite sua Inscrição Estadual"); 	
	theForm.inscricao_estadual.focus();
  	return (false);
  }   
if (Trim(theForm.inscricao_municipal.value) == ""){
  	alert("Por favor, digite sua Inscrição Municipal"); 	
	theForm.inscricao_municipal.focus();
  	return (false);
  }   
if (Trim(theForm.sexo.value) == ""){
  	alert("Por favor, escolha o Sexo"); 	
	theForm.sexo.focus();
  	return (false);
  }   
if (Trim(theForm.cep.value) == ""){
  	alert("Por favor, digite o seu CEP"); 	
	theForm.cep.focus();
  	return (false);
  }   
if (Trim(theForm.endereco.value) == ""){
  	alert("Por favor, digite o seu Endereço"); 	
	theForm.endereco.focus();
  	return (false);
  }   
if (Trim(theForm.numero.value) == ""){
  	alert("Por favor, digite o Nº da residência"); 	
	theForm.numero.focus();
  	return (false);
  }   
if (Trim(theForm.bairro.value) == ""){
  	alert("Por favor, digite o seu Bairro"); 	
	theForm.bairro.focus();
  	return (false);
  }   
if (Trim(theForm.cidade.value) == ""){
  	alert("Por favor, digite a sua cidade"); 	
	theForm.cidade.focus();
  	return (false);
  }   
if (Trim(theForm.estado.value) == ""){
  	alert("Por favor, escolha seu estado"); 	
	theForm.estado.focus();
  	return (false);
  }   
if (Trim(theForm.numero_telefone.value) == ""){
  	alert("Por favor, digite o número do seu telefone"); 	
	theForm.numero_telefone.focus();
  	return (false);
  }   
if (Trim(theForm.ponto.value) == ""){
  	alert("Por favor, digite Ponto de Referência próximo a sua residência/empresa"); 	
	theForm.ponto.focus();
  	return (false);
  }   
if (Trim(theForm.email.value) == ""){
  	alert("Por favor, digite seu e-mail para autenticação da área restrita"); 	
	theForm.email.focus();
  	return (false);
  }   
if (Trim(theForm.senha_cliente.value) == ""){
  	alert("Por favor, digite uma senha"); 	
	theForm.senha_cliente.focus();
  	return (false);
  } 

return (true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function EnviaForm(){
	jan=displayWindow('','FORMULARIO','540','150',''); //opções do popup
//	document.form2.submit();
}

function EnviaForm2(){
	jan2=displayWindow('','FORMULARIO2','540','150',''); //opções do popup
//	document.form3.submit();
}

function displayWindow(theURL,winName,width,height,features) { //Esta função aqui é para o pop-up abrir no centro, está funcionando legal
    var window_width = width;
    var window_height = height;
    var newfeatures= features;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',features=' + newfeatures + '');
    newWindow.focus();
}

function Trim(s){
  // Remove leading spaces and carriage returns
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns
  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}


var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}



  function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
      var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

      if(document.all) { // Internet Explorer
        nTecla = evtKeyPress.keyCode; }
      else if(document.layers) { // Nestcape
        nTecla = evtKeyPress.which;
      }

      sValue = objForm[strField].value;

      // Limpa todos os caracteres de formatação que
      // já estiverem no campo.
      sValue = sValue.toString().replace( "-", "" );
      sValue = sValue.toString().replace( "-", "" );
      sValue = sValue.toString().replace( ".", "" );
      sValue = sValue.toString().replace( ".", "" );
      sValue = sValue.toString().replace( "/", "" );
      sValue = sValue.toString().replace( "/", "" );
      sValue = sValue.toString().replace( "(", "" );
      sValue = sValue.toString().replace( "(", "" );
      sValue = sValue.toString().replace( ")", "" );
      sValue = sValue.toString().replace( ")", "" );
      sValue = sValue.toString().replace( " ", "" );
      sValue = sValue.toString().replace( " ", "" );
      fldLen = sValue.length;
      mskLen = sMask.length;

      i = 0;
      nCount = 0;
      sCod = "";
      mskLen = fldLen;

      while (i <= mskLen) {
        bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
        bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

        if (bolMask) {
          sCod += sMask.charAt(i);
          mskLen++; }
        else {
          sCod += sValue.charAt(nCount);
          nCount++;
        }

        i++;
      }

      objForm[strField].value = sCod;

      if (nTecla != 8) { // backspace
        if (sMask.charAt(i-1) == "9") { // apenas números...
          return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
        else { // qualquer caracter...
          return true;
        } }
      else {
        return true;
      }
    }
	
////////////////////////////////////////////////////////////////////////////////////////////////////
 function checaCPF (CPF) {
	if (CPF.length != 11 || CPF == "000.000.000-00" || CPF == "111.111.111-11" ||
		CPF == "222.222.222-22" ||	CPF == "333.333.333-33" || CPF == "444.444.444-44" ||
		CPF == "555.555.555-55" || CPF == "666.666.666-66" || CPF == "777.777.777-77" ||
		CPF == "888.888.888-88" || CPF == "999-999-999-99")
		return false;
	soma = 0;
	for (i=0; i < 9; i ++)
		soma += parseInt(CPF.charAt(i)) * (10 - i);
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		resto = 0;
	if (resto != parseInt(CPF.charAt(9)))
		return false;
	soma = 0;
	for (i = 0; i < 10; i ++)
		soma += parseInt(CPF.charAt(i)) * (11 - i);
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		resto = 0;
	if (resto != parseInt(CPF.charAt(10)))
		return false;
	return true;
 }
 

////////////////////////////////////////////////////////////////////////////////////////////////////
 function checaCNPJ(cnpj)
      {
      var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
      digitos_iguais = 1;
      if (cnpj.length < 14)
            return false;
      for (i = 0; i < cnpj.length - 1; i++)
            if (cnpj.charAt(i) != cnpj.charAt(i + 1))
                  {
                  digitos_iguais = 0;
                  break;
                  }
      if (!digitos_iguais)
            {
            tamanho = cnpj.length - 2
            numeros = cnpj.substring(0,tamanho);
            digitos = cnpj.substring(tamanho);
            soma = 0;
            pos = tamanho - 7;
            for (i = tamanho; i >= 1; i--)
                  {
                  soma += numeros.charAt(tamanho - i) * pos--;
                  if (pos < 2)
                        pos = 9;
                  }
            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
            if (resultado != digitos.charAt(0))
                  return false;
            tamanho = tamanho + 1;
            numeros = cnpj.substring(0,tamanho);
            soma = 0;
            pos = tamanho - 7;
            for (i = tamanho; i >= 1; i--)
                  {
                  soma += numeros.charAt(tamanho - i) * pos--;
                  if (pos < 2)
                        pos = 9;
                  }
            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
            if (resultado != digitos.charAt(1))
                  return false;
            return true;
            }
      else
            return false;
      } 
	  
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
