<!-- Preload Images -->
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
<!-- /Preload Images -->


function showResultSucessoIndique() {

$('#resultSucesso').slideToggle('slow');
	$(this).toggleClass('show');
}


function showComoFacil() {

$('#saiba-como-indicar').slideToggle('slow');
	$(this).toggleClass('show');
}


function vazaContato() {
	$('#div-outras-cidades').slideToggle('medium');
	$(this).toggleClass('show');
}

<!-- Result -->
function vazaSucesso() {
$('#resultSucesso').slideToggle('slow');
	$(this).toggleClass('show');
}
function vazaErro() {
$('#resultErro').slideToggle('slow');
	$(this).toggleClass('show');
}
function vazaBemVindo() {
$('#resultBem').slideToggle('slow');
	$(this).toggleClass('show');
}

function closeGooglemaps() {
$('#googleMaps').slideToggle('slow');
	$(this).toggleClass('show');
}

function closeGallery() {
$('#gallery').slideToggle('slow');
	$(this).toggleClass('show');
}

function showCidades() {
$('#div-outras-cidades').slideToggle('slow');
	$(this).toggleClass('show');
}

function exibe_dd_parceiro() {

$('#preview-dd').slideToggle('slow');
	$(this).toggleClass('show');
}

function exibe_dd_parceiro2() {

$('#preview-dd2').slideToggle('slow');
	$(this).toggleClass('show');
}

function abre(caminho,largura,altura,rolagem){
	w = largura;
	h = altura;
	rol = rolagem;
	largura = screen.width;
	altura = screen.height;
	XX = (largura-w)/2;
	YY = (altura-h)/2;
	janela = window.open(caminho,nm_janela, 'width='+w+', height='+h+', left='+XX+', top='+YY+'menubar=no, toolbar=no,status=no,scrollbars='+rol+',');
	janela.focus();
}


/*Mascaras -----------------------------------------------------------------------------------*/
    function Mascara(o,f){
        v_obj=o
        v_fun=f
        setTimeout("execmascara()",1)
    }
    
    /*Função que Executa os objetos*/
    function execmascara(){
        v_obj.value=v_fun(v_obj.value)
    }
    
    /*Função que Determina as expressões regulares dos objetos*/
    function leech(v){
        v=v.replace(/o/gi,"0")
        v=v.replace(/i/gi,"1")
        v=v.replace(/z/gi,"2")
        v=v.replace(/e/gi,"3")
        v=v.replace(/a/gi,"4")
        v=v.replace(/s/gi,"5")
        v=v.replace(/t/gi,"7")
        return v
    }
    
    /*Função que permite apenas numeros*/
    function Integer(v){
        return v.replace(/\D/g,"")
    }
    
    /*Função que padroniza telefone (11) 4184-1241*/
    function Telefone(v){
        v=v.replace(/\D/g,"")                 
        v=v.replace(/^(\d\d)(\d)/g,"($1) $2") 
        v=v.replace(/(\d{4})(\d)/,"$1-$2")    
        return v
    }
    
    /*Função que padroniza telefone (11) 41841241*/
    function TelefoneCall(v){
        v=v.replace(/\D/g,"")                 
        v=v.replace(/^(\d\d)(\d)/g,"($1) $2")    
        return v
    }
    
    /*Função que padroniza CPF*/
    function Cpf(v){
        v=v.replace(/\D/g,"")                    
        v=v.replace(/(\d{3})(\d)/,"$1.$2")       
        v=v.replace(/(\d{3})(\d)/,"$1.$2")       
                                                 
        v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") 
        return v
    }
    
    /*Função que padroniza CEP*/
    function Cep(v){
		v=v.replace(/\D/g,"")
        v=v.replace(/D/g,"")                
        v=v.replace(/^(\d{5})(\d)/,"$1$2") 
        return v
    }
    
    /*Função que padroniza CNPJ*/
    function Cnpj(v){
        v=v.replace(/\D/g,"")                   
        v=v.replace(/^(\d{2})(\d)/,"$1.$2")     
        v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") 
        v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           
        v=v.replace(/(\d{4})(\d)/,"$1-$2")              
        return v
    }
    
    /*Função que permite apenas numeros Romanos*/
    function Romanos(v){
        v=v.toUpperCase()             
        v=v.replace(/[^IVXLCDM]/g,"") 
        
        while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
            v=v.replace(/.$/,"")
        return v
    }
    
    /*Função que padroniza o Site*/
    function Site(v){
        v=v.replace(/^http:\/\/?/,"")
        dominio=v
        caminho=""
        if(v.indexOf("/")>-1)
            dominio=v.split("/")[0]
            caminho=v.replace(/[^\/]*/,"")
            dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
            caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"")
            caminho=caminho.replace(/([\?&])=/,"$1")
        if(caminho!="")dominio=dominio.replace(/\.+$/,"")
            v="http://"+dominio+caminho
        return v
    }

    /*Função que padroniza DATA*/
    function Data(v){
        v=v.replace(/\D/g,"") 
        v=v.replace(/(\d{2})(\d)/,"$1/$2") 
        v=v.replace(/(\d{2})(\d)/,"$1/$2") 
        return v
    }
    
    /*Função que padroniza HORA*/
    function Hora(v){
        v=v.replace(/\D/g,"") 
        v=v.replace(/(\d{2})(\d)/,"$1:$2")  
        return v
    }
    
    /*Função que padroniza valor monétario*/
    function Valor(v){
        v=v.replace(/\D/g,"") //Remove tudo o que não é dígito
        v=v.replace(/^([0-9]{3}\.?){3}-[0-9]{2}$/,"$1.$2");
        //v=v.replace(/(\d{3})(\d)/g,"$1,$2")
        v=v.replace(/(\d)(\d{2})$/,"$1,$2") //Coloca ponto antes dos 2 últimos digitos
        return v
    }
    
    /*Função que padroniza Area*/
    function Area(v){
        v=v.replace(/\D/g,"") 
        v=v.replace(/(\d)(\d{2})$/,"$1.$2") 
        return v
        
    }
	
/* Compartilha Oferta - Janela */
$( document ).ready( function() {  
 $("a[rel='pop-compartilha']").click(function () {  
	 var caracteristicas = "height=530,width=680,left="+(screen.availWidth-700)/2+",top="+(screen.availHeight-400)/2+",status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no"; //Abre e centraliza na tela
	 nueva=window.open(this.href, 'Popup', caracteristicas);  
	 return false;  
});  
}); 

/* Visualizar Cupons */
$( document ).ready( function() {  
 $("a[rel='pop-up']").click(function () {  
	 var caracteristicas = "height=530,width=540,left="+(screen.availWidth-700)/2+",top="+(screen.availHeight-500)/2+",status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes"; //Abre e centraliza na tela
	 nueva=window.open(this.href, 'Popup', caracteristicas);  
	 return false;  
});  
});  

/* Listar Cupons */
function mudarStatus(status,idCadastro){
	var divResposta = document.getElementById('recebe'); /* Pega o Div pelo ID */
	var ajax = openajax(); /* Chama a Função que Instancia o AJAX */
	ajax.open("GET","area-usuario/carrega-cupons.php?statusTransacao="+status+"&idCadastro="+idCadastro+"",true);
	ajax.onreadystatechange = function()/* ajax.onreadystatechange = O que ele fara de acordo com o tempo de execuação*/{
		if (ajax.readyState < 4)/* ajax.readystate = Estado que se encontra a Requisição*/{
			divResposta.innerHTML = "<span style='margin:100px 0 0; display:block;'><center>Carregando Informações. Aguarde!<br><img src='imgs/decorativo/ajax-loader.gif' width='220' height='19' /></center></span>";
		}
		if (ajax.readyState == 4){
			if (ajax.status == 200)/* Estado de Carregamento*/{
				divResposta.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.send(null);
}
/* botoes Cupons */
function carrega01(){
		document.getElementById('01').className = 'ativo';
		document.getElementById('02').className = '';
		document.getElementById('03').className = '';
		document.getElementById('04').className = '';
		document.getElementById('05').className = '';
		document.getElementById('06').className = '';
}
function carrega02(){
		document.getElementById('01').className = '';
		document.getElementById('02').className = 'ativo';
		document.getElementById('03').className = '';
		document.getElementById('04').className = '';
		document.getElementById('05').className = '';
		document.getElementById('06').className = '';
}
function carrega03(){
		document.getElementById('01').className = '';
		document.getElementById('02').className = '';
		document.getElementById('03').className = 'ativo';
		document.getElementById('04').className = '';
		document.getElementById('05').className = '';
		document.getElementById('06').className = '';
}
function carrega04(){
		document.getElementById('01').className = '';
		document.getElementById('02').className = '';
		document.getElementById('03').className = '';
		document.getElementById('04').className = 'ativo';
		document.getElementById('05').className = '';
		document.getElementById('06').className = '';
}
function carrega05(){
		document.getElementById('01').className = '';
		document.getElementById('02').className = '';
		document.getElementById('03').className = '';
		document.getElementById('04').className = '';
		document.getElementById('05').className = 'ativo';
		document.getElementById('06').className = '';
}
function carrega06(){
		document.getElementById('01').className = '';
		document.getElementById('02').className = '';
		document.getElementById('03').className = '';
		document.getElementById('04').className = '';
		document.getElementById('05').className = '';
		document.getElementById('06').className = 'ativo';
}

/* Balão Dúvida Cancelados */
function showCanceladosDuvida() {
$('#balao-cancelados-duvida').toggleClass('show');
}

/* Menu Outras Cidades */
function showOutrasCidades() {
	if(document.getElementById('menu-list-cidade').className == 'exibe'){
		document.getElementById('menu-list-cidade').className = '';
		document.getElementById('conteudo-cidade-escolhida').className = '';
		document.getElementById('btn-muda-cidade').className = '';		
	}else{
		document.getElementById('menu-list-cidade').className = 'exibe'
		document.getElementById('conteudo-cidade-escolhida').className = 'cidade-escolhida-exibe';
		document.getElementById('btn-muda-cidade').className = 'btn-muda-cidade-exibe';
	}
}


function mudaCidade() {
	$('#conteudo-cidade-escolhida span.localidade strong').html('Carregando...');
		document.getElementById('menu-list-cidade').className = '';
		document.getElementById('btn-muda-cidade').className = '';			
}

$(document).ready(function(){
	// Box Fechado
	$('#box-login-topo-fechado .logon a')
	.click(function(){
		$(this).fadeOut(0);
		$('#box-login-topo-fechado span.logon, #box-login-topo-fechado span.separador-login, #box-login-topo-fechado span.cadastrar').fadeOut(0);		
		$('#box-login-topo-aberto').slideDown(1000);
		$('#box-login-topo-fechado')
			.animate({ 
				marginTop:"+=150px"
			}, 1000 ); //antigo +=130px
		$('#box-login-topo-aberto-conteudo').fadeIn(500);
		$('#box-login-topo-fechado span.fechar, #box-login-topo-fechado span.fechar a').fadeIn(500);
	})//fim

	// Box Aberto
	$('#box-login-topo-fechado .fechar a')
	.click(function(){
		$(this).fadeOut(0);
		$('#box-login-topo-fechado span.separador-login, #box-login-topo-fechado span.cadastrar').fadeIn(0);		
		$('#box-login-topo-fechado span.logon a, #box-login-topo-fechado span.logon').fadeIn(0);
		$('#box-login-topo-aberto').slideUp(1000);
		$('#box-login-topo-fechado')
			.animate({ 
				marginTop:"-=150px"
			}, 1000 ); //antigo +=130px
		$('#box-login-topo-aberto-conteudo').fadeOut(500);
	})//fim	
});

