jQuery(document).ready(function(){
    LoginAction = $("#LoginAction").val();
    productStorageGlobal = localStorage.productWpContact;
    if(productStorageGlobal !='' && productStorageGlobal != undefined && productStorageGlobal != null && LoginAction =='failed')
    {        
        $("#BtnWP").trigger("click");
    }
    
    //toggle submenu - menu principal
    jQuery('#header__accounttoggle').click(function(){
       jQuery(this).find('.header__submenu').slideToggle('fast');
    });
    
    $('#chatMenu').unbind('click').bind('click', function() {
        $('.closeMenu').click()
        $('#btn_Chat').click()
    });
});
//
jQuery(document).on('click', '#result-filter__btnshopm', function () {
    jQuery('#result-filter__ctnshop--m').show();
    jQuery('#result-filter__ctnprodt--m').hide();
    jQuery(this).addClass('result-filter__btnshopm--active');
    jQuery('#result-filter__btnprodm').removeClass('result-filter__btnprodm--active');
});
jQuery(document).on('click', '#result-filter__btnprodm', function () {
    jQuery('#result-filter__ctnshop--m').hide();
    jQuery('#result-filter__ctnprodt--m').show();
    jQuery(this).addClass('result-filter__btnprodm--active');
    jQuery('#result-filter__btnshopm').removeClass('result-filter__btnshopm--active');

});


//filtro categorias
jQuery(document).on('click', '#filter__inpttoggle',function(){
   
    jQuery(this).find('.fa-caret-down').toggleClass('fa-caret-up');
    jQuery(this).toggleClass('filter__inpttoggle--active');
    jQuery(this).next().slideToggle();
});
//filtro ubicacion
jQuery(document).on('click', '#filter__inptlocation',function () {

    jQuery(this).find('.fa-caret-down').toggleClass('fa-caret-up');
    jQuery(this).toggleClass('filter__inpttoggle--active');
    jQuery(this).next().slideToggle();
});
//filtro comercial
jQuery('#filter__inptcomerc').click(function () {
    jQuery(this).find('.fa-caret-down').toggleClass('fa-caret-up');
    jQuery('#filter__locationcom').slideToggle('fast');
});
//

$(document).ready(function(){
$("#whatsapp").prop("disabled",false);
$("#step1").prop("disabled",true);
$("#step2").prop("disabled",true);
$("#step3").prop("disabled",true);
    var navListItems = $('div.setup-panel div a'),
        allWells = $('.setup-content'),
        allNextBtn = $('.nextBtn');
        allNextBtnWanted = $('.nextBtnWanted');
    allWells.hide();

    navListItems.click(function (e) {
        e.preventDefault();
        var $target = $($(this).attr('href')),
            $item = $(this);

        if (!$item.hasClass('disabled')) {
            navListItems.removeClass('btn-success').addClass('btn-default');
            $item.addClass('btn-success');
            allWells.hide();
            $target.show();
            $target.find('input:eq(0)').focus();
        }
    });

    allNextBtn.click(function () {
        var curStep = $(this).closest(".setup-content"),
            curStepBtn = curStep.attr("id"),
            nextStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().next().children("a"),
            curInputs = curStep.find("input[type='text'],input[type='url']"),
            isValid = true;
        $(".form-group").removeClass("has-error");
        for (var i = 0; i < curInputs.length; i++) {
            if (!curInputs[i].validity.valid) {
                isValid = false;
                $(curInputs[i]).closest(".form-group").addClass("has-error");
            }
        }
       
        if (isValid) nextStepWizard.removeAttr('disabled').trigger('click');
    });

    allNextBtnWanted.click(function () {
     
        var curStep = $(this).closest(".setup-content"),
            curStepBtn = curStep.attr("id"),
            nextStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().next().children("a"),
            curInputs = curStep.find("input[type='text'],input[type='url']"),
            isValid = true;
            //console.log(curInputs);
            
        $(".form-group").removeClass("has-error");
        for (var i = 0; i < curInputs.length; i++) {
   
            if (!curInputs[i].validity.valid) {
                //isValid = false;
                $(curInputs[i]).closest(".form-group").addClass("has-error");
            }
        }
        
        if (isValid) nextStepWizard.removeAttr('disabled').trigger('click');
    });

    $('.backBtn').on('click',function () {
        var curStep = $(this).closest(".setup-content"),
            curStepBtn = curStep.attr("id"),
            backStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().prev().children("a").trigger('click'),
            curInputs = curStep.find("input[type='text'],input[type='url']"),
            isValid = true;
        
        $(".form-group").removeClass("has-error");
        for (var i = 0; i < curInputs.length; i++) {
            if (!curInputs[i].validity.valid) {
                isValid = false;
                $(curInputs[i]).closest(".form-group").addClass("has-error");
            }
        }
        if (isValid) backStepWizard.removeAttr('disabled').trigger('click');
    });
    $('#back_step1').on('click',function () {
        
        var curStep = $(this).closest(".setup-content"),
            curStepBtn = curStep.attr("id"),
            backStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().prev().children("a").trigger('click'),
            curInputs = curStep.find("input[type='text'],input[type='url']"),
            isValid = true;
        
        $(".form-group").removeClass("has-error");
        for (var i = 0; i < curInputs.length; i++) {
            if (!curInputs[i].validity.valid) {
                isValid = false;
                $(curInputs[i]).closest(".form-group").addClass("has-error");
            }
        }
        if (isValid) backStepWizard.removeAttr('disabled').trigger('click');
    });
    
    $('div.setup-panel div a.btn-success').trigger('click');

$("#password").on("focusout", function (e) {
    if ($(this).val() != $("#passwordConfirm").val()) {
        $("#passwordConfirm").removeClass("valid").addClass("invalid");
    } else {
        $("#passwordConfirm").removeClass("invalid").addClass("valid");
    }
});

$("#passwordConfirm").on("keyup", function (e) {
    if ($("#password").val() != $(this).val()) {
        $(this).removeClass("valid").addClass("invalid");
    } else {
        $(this).removeClass("invalid").addClass("valid");
    }
});

});

//categories hover
jQuery(document).on('click', '.catego-animales',function(){
    var tag_id = $(this).data('tagid');
    jQuery(this).toggleClass('catego-hover');
    jQuery(this).toggleClass('catego-hover-animales_hover');
    $("#FastFilter2").removeClass("catego-hover");
    $("#FastFilter3").removeClass("catego-hover");
    $.arr.push(tag_id);

    var uniqueNames = [];
    $.each($.arr, function (i, el) {
        if ($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
    });
    $('#categories').val(uniqueNames);
});
jQuery(document).on('click', '.catego-frutas', function () {
    var tag_id = $(this).data('tagid');
    jQuery(this).toggleClass('catego-hover');
    jQuery(this).toggleClass('catego-hover-frutas_hover');
    $("#FastFilter1").removeClass("catego-hover");
    $("#FastFilter3").removeClass("catego-hover");
    $.arr.push(tag_id);

    var uniqueNames = [];
    $.each($.arr, function (i, el) {
        if ($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
    });


    $('#categories').val(uniqueNames);
});
jQuery(document).on('click', '.catego-mercancias', function () {
    var tag_id = $(this).data('tagid');
    jQuery(this).toggleClass('catego-hover');
    jQuery(this).toggleClass('catego-hover-mercancias_hover');
    $("#FastFilter1").removeClass("catego-hover");
    $("#FastFilter2").removeClass("catego-hover");
    $.arr.push(tag_id);
    $('#categories').val($.arr);
});


//enlaces interes
$(document).on('click','#enlaces-interes',function(){
    $(this).find('.fa-sort-desc').toggleClass('fa-sort-asc');
    $('#enlaces-interes__cont').slideToggle('fast'); 
});

//faq quest
$(document).on('click','#faq__qtitle',function(){
    $(this).find('.fa-plus').toggleClass('fa-minus');
    $(this).find('.fa-sort-desc').toggleClass('fa-sort-asc');
    $(this).toggleClass('faq__qtitle--active');
    $(this).next().slideToggle('fast');

});
/* price liquidation trigger*/
$("#price_liquidationWholesale").on({
    "focus": function (event) {
        $(event.target).select();
    },
    "keyup": function (event) {
        $(event.target).val(function (index, value ) {
            return value.replace(/\D/g, "")
                        //.replace(/([0-9])([0-9]{2})$/, '$1.$2')
                        .replace(/\B(?=(\d{3})+(?!\d)\.?)/g, ",");
        });
    }
});
$("#regular_priceWholesale").on({
    "focus": function (event) {
        $(event.target).select();
    },
    "keyup": function (event) {
        $(event.target).val(function (index, value ) {
            return value.replace(/\D/g, "")
                        //.replace(/([0-9])([0-9]{2})$/, '$1.$2')
                        .replace(/\B(?=(\d{3})+(?!\d)\.?)/g, ",");
        });
    }
});

$("#regular_priceWholesale").bind("keyup", function () {
    var regular_price =  $(this).val();
    var auxPrice = regular_price.replace(/,/g, "");
    var presentation_1 = $('#presentation_1').val();
  
    $('#_regular_price_visibility').val(auxPrice);
    $('#_regular_price').val(auxPrice);
    $('#unit_price_visibility').val(parseInt(auxPrice)/parseInt(presentation_1));
    $('#unit_price').val(parseInt(auxPrice)/parseInt(presentation_1));
    tax_prod();
    //$("#unit_price").val(unit_priceV);
    //generateMayorista();
});

/*unite price trigger*/
$("#unit_price_visibility").bind("keyup", function () {
    var unit_priceV =  $(this).val();
    $("#unit_price").val(unit_priceV);
    $("#regular_priceWholesale").val(0);
    $("#price_liquidationWholesale").val(0);
    generateMayorista();
});
/*regular price trigger*/
$("#_regular_price_visibility").bind("keyup", function () {
    var _regular_priceV =  $(this).val();
    $("#_regular_price").val(_regular_priceV);
    $("#regular_priceWholesale").val(0);
    $("#price_liquidationWholesale").val(0);
    generateUnitario();
});
    function generateFullName()
    {                        
        
        
        document.getElementById('unit').value =
        document.getElementById('presentation_1').value + '  ' +
        document.getElementById('presentation_2').value;
        document.getElementById('unit_price').value =
        Math.ceil(document.getElementById('unit_price').value);
        $(".unit_price_label").addClass('active', this.checked);    
        $("._regular_price_label").addClass('active', this.checked);   
        $('#text-presentation_2').text(document.getElementById('presentation_2').value);                     
        generateMayorista();
    }       
    function tax_prod(){
        var tax_prod = document.getElementById('tax_prod').value; 

        store_commission = $("#store_commission").val();
        var unitprice = document.getElementById('_regular_price').value; 
        var unit_price = unitprice.replace(/,/g, '');  
    
        //totalx = parseInt(unitTotal)*parseInt(store_commission)/100;
        totalx =((parseInt(unit_price)/(1 + (parseInt(tax_prod)/100))) * (1-(parseInt(store_commission) / 100)) ) + (parseInt(unit_price) - (parseInt(unit_price)/(1+parseInt(tax_prod)/100)));
        
        var unitTotal_ = Math.ceil(document.getElementById('_regular_price').value)
        //valuecommission =  parseInt(unitTotal_) - parseInt(totalx);
        valuecommission =  totalx;
        
        $("#valueTotal").text("Por cada venta recibirás "+new Intl.NumberFormat('de-DE').format(valuecommission.toFixed(0)));
        $("#valueTotalWh").text("Por cada venta recibirás "+new Intl.NumberFormat('de-DE').format(valuecommission.toFixed(0)));


        setTimeout(function(){ 
        var valueTotal = new Cleave('#valueTotal',{
            numeral: true,          
            numeralPositiveOnly: true
            })
        });
    }
        function generateUnitario()
        {            
            var _regularprice = document.getElementById('_regular_price').value; 
            var _regular_price = _regularprice.replace(/,/g, '');        
            document.getElementById('unit_price').value =
            Math.ceil(_regular_price /
            document.getElementById('presentation_1').value);
            document.getElementById('_regular_price_visibility').value = _regular_price;
            document.getElementById('_regular_price').value = Math.ceil(_regular_price);
            document.getElementById('unit_price').value = Math.ceil(document.getElementById('unit_price').value);
            document.getElementById('unit_price_visibility').value = Math.ceil(document.getElementById('unit_price').value);
            document.getElementById('presentation_1').value = document.getElementById('presentation_1').value;
            document.getElementById('presentation_2').value = document.getElementById('presentation_2').value;
            //Format unit price
            var unit_price_visibility = new Cleave('#unit_price_visibility',{
                numeral: true,          
                numeralPositiveOnly: true
              })
              //Format regular price
              var _regular_price_visibility = new Cleave('#_regular_price_visibility',{
                numeral: true,          
                numeralPositiveOnly: true
              })              
            
              var unitTotal = Math.ceil(document.getElementById('_regular_price').value)
              var tax_prod = document.getElementById('tax_prod').value; 
              store_commission = $("#store_commission").val();
              var unitprice = document.getElementById('unit_price').value; 
              var unit_price = unitprice.replace(/,/g, '');  

              //totalx = parseInt(unitTotal)*parseInt(store_commission)/100;
              totalx =((parseInt(unitTotal)/(1 + (parseInt(tax_prod)/100))) * (1-(parseInt(store_commission) / 100)) ) + (parseInt(unitTotal) - (parseInt(unitTotal)/(1+parseInt(tax_prod)/100)));
              valuecommission =  totalx;
                // totalx = parseInt(unitTotal)*parseInt(store_commission)/100;
                // var unitTotal_ = Math.ceil(document.getElementById('_regular_price').value)
                // valuecommission =  parseInt(unitTotal_) - parseInt(totalx);
                
                $("#valueTotal").text("Por cada venta recibirás "+new Intl.NumberFormat('de-DE').format(valuecommission.toFixed(0)));
            
                $("#valueTotalWh").text("Por cada venta recibirás "+new Intl.NumberFormat('de-DE').format(valuecommission.toFixed(0)));

            setTimeout(function(){ 
            var valueTotal = new Cleave('#valueTotal',{
                numeral: true,          
                numeralPositiveOnly: true
              })          

            });
    
        }   
        function generateMayorista(){            
                var unitprice = document.getElementById('unit_price').value; 
                var unit_price = unitprice.replace(/,/g, '');            
            document.getElementById('_regular_price').value =
                unit_price *
            document.getElementById('presentation_1').value ;
            document.getElementById('_regular_price').value = document.getElementById('_regular_price').value;
                document.getElementById('_regular_price_visibility').value = Math.ceil(document.getElementById('_regular_price').value);

                document.getElementById('unit_price').value = Math.ceil(unit_price);
            document.getElementById('presentation_1').value = document.getElementById('presentation_1').value;
            document.getElementById('presentation_2').value = document.getElementById('presentation_2').value;
                //Format regular price
                var _regular_price_visibility = new Cleave('#_regular_price_visibility',{
                    numeral: true,          
                    numeralPositiveOnly: true
                })

                var unitTotal = Math.ceil(document.getElementById('_regular_price').value)
                // store_commission = $("#store_commission").val();
                //   totalx = parseInt(unitTotal)*parseInt(store_commission)/100;
                //   var unitTotal_ = Math.ceil(document.getElementById('_regular_price').value)
                //   valuecommission =  parseInt(unitTotal_) - parseInt(totalx);
                  
                //   $("#valueTotal").val(valuecommission);
              
                var tax_prod = document.getElementById('tax_prod').value; 
                store_commission = $("#store_commission").val();
               
                totalx =((parseInt(unitTotal)/(1 + (parseInt(tax_prod)/100))) * (1-(parseInt(store_commission) / 100)) ) + (parseInt(unitTotal) - (parseInt(unitTotal)/(1+parseInt(tax_prod)/100)));
                
               
                var unitTotal_ = Math.ceil(document.getElementById('_regular_price').value)
                valuecommission =  totalx;
                $("#valueTotal").text("Por cada venta recibirás "+new Intl.NumberFormat('de-DE').format(valuecommission.toFixed(0)));
                $("#valueTotalWh").text("Por cada venta recibirás "+new Intl.NumberFormat('de-DE').format(valuecommission.toFixed(0)));
              setTimeout(function(){ 
              var valueTotal = new Cleave('#valueTotal',{
                  numeral: true,          
                  numeralPositiveOnly: true
                })          
  
              });
        }



 jQuery("#store_name").keyup(function(e){
  var  text =  this.value;
  var textmin = text.toLowerCase();
     var validar =0;
      if(textmin == 'la mayorista'){
         validar=1;
      }else if(textmin == 'mayorista'){
        validar=1;
      }else if(textmin == 'mayoristas'){
        validar=1;
      }else if(textmin=='lamayorista'){
        validar=1;
      }else if(textmin=='lamayorista.co'){
        validar=1;
      }else if(textmin=='lamayorista.com'){
        validar=1;
      } 
      if(validar==1)
      {
        alert('El nombre ('+textmin+') no esta permitido');
        jQuery("#store_name").val('');
      }
        });

        $.whatsapp_indicator='';
 jQuery("#whatsapp_indicator").change(function(e){
    $.whatsapp_indicator = $(this).val();
    if($.whatsapp_indicator!= ''){
        $("#whatsapp").prop("disabled",false);
        $("#MsmWhatsappindicator").hide();
    }else{
        $("#whatsapp").prop("disabled",true);
        $("#MsmWhatsappindicator").show();
        $("#whatsapp").val('');
    }
 });
  jQuery("#whatsapp").blur(function(e) {
     var cantidadNumero = jQuery(this).val();
     if($.whatsapp_indicator== 57){
      if(cantidadNumero.length<7){
                    $(this).attr('maxlength','10');
                    $(this).attr('minlength','7');
        $("#msmWhatsapp").show();
        $("#register_user").attr("disabled", true);
        $("#whatsapp").focus();
                    $("#step3").attr("disabled",true);
                    $.step3Validate=1;
      }else{
                    $(this).attr('maxlength','15');
        $("#msmWhatsapp").hide();
        $("#register_user").attr("disabled", false);
                    $("#step3").attr("disabled",false);
                    $.step3Validate=0;
      }
            }else
            {
                $("#step3").attr("disabled",false);
                $("#msmWhatsapp").hide();
                $("#register_user").attr("disabled", false);
        }
    });
var lastScrollTop = 0;

$(window).scroll(function (event) {
    var st = $(this).scrollTop();
    var alto_menu = $('.header').height();
    var alto_carousel = $('.callout-text').height();
    var alto_top = alto_menu + alto_carousel;
    if (st > lastScrollTop) {
        
    } else {
        // upscroll code
        $('.filter').css({
            'bottom': 'initial',
            'float': 'initial'
        });
        
    }
    lastScrollTop = st;
    /**Scroll para categorias y subcategorias */
    lastScrollTop = st;
    var header = $('.global-header').height();
    if(st>3)
    {
        $(".categoriesnew__right header.page-header").addClass("ScrollFixedCat");
        $('.categoriesnew__right header.page-header').css('top',header+'px');   
    }else{
        $(".categoriesnew__right header.page-header").removeClass("ScrollFixedCat");
    }

});

$(document).mouseup(function(e){
    $("#header__searchpreview, .header__searchpreview_mobil").hide();
});
// filter mobil button
jQuery(document).on('click','#filter__btnfloat',function(){
    jQuery('#filter-mbl').slideToggle('fast');    
});

/* Fast filter trigger */
jQuery(document).on('click','.filter__fastbtns .catego',function(){
    jQuery('#btnfiltrar').trigger('click');
});
/*close filter mobil */
jQuery(document).on('click','#close-filter-mobil',function(){
    jQuery('#filter-mbl').slideUp('fast');
});

$(document).ready(function(){
   
    $(document).on('input','.header__iptsearch',function()
    {
        if ($('#header__rsmobil').is(':visible')) {
            
            $('#cls-filter').show();
        }
    });

    $(document).on('click','#cls-filter',function(){
        
        $('.header__srslt').slideUp('fast');
        $(this).hide();
    });

    $(document).on('change', '#header__rsmobil',function(){

        if ($('#header__rsmobil').height() > 0 ) {
            $('.header__logo').css('opacity', '0.5');
            $('.header__logo').parent().removeAttr('href');
            $('.header__icon').each(function (i, item) {
                
            });
        }
    });

});

//
$(document).on('click', '#cls-filter', function () {
    $('#search_input_mobil').val('');
});
/**Solo numeros */
function Num(evt) 
{
    if ( window.event ) { // IE
        keyNum = evt.keyCode;
    } else {
        keyNum = evt.which;
    }

    if ( keyNum >= 48 && keyNum <= 57 ) {
        return true;
    } else {
        return false;
    }
}

$(document).on('click', '#cls-filter', function () {
    $('#search_input_mobil').val('');
});
function isMobileDevice() {
    return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1);
};
if(isMobileDevice()){
    $("#user_active_mobil").val('mobil');
}else{
    $("#user_active_mobil").val('desktop');
}

$('#modal1').on('hidden.bs.modal', function (e) {
    // do something...
    $('#modal1 iframe').attr("src", $("#modal1 iframe").attr("src"));
  });
  
  $('#modal6').on('hidden.bs.modal', function (e) {
    // do something...
    $('#modal6 iframe').attr("src", $("#modal6 iframe").attr("src"));
  });
  $('#modal4').on('hidden.bs.modal', function (e) {
    // do something...
    $('#modal4 iframe').attr("src", $("#modal4 iframe").attr("src"));
  });
/* filtro tienda */
$(document).ready(function(){
    $('#Tns__FormFilter').hide();
     if (!$('#Tns__FormFilter').is('visible')) {
        $('#Tns__FilterLeft').css('height','40px');
    }  
});
/* carousel single product */
$(document).ready(function(){
    $('.selectpicker').selectpicker();
    $('.Pto__carouselcont .carousel-inner .carousel-item:first-child()').addClass('active')
    $('.sprod-carousel__right .carousel-inner .carousel-item:first-child()').addClass('active')
    //show / hide country, state, city
    if ($('#Tns_store_country').val() == '' || $('#Tns_store_country').val() == null){
        $('#Tns_store_state').hide();
        $('#Tns_store_city').hide();
    }
    if ($('#Tns_store_state').val() == '' || $('#Tns_store_state').val() == null){
        $('#Tns_store_city').hide();
    }   
    $('#Tns_store_country').on('change',function(){
        if($(this).val()!='' || $(this).val()!= null)
        {
            $('#Tns_store_state').show();    
            $('#Tns_store_city').hide();
            $('#Tns_store_city, #Tns_store_state').val('');

        }else{
            $('#Tns_store_state, #Tns_store_city').hide();             
            //$('#Tns_store_state, #Tns_store_city').val('');             
        }       
    });
    $('#Tns_store_state').on('change',function(){
        if($(this).val()!='' || $(this).val()!= null)
        {
            $('#Tns_store_city').show();
        }else{
            $('#Tns_store_city').hide();
        }
    });
    $('#Tns_store_city').on('change',function(){
        $('#Tns_store_country').on('change', function () {
            $('#Tns_store_state_store').show();
        });   
    });
    //Show / hide country, state, city new version
    if($("#country_select, .country_select2, #Tns_store_city_desk, #cat_country, .stre_country").val()== '')
    {        
       
        $(".state_select,.state_select2,.city_select,.city_select2, #Tns_store_state_storedesk, #Tns_store_city_desk, #Tns_store_state_cat, #Tns_store_city_cat, #Tns_store_city, #Tns_store_state_store, #Tns_store_city_cat_mobil, .Tns_store_state_store,.Tns_store_city").hide();
        $(".state_select,.state_select2,.city_select,.city_select2, #Tns_store_state_storedesk, #Tns_store_city_desk,  #Tns_store_state_cat, #Tns_store_city_cat, #Tns_store_city, #Tns_store_state_store, #Tns_store_city_cat_mobil,.Tns_store_state_store, .Tns_store_city").val('');
        $(".state_arrow").hide();
        $(".city_arrow").hide();
    }else{        
        
        $(".state_select,.state_select2, #Tns_store_state_storedesk, #Tns_store_state_cat, #Tns_store_state_store, .Tns_store_state_store").show();
    }
    $(document).on('change', '#country_select, #country_select2, #stre_country,#cat_country, .stre_country,#stre_country',function(){          
    if($(this).val()!='')
    {        
        $(".state_select, .state_select2, #Tns_store_state_storedesk, #Tns_store_state_cat, #Tns_store_state_store, .Tns_store_state_store").show();
        $(".city_select, .city_select2, #Tns_store_city_desk, #Tns_store_city_cat, #Tns_store_city , #Tns_store_city_cat_mobil, .Tns_store_city").hide();
        $(".city_select, .city_select2, #Tns_store_city_desk, #Tns_store_city_cat, #Tns_store_city, #Tns_store_city_cat_mobil, .Tns_store_city").val('');
        $(".state_arrow").show();
    }else{     
        $(".state_select,.state_select2, .city_select, .city_select2,#Tns_store_state_storedesk,#Tns_store_city_desk, #Tns_store_state_cat, #Tns_store_city_cat, #Tns_store_city, #Tns_store_state_store, #Tns_store_city_cat_mobil, .Tns_store_city").hide();
        $(".state_select,.state_select2, .city_select, .city_select2, #Tns_store_state_storedesk,#Tns_store_city_desk, #Tns_store_state_cat, #Tns_store_city_cat , #Tns_store_city, #Tns_store_state_store, #Tns_store_city_cat_mobil, .Tns_store_city").val('');
        $(".state_arrow").hide();
        $(".city_arrow").hide();
    }
 });   


if($(".state_select,.state_select2, #Tns_store_state_storedesk, #Tns_store_state_cat, #Tns_store_state_store, .Tns_store_state_store").val()==null)
{
    $(".city_select, .city_select2, #Tns_store_city_desk, #Tns_store_city_cat, #Tns_store_city, #Tns_store_city_cat_mobil, .Tns_store_city").hide();
    $(".city_arrow").hide();
}
 $(document).on('change', '#state_select, .state_select2, #Tns_store_state_storedesk, #Tns_store_state_cat, #Tns_store_state_store, .Tns_store_state_store',function(){          
    if($(this).val()!='')
    {
        $(".city_select, .city_select2, #Tns_store_city_desk, #Tns_store_city_cat, #Tns_store_city, #Tns_store_city_cat_mobil, .Tns_store_city").show();
        $(".city_arrow").show();
    }else{
        $(".city_select, .city_select2, #Tns_store_city_desk, #Tns_store_city_cat, #Tns_store_city, #Tns_store_city_cat_mobil,.Tns_store_city").hide();
        $(".city_select, .city_select2, #Tns_store_city_desk, #Tns_store_city_cat, #Tns_store_city, #Tns_store_city_cat_mobil,.Tns_store_city").val('');
        $(".city_arrow").show();
    }
 });   



});
/* Boton filtro avanzado  */
$(document).on('click', '#Mic__btnadvancefilter',function(){
    $('.Mic__contadvfilter').fadeToggle();
});
/* 
    Toggle plans mobil
 */
$(document).ready(function(){
    $('[id^="plans__"]').parent().next().slideUp();
    $(document).on('click','#plans__1,#plans__2,#plans__3,#plans__4, #plans__5',function(){        
        
        $('[id^="plans__"]').parent().next().slideUp();
        
        var id =  $(this)[0].id;
            var listId = $("#"+id).data('planslist');
            var idSelected = $("#"+id).data('idform');            
                
                var plans = listId.split(',');
                $.each(plans, function (i, e) {                 
                if(e == idSelected)
                {                
                    $("#plans__"+e).parent().next().slideToggle();                    
                    if(e == 1){    
                        $("#pn_day").val(10);
                    }else if(e == 2){
                        $("#pn_day").val(3);
                    }else if(e == 3){
                        $("#pn_day").val(1);                    
                    }else if(e == 5){
                      $("#pn_day").val(7);
                    }
                } 
                if(e != idSelected)
                {  
                    $('.Pn__addItem input[type=checkbox]').prop("checked", false);
                    $('.Pn__totalplan p b').html(0);       
                    $('#totalPlan'+e).val(0);  
                }
            });       
        $("#"+id).removeClass('planS_'+id);
        $('div[class^=planS_]').toggle('hide');             
    });

    /* HELP CENTER TABS */

    $("div.bhoechie-tab-menu>div.list-group>a").click(function(e) {
        e.preventDefault();
        $(this).siblings('a.active').removeClass("active");
        $(this).addClass("active");
        var index = $(this).index();    
        $(this).parent().parent().parent().find('div.bhoechie-tab>div.bhoechie-tab-content').removeClass("active");
        $(this).parent().parent().parent().find('div.bhoechie-tab>div.bhoechie-tab-content').eq(index).addClass("zoomInCentro active");
    });
});
/* 
    Hidden $0
*/
$(document).on('input','.Mic-BalancePoints__inptmodal',function(){
    $(this).prev().hide();
});
/* 
Toggle Movimientos mobil
 */
$(document).on('click','.Mic-BalancePoints__titlemov .fa-angle-down',function(){
    $('.Mic-BalancePoints__tableborder').slideToggle();
});

$(document).on('click', '.go-anchor', function (event) {/* SMOOTH ANCHORS */
    event.preventDefault();
    $('html, body').animate({
        scrollTop: $($.attr(this, 'href')).offset().top-55
    }, 800);
});

$(document).ready(function(){

    $(window).scroll(function(){//Show scroll top arrow
        $('.Testi__content').find('.Testi__arrowdown').css('opacity', $(this).scrollTop() >= 200 ? '1' : '0');
    });

    //Click event to scroll to top
    $('.Testi__arrowdown').click(function() {
        $('html, body').animate({
            scrollTop: 0
        }, 800);
        return false;
    }); // click() scroll top END

    $(".Testi__modal").each(function(){
        $(this).on('hidden.bs.modal', function(){
            var player = this.querySelector('.Testi__videoframe').contentWindow;
            player.postMessage('{"event":"command","func":"stopVideo","args":""}', '*')
        });
    });
});


/* CHANGELOG RESPONSIVE VIEW */

$(document).ready(function(){

    var screen_width = window.innerWidth;

    if(screen_width <= 767){

        $(".Change__web_tab_text, .Change__app_tab_text").hide();

        $(".Change__container_fluid").prepend(
            '<div class="row">'+
                '<div class="col-6">'+
                    '<h4 class="text-uppercase font-weight-bold text-center Change__web_tab_text Change__web_tab_text_mobile Change__active">web</h4>'+
                '</div>'+

                '<div class="col-6">'+
                    '<h4 class="text-uppercase font-weight-bold text-center Change__app_tab_text Change__app_tab_text_mobile">app</h4>'+
                '</div>'+
            '</div>'
            );
    }

    if($(".Change__web_tab_text_mobile").hasClass('Change__active')){

        $(".Change__app_tab").hide();

        $(".Change__web_tab").show();
    }

    if($(".Change__app_tab_text_mobile").hasClass('Change__active')){

        $(".Change__web_tab").hide();

        $(".Change__app_tab").show();
    }

    $(".Change__web_tab_text_mobile").on('click', function(){

        $(this).addClass('Change__active');

        $(".Change__app_tab_text_mobile").removeClass('Change__active');

        $(".Change__web_tab").fadeIn();

        $(".Change__app_tab").fadeOut();
    });

    $(".Change__app_tab_text_mobile").on('click', function(){

        $(this).addClass('Change__active');

        $(".Change__web_tab_text_mobile").removeClass('Change__active');

        $(".Change__app_tab").fadeIn();

        $(".Change__web_tab").fadeOut();
    });
});

if ('loading' in HTMLImageElement.prototype) {    
    const images = document.querySelectorAll(".lazyload");
    images.forEach(img => {
        $(img).parent().find('.world-preloader').css('display', 'none');
        img.src = img.dataset.src;
    });

} else {
    let script = document.createElement("script");
    script.async = true;
    script.src =
      "https://cdnjs.cloudflare.com/ajax/libs/lazysizes/4.1.8/lazysizes.min.js";
    document.body.appendChild(script);
}
