function mostraObsDoc(id)
	{
	
	display = eval("document.getElementById('obs1_"+id+"').style.display");
	if(display=="none")
		{
		eval("document.getElementById('obs1_"+id+"').style.display = ''");
		eval("document.getElementById('obs2_"+id+"').style.display = ''");
		eval("document.getElementById('obs3_"+id+"').style.display = ''");
		eval("document.getElementById('maisDoc_"+id+"').src = 'images/menos.jpg'");
		}
	else
		{
		eval("document.getElementById('obs1_"+id+"').style.display = 'none'");
		eval("document.getElementById('obs2_"+id+"').style.display = 'none'");
		eval("document.getElementById('obs3_"+id+"').style.display = 'none'");
		eval("document.getElementById('maisDoc_"+id+"').src = 'images/mais.jpg'");
		
		}
	}

function realizaRespostaSac(id)
	{
	if(validateForm('mensagem_sac:1:Resposta')==true) 
	    {  	
		document.getElementById("acaoSAC").value = "responderSAC";
		document.getElementById("idSAC").value = id;
		document.formSAC.submit();	   
		}	 
	}
function realizaSac(){
	
	if(validateForm('assunto:1:Assunto,mensagem_sac:1:Descrição Detalhada')==true) 
	    {  	
		document.getElementById("acaoSAC").value = "abrirSAC";		
		document.formSAC.submit();	   
		}	 
	}

function buscaChamados(tipo,radio)
	  {
	  document.getElementById("iframe_aux").src = "login_clientes/area_cliente/sac/monta_sac.php?tipo_pesquisa="+tipo+"&radio="+radio;		  
	  }	  
	  
	  
function buscaDocs(tipo,radio)
	  {
	  document.getElementById("iframe_aux").src = "login_clientes/area_cliente/docs/monta_docs.php?tipo_pesquisa="+tipo+"&radio="+radio;		  
	  }	  	  
	  

function carregaMunicipioEntrega(){	
	
		document.getElementById("iframe_aux").src = "login_clientes/forms/municipios_montaCombo.php?id_uf="+document.formEnderecoEntrega.id_estado.value;		  
	
	}
	
function carregaMunicipio(){

		document.getElementById("iframe_aux").src = "login_clientes/forms/municipios_montaCombo.php?id_uf="+document.formCadastra.id_estado.value;
	
	}
function buscaPedidos(){
	
	document.getElementById("iframe_aux").src = "login_clientes/area_cliente/pedidos/meus_pedidos.php";		  
	
	}


function utilizaCupom(tipo,id_anuncio,pesquisa,id){	
	var answer = confirm ("Confirmar utilização do cupom ?");
		
	if (answer){
		
		if(tipo=="dobro")
			{
			document.getElementById("iframe_aux").src = "login_clientes/area_cliente/cupons_anunciante/meus_anuncios_anunciantes.php?verCompradores="+id_anuncio+"&pesquisaCupom="+pesquisa+"&utilizaCupomDobro="+id;		  			
			}
		else
			{
			document.getElementById("iframe_aux").src = "login_clientes/area_cliente/cupons_anunciante/meus_anuncios_anunciantes.php?verCompradores="+id_anuncio+"&pesquisaCupom="+pesquisa+"&utilizaCupom="+id;		  
			}
		
		
	}else {
		if(tipo=="dobro")
		eval("document.formAnuncios.cupom_utilizado_dobro_"+id+".checked = false");	   
		else
		eval("document.formAnuncios.cupom_utilizado_"+id+".checked = false");	   
		
	}
	
	
	}
	

function pesquisaAnunciosA(pesquisa){
		
//		eval("abreLogin('meusanuncios_"+pesquisa+"_"+document.formAnuncios.pesquisa_cupom.value+"','N')");

		
		document.getElementById("iframe_aux").src = "login_clientes/area_cliente/cupons_anunciante/cupons_antigos.php?pesquisaCupom="+document.getElementById("pesquisa_cupom").value;		  
		
		}
	
function pesquisaAnuncios(pesquisa){
		
//		eval("abreLogin('meusanuncios_"+pesquisa+"_"+document.formAnuncios.pesquisa_cupom.value+"','N')");

		document.getElementById("iframe_aux").src = "login_clientes/area_cliente/cupons_anunciante/meus_anuncios_anunciantes.php?verCompradores="+pesquisa+"&pesquisaCupom="+document.formAnuncios.pesquisa_cupom.value;		  
		
		}



function buscaCompradores(id,radio){
	document.getElementById("iframe_aux").src = "login_clientes/area_cliente/cupons_anunciante/meus_anuncios_anunciantes.php?verCompradores="+id+"&radio="+radio;		  
	}
	
function buscaCuponsAnunciante(tipo,radio)
	  {
	  document.getElementById("iframe_aux").src = "login_clientes/area_cliente/cupons_anunciante/meus_anuncios_resumo.php?tipo_pesquisa="+tipo+"&radio="+radio;		  
	  }
	  
function buscaCuponsAnuncianteA(tipo,radio)
	  {
	  document.getElementById("iframe_aux").src = "login_clientes/area_cliente/cupons_anunciante/cupons_antigos.php?tipo_pesquisa="+tipo+"&radio="+radio;		  
	  }	  
function buscaArremates(tipo,radio)
	  {		
	  document.getElementById("iframe_aux").src = "login_clientes/area_cliente/meus_arremates/monta_meus_arremates.php?tipo_pesquisa="+tipo+"&radio="+radio;		  
	  }	  
function buscaCupons(tipo,radio)
	  {
	  document.getElementById("iframe_aux").src = "login_clientes/area_cliente/meus_cupons/monta_meus_cupons.php?tipo_pesquisa="+tipo+"&radio="+radio;		  
	  }
	  

	  
	  
	  
	  
function mostraAbaAreaCliente(aba,path){
	
	  if(document.getElementById("td_meusdados")){
 	  document.getElementById("meusdados").style.display = 'none';	  
	  eval("document.getElementById('td_meusdados').style.backgroundImage=\"url('"+path+"login_clientes/images/menu_esq_notsel.jpg')\""); 
	  }
	  
	  if(document.getElementById("td_sac")){
	  document.getElementById("sac").style.display = 'none';	  
	  eval("document.getElementById('td_sac').style.backgroundImage=\"url('"+path+"login_clientes/images/menu_meio_notsel.jpg')\""); 
	  }
	  
	  if(document.getElementById("td_docs")){
	  document.getElementById("docs").style.display = 'none';	  
	  eval("document.getElementById('td_docs').style.backgroundImage=\"url('"+path+"login_clientes/images/menu_meio_notsel.jpg')\""); 
	  }
	  
	  if(document.getElementById("td_pedidos")){
	  document.getElementById("pedidos").style.display = 'none';	  
	  eval("document.getElementById('td_pedidos').style.backgroundImage=\"url('"+path+"login_clientes/images/menu_meio_notsel.jpg')\""); 
	  }
	  
	  if(document.getElementById("td_cupons")){
	  document.getElementById("cupons").style.display = 'none';	  	  
	  eval("document.getElementById('td_cupons').style.backgroundImage=\"url('"+path+"login_clientes/images/menu_meio_notsel.jpg')\""); 
	  
	  }
	  
	  if(document.getElementById("td_arremates")){
	  document.getElementById("arremates").style.display = 'none';	  	  
	  eval("document.getElementById('td_arremates').style.backgroundImage=\"url('"+path+"login_clientes/images/menu_meio_notsel.jpg')\""); 
	  
	  }
	  
	  
	  if(document.getElementById("td_presentes")){
	  document.getElementById("presentes").style.display = 'none';	  
	  eval("document.getElementById('td_presentes').style.backgroundImage=\"url('"+path+"login_clientes/images/menu_meio_notsel.jpg')\""); 
	  }
	  
	  
	  if(document.getElementById("td_anuncios")){  
	  document.getElementById("anuncios").style.display = 'none';	  
	  eval("document.getElementById('td_anuncios').style.backgroundImage=\"url('"+path+"login_clientes/images/menu_meio_notsel.jpg')\""); 
	  }
	  
	  if(document.getElementById("td_anunciosA")){  
	  document.getElementById("anunciosA").style.display = 'none';	  
	  eval("document.getElementById('td_anunciosA').style.backgroundImage=\"url('"+path+"login_clientes/images/menu_meio_notsel.jpg')\""); 
	  }
	  
	  
	  if(aba!="meusdados")
	  eval("document.getElementById('td_"+aba+"').style.backgroundImage=\"url('"+path+"login_clientes/images/menu_meio_sel.jpg')\""); 
	  else
	  eval("document.getElementById('td_"+aba+"').style.backgroundImage=\"url("+path+"'login_clientes/images/menu_esq_sel.jpg')\""); 
	  
	  
	  
	  
	  document.getElementById(aba).style.display = '';
	  
	  /*document.getElementById('td_interatividade').style.backgroundImage="url('editor/images/menu_meio_notsel.jpg')"; 
	  document.getElementById('td_aparencia').style.backgroundImage="url('editor/images/menu_esq_notsel.jpg')";
	  document.getElementById('td_ajuda').style.backgroundImage="url('editor/images/menu_meio_notsel.jpg')"; */
	   
	
}


function abreLogin(origem, caminho_pedido)
	{	 
	
	if(document.getElementById("TrListagemBanner")) document.getElementById("TrListagemBanner").style.display = "none";
	
	document.getElementById("iframe_aux").src = "login_clientes/ifr_area_cliente.php?origem="+origem+"&var_caminho_pedido="+caminho_pedido;	
	}

function trim(str) { return str.replace(/^\s+|\s+$/g,""); }
function realizaLogin()
	{
	 
	 
	 if(trim(document.formFinalizar.emaill.value)=="") document.formFinalizar.emaill.value = "";
	 if(trim(document.formFinalizar.senhaAcesso.value)=="") document.formFinalizar.senhaAcesso.value = "";

	  
	 if(validateForm('emaill:1:E-mail,senhaAcesso:1:Senha')==true) 
	    {  	
		document.getElementById("acaoLg").value = "login";		
		document.formFinalizar.submit();	   
		}	 
	 }
	 
function logoffCliente()
	{
	
		if(document.getElementById("acaoLg")) {
	
		document.getElementById("acaoLg").value = "logoff";
		document.formFinalizar.submit();	
		
		}else {
		
		document.getElementById("iframe_aux").src = "login_clientes/acoes/ifr_login_logoff_acao.php?acaoLg=logoff";		
			
			}		
	}


function retornaPagina(){	
		
		document.getElementById('TrDetalheProduto1').style.display = 'none';
		document.getElementById('TrDetalheProduto2').style.display = 'none';
		document.getElementById('TrListagem').style.display = '';

	} 












function abreAtualizaEmail()
 {
 if(document.getElementById('trMudaEmail0').style.display=='none')
 	{
	 document.getElementById('trMudaEmail0').style.display = '';
	 document.getElementById('trMudaEmail1').style.display = 'none';
	 document.getElementById('trMudaEmail').style.display = 'none'; 
	}
 else
 	{
	 document.getElementById('trMudaEmail0').style.display = 'none';
	 document.getElementById('trMudaEmail1').style.display = '';
	 document.getElementById('trMudaEmail').style.display = ''; 
	}
 }
function atualizaEmail()
 {
	 
 
 if(document.getElementById('emailNovo2').value!=document.getElementById('emailNovo').value) {alert("O novo e-mail e a confirmação não conferem.")}else{
 
 if(validateForm('emailAntigo:1:Seu e-mail anitgo,emailNovo:1:Seu novo e-mail,emailNovo2:1:Repita o novo e-mail,senhaTrocaEmail:1:Senha')){
	
	document.getElementById("iframe_aux").src = "paginas_lojavirtual/finaliza_compra/ifr_altera_email.php?email="+document.getElementById('emailAntigo').value+"&novoEmail="+document.getElementById('emailNovo').value+"&senhaTrocaEmail="+document.getElementById('senhaTrocaEmail').value;		
	 
 	}
 }
 }

function abreCadastro(){
	
	
	if(validateForm('nome_antesCadastro:1:Nome,email_antesCadastro:1:E-mail')){
	
	document.getElementById('tr_cadastroCliente').style.display = '';
	document.getElementById('tr_cadastroCliente_antesCadastro').style.display = 'none';
	
	document.getElementById('email').value   = document.getElementById('email_antesCadastro').value;
	
	if(document.getElementById('id_tipo_cadastro').value=="fisica")
	document.getElementById('nome').value = document.getElementById('nome_antesCadastro').value;
	else
	document.getElementById('contato').value = document.getElementById('nome_antesCadastro').value;
	
	//document.getElementById('cep').value   = document.getElementById('nome_antesCadastro').value;
	
	
	//buscaCep();
	}
	
	
	}

function buscaCep(){
	 document.getElementById("iframe_aux").src = "login_clientes/acoes/ifr_pega_endereco_peloCEP.php?tipo=cad_cliente&cep="+document.getElementById('cep').value;
	}
function buscaCepEntrega(){
	 document.getElementById("iframe_aux").src = "login_clientes/acoes/ifr_pega_endereco_peloCEP.php?tipo=entrega&cep="+document.getElementById('cep').value;
	}



function ValidarCPF(Objcpf){
	
	
	var cpf = Objcpf; 
    
	cpf = cpf.toString().replace( ".", "" ); 
	cpf = cpf.toString().replace( ".", "" ); 
	cpf = cpf.toString().replace( "/", "" ); 
	cpf = cpf.toString().replace( "-", "" ); 
	
if (vercpf(cpf)) 
{return true;}else 
{errors="1";if (errors) 
document.retorno = (errors == '');}}
function vercpf (cpf) 
{if (cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999")
return false;
add = 0;
for (i=0; i < 9; i ++)
add += parseInt(cpf.charAt(i)) * (10 - i);
rev = 11 - (add % 11);
if (rev == 10 || rev == 11)
rev = 0;
if (rev != parseInt(cpf.charAt(9)))
return false;
add = 0;
for (i = 0; i < 10; i ++)
add += parseInt(cpf.charAt(i)) * (11 - i);
rev = 11 - (add % 11);
if (rev == 10 || rev == 11)
rev = 0;
if (rev != parseInt(cpf.charAt(10)))
return false;
return true;

}






function ValidarCNPJ(cnpj)
      {
	  cnpj = cnpj.toString().replace( ".", "" ); 
	  cnpj = cnpj.toString().replace( ".", "" ); 
	  cnpj = cnpj.toString().replace( "/", "" ); 
	  cnpj = cnpj.toString().replace( "-", "" ); 	  
		  
      var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
      digitos_iguais = 1;
      if (cnpj.length < 14 && cnpj.length < 15)
            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 tipoCadastro()
	{
	
	if(document.formCadastra.id_tipo_cadastro.value=="fisica")
	  {
	   document.getElementById('tipoFisica1').style.display = '';
	   document.getElementById('tipoFisica2').style.display = '';
	   document.getElementById('tipoFisica3').style.display = '';
	   document.getElementById('tipoFisica4').style.display = '';
	   
	   document.getElementById('tipoJuridica1').style.display = 'none';
	   document.getElementById('tipoJuridica2').style.display = 'none';
	   document.getElementById('tipoJuridica3').style.display = 'none';
	   document.getElementById('tipoJuridica4').style.display = 'none';
	   
	   document.getElementById('tr_nomeFantasia1').style.display = 'none';
	   document.getElementById('tr_nomeFantasia2').style.display = 'none';
	   
	   document.getElementById('tr_contato1').style.display = 'none';
	   document.getElementById('tr_contato2').style.display = 'none';
	   
	   document.getElementById('cpf').style.display = '';
	   document.getElementById('cnpj').style.display = 'none';
	   
	   
	  }
	else
	  {
	   document.getElementById('tipoFisica1').style.display = 'none';
	   document.getElementById('tipoFisica2').style.display = 'none';
	   document.getElementById('tipoFisica3').style.display = 'none';
	   document.getElementById('tipoFisica4').style.display = 'none';
	   
	   document.getElementById('tipoJuridica1').style.display = '';
	   document.getElementById('tipoJuridica2').style.display = '';
	   document.getElementById('tipoJuridica3').style.display = '';
	   document.getElementById('tipoJuridica4').style.display = '';
	   
	   document.getElementById('tr_nomeFantasia1').style.display = '';
	   document.getElementById('tr_nomeFantasia2').style.display = '';
	   
	   document.getElementById('tr_contato1').style.display = '';
	   document.getElementById('tr_contato2').style.display = '';
	   
	   document.getElementById('cpf').style.display = 'none';
	   document.getElementById('cnpj').style.display = '';
	   

	   
	   
	   
	  }
	}

function realizaCadastro(){
	
	if(document.formCadastra.id_tipo_cadastro.value=="fisica")
	  {
	  if(ValidarCPF(document.formCadastra.cpf.value)) 
	    {
	    if(validateForm('nome:1:Nome,ddd:1:DDD,fone:1:Fone,nascimento:4:Nascimento,email:1:E-mail,key:1:Senha,key2:1:Repita Senha,enderecoc:1:Endereco,cep:1:CEP,numero:1:Numero,id_cidade:1:Cidade,id_estado:1:Estado'))
		  { 
		  document.formCadastra.submit(); 		  
		  }
		}
	   else {alert("O CPF informado é Inválido."); document.formCadastra.cpf.disabled = false; }
	  }
	else
	  {
	  
	  if(ValidarCNPJ(document.formCadastra.cnpj.value)) 
	    {
	    if(validateForm('nome:1:Nome,ddd:1:DDD,fone:1:Fone,nascimento:4:Nascimento,email:1:E-mail,key:1:Senha,key2:1:Repita Senha,enderecoc:1:Endereco,cep:1:CEP,numero:1:Numero,id_cidade:1:Cidade,id_estado:1:Estado'))
		  { 
		  document.formCadastra.submit(); 		  
		  }
		}
	   else {alert("O CNPJ informado é Inválido."); }
	  
	  
	  }
	  
	
	
	}




function enviaSenha(){
	 if(validateForm('emaill:1:E-mail')==true) 
	    {  	
		document.getElementById("acaoLg").value = "senha";
		document.formFinalizar.submit();	   
		}	 
}	 



