
// FUNÇÕES PARA DIMINUIR OU AUMENTAR O TAMANHO DA FONTE DO CONTEÚDO DO TEXTO
var tamanhoFonte = 16;
var tamanhoLinha = tamanhoFonte + 10;

function diminuirFonte(){
    
    console.log("%c INICIANDO FUNÇÃO PARA DIMINUIR TAMANHO DA FONTE","background:#D62261;color:#fff;");
    
    tamanhoFonte = tamanhoFonte - 2;
    if(tamanhoFonte==0){
    	tamanhoFonte = 2;
    }
    tamanhoLinha = tamanhoFonte + 10;

    $(".conteudo article p").css("font-size",tamanhoFonte+"px");
    $(".conteudo article ul").css("font-size",tamanhoFonte+"px");
    $(".conteudo article ul li").css("font-size",tamanhoFonte+"px");
    $(".conteudo article ol").css("font-size",tamanhoFonte+"px");
    $(".conteudo article blockquote").css("font-size",tamanhoFonte+"px");

    $(".conteudo article p").css("line-height",tamanhoLinha+"px");
    $(".conteudo article ul").css("line-height",tamanhoLinha+"px");
    $(".conteudo article ul li").css("line-height",tamanhoLinha+"px");
    $(".conteudo article ol").css("line-height",tamanhoLinha+"px");
    $(".conteudo article blockquote").css("line-height",tamanhoLinha+"px");

}


function aumentarFonte(){

	console.log("%c INICIANDO FUNÇÃO PARA AUMENTAR TAMANHO DA FONTE","background:#D62261;color:#fff;");

	tamanhoFonte = tamanhoFonte + 2;
    if(tamanhoFonte==60){
    	tamanhoFonte = 58;
    }
    tamanhoLinha = tamanhoFonte + 10;

    $(".conteudo article p").css("font-size",tamanhoFonte+"px");
    $(".conteudo article ul").css("font-size",tamanhoFonte+"px");
    $(".conteudo article ul li").css("font-size",tamanhoFonte+"px");
    $(".conteudo article ol").css("font-size",tamanhoFonte+"px");
    $(".conteudo article blockquote").css("font-size",tamanhoFonte+"px");

    $(".conteudo article p").css("line-height",tamanhoLinha+"px");
    $(".conteudo article ul").css("line-height",tamanhoLinha+"px");
    $(".conteudo article ul li").css("line-height",tamanhoLinha+"px");
    $(".conteudo article ol").css("line-height",tamanhoLinha+"px");
    $(".conteudo article blockquote").css("line-height",tamanhoLinha+"px");

}


// PROCESSAR ACTIONS VARIAÇÃO PRODUTO
function activeVariationProduto(idVariacao,precoVariacao,imgVariacao){

    // ATUALIZAR O ID DA VARIACAO
    $(".btn-compra-produto").attr("href",homeUrlDefault+"/?add-to-cart="+idVariacao);

    // ATUALIZAR O PREÇO DO PRODUTO
    $(".preco-final-produto").html(`<span>R$</span> ${precoVariacao}`);

    // ATUALIZAR A IMAGEM DO PRODUTO
    if(imgVariacao!="" && imgVariacao!=null){
        $("#imagemPrincipalProduto").attr("src",imgVariacao);
    }

}


function abrirFecharMenuMobile(){

	if(jQuery("section.side-menu-mobile").hasClass("aberto")){
		jQuery("section.side-menu-mobile").removeClass("aberto");
	}else{
		jQuery("section.side-menu-mobile").addClass("aberto");

	}

}

function mudarValoresProdutoBolao(){

	var idProduto    = jQuery("#qtdProduto").attr("id-produto");
	var precoProduto = jQuery("#qtdProduto").attr("preco-produto");
	var qtdProduto   = jQuery("#qtdProduto").val();

	var precoAtualizado = qtdProduto * precoProduto;

	jQuery("#precoProduto").html(`R$${precoAtualizado.toFixed(2)}`);
	jQuery("#formProdutoBolao").attr("src",`${homeUrlDefault}/?add-to-cart=${idProduto}&quantity=${qtdProduto}`)

}

$( document ).ready(function() {


                           var superBanner = $('#superBanner').owlCarousel({
                                    loop:true,
                                    margin:0,
                                    items: 1,
                                    autoplay: true,
                                    center: true,
                                    smartSpeed:1450,
                                    speed: 5000,
                                    autoplayHoverPause:true,
                                    navText: [
                                        '<img src="'+homeUrlDefault+'/wp-content/plugins/plugin-tema-rifa/templates/front-end/images/left.svg" alt="Página anterior">',
                                        '<img src="'+homeUrlDefault+'/wp-content/plugins/plugin-tema-rifa/templates/front-end/images/right.svg" alt="Próximo Página">'
                                    ], 
                                    navContainer: '.custom-nav-loop1',
                                                                         
                            });
}); 




function quaisSaoMeusNumeros(userEmailD){

    if (userEmailD) {

        var produto = 0;

            var email   = userEmailD;
            var celular = '';

            if(email=="" && celular==""){

                    var erro = jQuery.confirm({
                            title: '',
                            type: 'red',
                            content: `
                                <p>
                                    Você precisa informar o e-mail ou o celular cadastrado para realizar uma consulta;
                                </p>
                            `,
                            buttons: {
                                heyThere: {
                                    text: 'Ok, entendi.', 
                                    action: function () {
                                        erro.close();
                                    }
                                }
                            }
                    });

                    return;

            }

            var carregando = jQuery.confirm({
                    title: '',
                    content: `
                    <div class="carregando-auth-checkout">
                        <img src="${homeUrlRifa}/wp-content/plugins/plugin-extensao-numeros-aleatorios/images/loading-load.gif" alt="" style="margin-left:auto;margin-right:auto;">
                        <p>
                            Carregando...
                        </p>
                    </div>
                    `,
                    buttons: {
                        heyThere: {
                            text: 'Cancelar', 
                            action: function () {
                                dadosConsulta.close();
                                carregando.close();
                            }
                        }
                    }
            });


            var params = `action=quais_sao_meus_numeros&produto=${produto}&email=${email}&celular=${celular}`;

                    // ENVIAR PARA COMPRA
                    jQuery.ajax({
                        url: homeUrlRifa+"/wp-admin/admin-ajax.php",
                        type: "POST",
                        dataType: "json",
                        data: params,
                        success: function(data){
                            console.log("RETORNO SOBRE A CONSULTA:");
                            console.log(data);
                            // A CRIAÇÃO DO PEDIDO DEU CERTO! TEMOS O LEAD
                            if(data.sucesso==200){

                                console.log("SOLICITAÇÃO PIX ENVIADA COM SUCESSO!");
                                carregando.close();

                                var dados = jQuery.confirm({
                                    title: 'Dados encontrados',
                                    //columnClass: 'large',
                                    content: `

                                         ${data.html}

                                    
                                    `,
                                    buttons: {
                                        heyThere: {
                                            text: 'Cancelar', 
                                            action: function () {
                                                dados.close();
                                            }
                                        }
                                    }
                                });

                                
                            // A CRIAÇÃO DO PEDIDO DEU ERRADO
                            }else{

                                        if(data.sucesso==203||data.sucesso==403){
                                                var b = $.confirm({
                                                    title: 'Oops! Algo deu errado.',
                                                    type: 'red',
                                                    content: 'Não foi possível processar sua solicitação. Tente novamente em alguns minutos, ou entre em contato com a gente',
                                                    buttons: {
                                                        heyThere: {
                                                            text: 'Ok, entendi', 
                                                            action: function () {
                                                                b.close();
                                                            }
                                                        }
                                                    }
                                                });
                                        }
                                

                            }

                        }
                    });

    }


}