;(function ($) {
    "use strict";
    var pxl_scroll_top;
    var pxl_window_width;
    var pxl_window_height;
    var pxl_scroll_status = '';
    var pxl_last_scroll_top = 0;

    $(window).on('load', function () {
        pxl_scroll_top = $(window).scrollTop();
        pxl_window_width = $(window).width();
        pxl_window_height = $(window).height();
        kaitex_loader();
        kaitex_header_sticky();
        kaitex_scroll_to_top();
        kaitex_footer_fixed();
        kaitex_quantity_icon();
        kaitex_panel_anchor_toggle();
        kaitex_document_click();
        kaitex_product_single_variations_att();
        kaitex_tab_carousel();
        kaitex_check_scroll();
        kaitex_check_menu();
        kaitex_webgl_effects();
        kaitex_functions();
        kaitex_functions_rsz();
        Splitting();
    });

    $(window).on('resize', function () {
        pxl_window_width = $(window).width();
        pxl_window_height = $(window).height();
        kaitex_functions_rsz();
    });

    $(window).on('scroll', function () {
        pxl_scroll_top = $(window).scrollTop();
        pxl_window_width = $(window).width();
        pxl_window_height = $(window).height();
        if (pxl_scroll_top < pxl_last_scroll_top) {
            pxl_scroll_status = 'up';
        } else {
            pxl_scroll_status = 'down';
        }
        pxl_last_scroll_top = pxl_scroll_top;
        kaitex_header_sticky();
        kaitex_scroll_to_top();
        kaitex_footer_fixed();
        kaitex_check_scroll();
    });

    $(document).ready(function () {
        /* Menu Responsive Dropdown */
        var $kaitex_menu = $('.pxl-header-elementor-main');
        $kaitex_menu.find('.pxl-menu-primary li').each(function () {
            var $kaitex_submenu = $(this).find('> ul.sub-menu');
            if ($kaitex_submenu.length == 1) {
                $(this).hover(function () {
                    if ($kaitex_submenu.offset().left + $kaitex_submenu.width() > $(window).width()) {
                        $kaitex_submenu.addClass('pxl-sub-reverse');
                    } else if ($kaitex_submenu.offset().left < 0) {
                        $kaitex_submenu.addClass('pxl-sub-reverse');
                    }
                }, function () {
                    $kaitex_submenu.removeClass('pxl-sub-reverse');
                });
            }
        });

        var $kaitex_subwidth = $('.pxl-menu-primary li .sub-menu li a span');
        $kaitex_subwidth.each(function () {
            var widest = 0;
            var submenu_width = $(this).width();
            if (submenu_width > widest) {
                widest = submenu_width;
            }
            if (widest > 150) {
                var $closestSubMenu = $(this).closest('.sub-menu');
                $closestSubMenu.css({
                    "min-width": widest + 90 + 'px'
                });
            }
        });

        /* Active Menu Header */
        $('.pxl-header-elementor-main .pxl-menu-primary .menu-item, .pxl-header-elementor-sticky .pxl-menu-primary .menu-item').each(function () {
            $(this).hover(function () {
                $(this).addClass('active').siblings('li').removeClass("active").find('.sub-menu li').removeClass("active");
            });
            $(this).find('.sub-menu').hover(function () {
                $(this).parent().addClass("active");
            });
            $(this).parents('section').mouseleave(function() {
                setTimeout(function () {
                    $('.pxl-menu-primary .menu-item').removeClass("active");
                }, 200);
            });
        });

        /* Start Menu Mobile */
        $('.pxl-header-menu li.menu-item-has-children, .pxl-nav-hidden li.menu-item-has-children, .pxl-menu-primary li.menu-item-has-children').append('<span class="pxl-menu-toggle"></span>');
        $('.pxl-menu-toggle').on('click', function () {
            if( $(this).hasClass('active')){
                $(this).closest('ul').find('.pxl-menu-toggle.active').toggleClass('active');
                $(this).closest('ul').find('.sub-menu.active').toggleClass('active').slideToggle();
                $(this).closest('ul').find('a.active').toggleClass('active');
            }else{
                $(this).closest('ul').find('.pxl-menu-toggle.active').toggleClass('active');
                $(this).closest('ul').find('.sub-menu.active').toggleClass('active').slideToggle();
                $(this).closest('ul').find('a.active').toggleClass('active');
                $(this).toggleClass('active');
                $(this).parent().find('> .sub-menu').toggleClass('active');
                $(this).parent().find('> .sub-menu').slideToggle();
                $(this).parent().find('> a').toggleClass('active');
            }
        });
        $(".pxl-nav-mobile").on('click', function () {
            $(this).toggleClass('active');
            $('.pxl-header-menu').toggleClass('active');
        });

        $(".pxl-menu-close, .pxl-header-menu-backdrop").on('click', function () {
            $('.pxl-header-main').find('.pxl-header-menu').removeClass('active');
            $('.pxl-nav-mobile').removeClass('active');
        });
        /* End Menu Mobile */

        /* Scroll To Top */
        $('.pxl-scroll-top').click(function () {
            $('html, body').animate({scrollTop: 0});
            return false;
        });

        /* Animate Time Delay */
        $('.pxl-grid-masonry').each(function () {
            var eltime = 100;
            var elt_inner = $(this).children().length;
            var _elt = elt_inner - 1;
            $(this).find('> .pxl-grid-item > .wow').each(function (index, obj) {
                $(this).css('animation-delay', eltime + 'ms');
                if (_elt === index) {
                    eltime = 100;
                    _elt = _elt + elt_inner;
                } else {
                    eltime = eltime + 60;
                }
            });
        });

        /* Nice Select */
        $('.pxl-nice-select, .woocommerce .woocommerce-ordering .orderby, #wp-block-archives-1, #wp-block-categories-1, .woocommerce div.product form.cart .variations select, #pxl-sidebar-area select').each(function () {
            $(this).niceSelect();
        });

        /* Comment Form */
        var inputElement = $('.comment-respond .form-submit input.submit');
        var buttonElement = $('<button>', {
            name: inputElement.attr('name'),
            id: inputElement.attr('id'),
            class: inputElement.attr('class'),
            type: inputElement.attr('type'),
            text: inputElement.val()
        });
        inputElement.replaceWith(buttonElement);

        /* Custom Widget */
        $(".widget.widget_search input, .widget.widget_product_search input").attr('required', true);
        $(".widget.widget_search button.search-submit").attr("aria-label", "Search");

        /* Custom Woocommerce */
        $('.woocommerce .woocommerce-summary-wrap.row.style1').parents('.product').addClass('pxl-product-page-style1');
        $('.woocommerce .woocommerce-summary-wrap.row.style2').parents('.product').addClass('pxl-product-page-style2');

        $(".woocommerce .pxl-wapper #pxl-main .pxl-content-product .woosc-quick-table").remove();
        $(".woocommerce ul.products li.product > .woosc-btn, .woocommerce ul.products li.product > .woosq-btn, .woocommerce ul.products li.product > .woosw-btn").remove();
        $(".single-product #primary div.product .entry-summary > button").remove();

        $('.add_to_cart_button').attr('title', 'Add To Cart');
        $('.product_type_grouped').attr('title', 'View Product');
        $('.product_type_external').attr('title', 'Shop Now');
        $('.woosw-btn').attr('title', 'Add To Wishlist');
        $('.woosq-btn').attr('title', 'Quick View');
        $('.woosc-btn').attr('title', 'Compare');

        $(".woocommerce-shop .widget_layered_nav .wc-layered-nav-term").on('click', function(e) {
            $(this).addClass('active').siblings('li').removeClass("active");
        });

        // Custom Add space in the end price currency
        $('.woocommerce-Price-currencySymbol').each(function() {
            var $el = $(this);
            var string = $el.text();
            $el.text('');
            var result = string.trim() + " ";
            $el.html(result);
        });

        // Custom move section shop single
        var productPage = $('.woocommerce .product.pxl-product-page-style2');

        var wooTabsWrapper = productPage.find('.woocommerce-tabs.wc-tabs-wrapper');
        var originalTabs = wooTabsWrapper.clone();
        wooTabsWrapper.remove();
        productPage.find('.woocommerce-summary-wrap .woocommerce-gallery + div').append(originalTabs);

        var tabMappings = [
            { tabName: 'description_tab', panelClass: 'woocommerce-Tabs-panel--description' },
            { tabName: 'additional_information_tab', panelClass: 'woocommerce-Tabs-panel--additional_information' },
            { tabName: 'tab-product-feature_tab', panelClass: 'woocommerce-Tabs-panel--tab-product-feature' },
            { tabName: 'reviews_tab', panelClass: 'woocommerce-Tabs-panel--reviews' }
            ];

        $.each(tabMappings, function(index, mapping) {
            var tabElement = productPage.find('.wc-tabs .' + mapping.tabName);
            var panelElement = originalTabs.find('.woocommerce-Tabs-panel.' + mapping.panelClass).clone();
            originalTabs.find('.woocommerce-Tabs-panel.' + mapping.panelClass).remove();
            tabElement.append(panelElement);
        });

        /* Search Popup */
        var $search_wrap_init = $("#pxl-search-popup");
        var search_field = $('#pxl-search-popup .search-field');
        var $body = $('body');

        $(".pxl-search-popup-button").on('click', function(e) {
            if (!$search_wrap_init.hasClass('active')) {
                $search_wrap_init.addClass('active');
                setTimeout(function() { search_field.get(0).focus(); }, 300);
            } else if (search_field.val() === '') {
                $search_wrap_init.removeClass('active');
                search_field.get(0).focus();
            }
            e.preventDefault();
            return false;
        });

        $("#pxl-search-popup .pxl-item--overlay, #pxl-search-popup .pxl-item--close").on('click', function (e) {
            $body.addClass('pxl-search-out-anim');
            setTimeout(function () {
                $body.removeClass('pxl-search-out-anim');
            }, 500);
            setTimeout(function () {
                $search_wrap_init.removeClass('active');
            }, 800);
            e.preventDefault();
            return false;
        });

        /* Select Theme Style */
        $('.wpcf7-select').each(function() {
            var $this = $(this), numberOfOptions = $(this).children('option').length;

            $this.addClass('pxl-select-hidden');
            $this.wrap('<div class="pxl-select"></div>');
            $this.after('<div class="pxl-select-higthlight"></div>');

            var $styledSelect = $this.next('div.pxl-select-higthlight');
            $styledSelect.text($this.children('option').eq(0).text());

            var $list = $('<ul />', {
                'class': 'pxl-select-options'
            }).insertAfter($styledSelect);

            for (var i = 0; i < numberOfOptions; i++) {
                $('<li />', {
                    text: $this.children('option').eq(i).text(),
                    rel: $this.children('option').eq(i).val()
                }).appendTo($list);
            }

            var $listItems = $list.children('li');

            $styledSelect.click(function(e) {
                e.stopPropagation();
                $('div.pxl-select-higthlight.active').not(this).each(function(){
                    $(this).removeClass('active').next('ul.pxl-select-options').addClass('pxl-select-lists-hide');
                });
                $(this).toggleClass('active');
            });

            $listItems.click(function(e) {
                e.stopPropagation();
                $styledSelect.text($(this).text()).removeClass('active');
                $this.val($(this).attr('rel'));
            });

            $(document).click(function() {
                $styledSelect.removeClass('active');
            });

        });

        /* Custom Background Page */
        if ($('.pxl-page-bg').length > 0) {
            $('#pxl-wapper').addClass('pxl-wapper-has-bg');
        }

        $('.pxl-nav-menu1.first-menu-style2').each(function() {
            var adminBar = $('body').hasClass('admin-bar');
            $(this).closest('.elementor-widget-pxl_menu').css("position", "sticky");
            $(this).closest('.elementor-widget-pxl_menu').css("top", adminBar ? 32 : 0);
        });

        /* Custom Login */
        $('.pxl-user-popup input[type="password"]').each(function() {
            var inputId = $(this).attr('id');
            $(this).parent().append('<div toggle="#' + inputId + '" class="fa fa-fw fa-eye toggle-password"></div>');
        });
        $(".toggle-password").click(function() {
            $(this).toggleClass("fa-eye fa-eye-slash");
            var input = $($(this).attr("toggle"));
            if (input.attr("type") == "password") {
                input.attr("type", "text");
            } else {
                input.attr("type", "password");
            }
        });
        $('.pxl-modal-close').on('click', function () {
            $(this).parent().removeClass('open').addClass('remove');
        });
        $('.btn-sign-up').on('click', function () {
            $('.pxl-user-register').addClass('u-open').removeClass('u-close');
            $('.pxl-user-login').addClass('u-close').removeClass('u-open');
        });
        $('.btn-sign-in').on('click', function () {
            $('.pxl-user-register').addClass('u-close').removeClass('u-open');
            $('.pxl-user-login').addClass('u-open').removeClass('u-close');
        });
        $('.pxl-user-have-an-account').on('click', function () {
            $(this).parents('.pxl-modal-content').find('.pxl-user-register').addClass('u-close').removeClass('u-open');
            $(this).parents('.pxl-modal-content').find('.pxl-user-login').addClass('u-open').removeClass('u-close');
        });

        var dropdownActive = false;
        $(document).on('click',function () {
            $('.pxl-user-account').removeClass('active');
            dropdownActive = false;
        });
        $('.h-btn-user').each(function () {
            dropdownActive = false;
            $(this).on('click', function (e) {
                e.preventDefault();
                e.stopPropagation();
                if (dropdownActive) {
                    return;
                }
                $('.pxl-user-popup').addClass('open').removeClass('remove');
                $(this).find('.pxl-user-account').toggleClass('active');
                dropdownActive = true;
            });
            $('.pxl-user-account').on('click', function (e) {
                e.stopPropagation();
                dropdownActive = false;
            });
        });

        /* Custom Loader */
        if( $('#pxl-loadding').hasClass('style-tower') ) {
            const selectAll = e => $(e),
            cubes = selectAll('.pxl-loader .cube'),
            cubeYPos = 10;

            gsap.set('.pxl-loader .preloader-inner', { autoAlpha: 1 });
            gsap.set('.pxl-loader .scene', { rotateX: -30 })

            gsap.to('.pxl-loader .cube', {
                duration: 4,
                scaleY: 3,
                rotateY: 180,
                y: (i) => {
                    return cubeYPos * i - (cubes.length - 1) * cubeYPos;
                },
                ease: "sine.inOut",
                stagger: {
                    each: 0.08,
                    yoyo: true,
                    repeat: -1,
                    from: "start"
                }
            });

            gsap.to('.pxl-loader .cube-ring', {
                duration: 4,
                scale: 1.2,
                rotateY: 180,
                ease: "sine.inOut",
                stagger: {
                    each: 0.05,
                    yoyo: true,
                    repeat: -1,
                    repeatDelay: 0,
                    ease: "none",
                    from: "start"
                }
            });

            gsap.timeline({
                repeat: -1,
                defaults: {
                    duration: 3,
                    stagger: {
                        each: 0.1,
                        from: "end"
                    },
                    ease: "power2.inOut"
                }
            })
            .from('.pxl-loader .cube-ring__rect-inner', {
                drawSVG: "0% 0%"
            })
            .to('.pxl-loader .cube-ring__rect-inner', {
                drawSVG: "100% 100%"
            });
        }

        /* Custom Effects */
        $('.pxl-parent-cursor').on("mouseenter", function () {
            var $btn = $(this).find(".btn-default");
            $btn.each(function () {
                $(this).on('click', function (e) {
                    if ($(this).find('.ripple-span').length < 1) {
                        kaitex_create_ripple($(this), e);
                    }
                });
            });
        });
        $('.btn-default').each(function () {
            if (!$(this).closest('.pxl-parent-cursor').length > 0) {
                $(this).on('click', function (e) {
                    kaitex_create_ripple($(this), e);
                });
            }
        });

    });

    /* --------------------------------------------------------------------------------------------- */

    function kaitex_panel_anchor_toggle() {
        'use strict';
        $(document).on('click','.pxl-anchor.side-panel',function(e){
            e.preventDefault();
            e.stopPropagation();
            var target = $(this).attr('data-target');
            $(this).toggleClass('cliked');
            $(target).toggleClass('open');
            $('body').toggleClass('side-panel-open');
            $(target).next('.pxl-overlay-drop').toggleClass('panel-open');
        });
        $(document).on('click','.custom-link.anchor',function(e){
            e.preventDefault();
            e.stopPropagation();
            var target = $(this).attr('data-target');
            $(this).toggleClass('cliked');
            $(target).toggleClass('anchor-target-open');
            $('.pxl-anchor-bg').toggleClass('anchor-bg-open');
        });
        $(".pxl-button.pxl-atc-popup").on('click', function () {
            $('body').addClass('pxl-ov-hidden');
            $(this).parents('.pxl-wapper').find('.pxl-page-popup').addClass('active');
        });
        $(".pxl-popup--close").on('click', function () {
            $('body').removeClass('pxl-ov-hidden');
            $(this).parent().removeClass('active');
        });

        //* Menu Dropdown
        $('.pxl-menu-primary li').each(function () {
            var $submenu = $(this).find('> ul.sub-menu');
            if ($submenu.length == 1) {
                $(this).hover(function () {
                    if ($submenu.offset().left + $submenu.width() > $(window).width()) {
                        $submenu.addClass('back');
                    } else if ($submenu.offset().left < 0) {
                        $submenu.addClass('back');
                    }
                }, function () {
                    $submenu.removeClass('back');
                });
            }
        });
    }

    function kaitex_document_click() {
        $(document).on('click',function (e) {
            var target = $(e.target);
            var check = '.btn-nav-mobile';

            if (!(target.is(check)) && target.closest('.pxl-hidden-template').length <= 0 && $('body').hasClass('side-panel-open')) {
                $('.btn-nav-mobile').removeClass('cliked');
                $('.pxl-hidden-template').removeClass('open');
                $('body').removeClass('side-panel-open');
                $('.pxl-overlay-drop').removeClass('panel-open');
            }

        });
        $(document).on('click','.pxl-close',function(e){
            e.preventDefault();
            e.stopPropagation();
            $(this).closest('.pxl-hidden-template').toggleClass('open');
            $('.btn-nav-mobile').removeClass('cliked');
            $('body').toggleClass('side-panel-open');
        });
        $(document).on('click','.pxl-close-drop',function(e){
            e.preventDefault();
            e.stopPropagation();
            $('.pxl-overlay-drop').removeClass('panel-open');
        });
    }

    /* Get Mouse Move Direction */
    function getDirection(ev, obj) {
        var w = $(obj).width(),
        h = $(obj).height(),
        x = (ev.pageX - $(obj).offset().left - (w / 2)) * (w > h ? (h / w) : 1),
        y = (ev.pageY - $(obj).offset().top - (h / 2)) * (h > w ? (w / h) : 1),
        d = Math.round( Math.atan2(y, x) / 1.57079633 + 5 ) % 4;
        return d;
    }
    function addClass( ev, obj, state ) {
        var direction = getDirection( ev, obj ),
        class_suffix = null;
        $(obj).removeAttr('class');
        switch ( direction ) {
            case 0 : class_suffix = '-top';    break;
            case 1 : class_suffix = '-right';  break;
            case 2 : class_suffix = '-bottom'; break;
            case 3 : class_suffix = '-left';   break;
        }
        $(obj).addClass( state + class_suffix );
    }
    $.fn.ctDeriction = function () {
        this.each(function () {
            $(this).on('mouseenter',function(ev){
                addClass( ev, this, 'in' );
            });
            $(this).on('mouseleave',function(ev){
                addClass( ev, this, 'out' );
            });
        });
    }

    /* Header Sticky */
    function kaitex_header_sticky() {
        if($('#pxl-header-elementor').hasClass('is-sticky')) {
            if (pxl_scroll_top > 147) {
                $('.pxl-header-elementor-sticky.pxl-sticky-stb, .pxl-header-mobile-sticky.pxl-sticky-stb').addClass('pxl-header-fixed');
            } else {
                $('.pxl-header-elementor-sticky.pxl-sticky-stb, .pxl-header-mobile-sticky.pxl-sticky-stb').removeClass('pxl-header-fixed');
            }

            if (pxl_scroll_status == 'up' && pxl_scroll_top > 147) {
                $('.pxl-header-elementor-sticky.pxl-sticky-stt, .pxl-header-mobile-sticky.pxl-sticky-stt').addClass('pxl-header-fixed');
            } else {
                $('.pxl-header-elementor-sticky.pxl-sticky-stt, .pxl-header-mobile-sticky.pxl-sticky-stt').removeClass('pxl-header-fixed');
            }

            if ($('.pxl-sticky-stb').length > 0 && pxl_window_width >= 1200) {
                var header_sticky_height = $('.pxl-header-elementor-sticky.pxl-sticky-stb').height();
                var adminBar = $('body').hasClass('admin-bar');
                $('.pxl-sidebar-sticky, .pxl-row-scroll-fixed .pxl-column-sticky, .pxl-sidebar-shop .sidebar-sticky').css("top", header_sticky_height + (adminBar ? 32 : 0));
            }

            if ($('.pxl-sticky-stt').length > 0 && pxl_window_width >= 1200 && pxl_scroll_top > 147) {
                var header_sticky_height = $('.pxl-header-elementor-sticky.pxl-sticky-stt').height();
                var adminBar = $('body').hasClass('admin-bar');
                if (pxl_scroll_status == 'up') {
                    $('.pxl-sidebar-sticky, .pxl-row-scroll-fixed .pxl-column-sticky, .pxl-sidebar-shop .sidebar-sticky').css("top", header_sticky_height + (adminBar ? 32 : 0));
                } else if (pxl_scroll_status == 'down') {
                    $('.pxl-sidebar-sticky, .pxl-row-scroll-fixed .pxl-column-sticky, .pxl-sidebar-shop .sidebar-sticky').css("top", adminBar ? 32 : 0);
                }
            }
        }
        $('.pxl-header-elementor-sticky').parents('body').addClass('pxl-header-sticky');
    }

    /* Scroll To Top */
    function kaitex_scroll_to_top() {
        if (pxl_scroll_top < pxl_window_height) {
            $('.pxl-scroll-top').addClass('pxl-off').removeClass('pxl-on');
        }
        if (pxl_scroll_top > pxl_window_height) {
            $('.pxl-scroll-top').addClass('pxl-on').removeClass('pxl-off');
        }
    }

    /* Footer Fixed */
    function kaitex_footer_fixed() {
        setTimeout(function(){
            var h_footer = $('.pxl-footer-fixed #pxl-footer-elementor').outerHeight() - 1;
            $('.pxl-footer-fixed #pxl-main').css('margin-bottom', h_footer + 'px');
        }, 600);
    }

    /* ====================
     WooComerce Quantity
     ====================== */
    function kaitex_quantity_icon() {
        $('#pxl-main .quantity').append('<span class="quantity-icon"><i class="quantity-down">-</i><i class="quantity-up">+</i></span>');
        $('.quantity-up').on('click', function () {
            $(this).parents('.quantity').find('input[type="number"]').get(0).stepUp();
            $(this).parents('.woocommerce-cart-form').find('.actions .button').removeAttr('disabled');
        });
        $('.quantity-down').on('click', function () {
            $(this).parents('.quantity').find('input[type="number"]').get(0).stepDown();
            $(this).parents('.woocommerce-cart-form').find('.actions .button').removeAttr('disabled');
        });
        $('.woocommerce-cart-form .actions .button').removeAttr('disabled');
    }

    function kaitex_product_single_variations_att() {
        $(document).on('mousedown', '.pro-variation-select', function (e) {
            e.preventDefault();
            var $this_var = $(this).closest('.variations'),
                this_closest = $(this).closest('.pxl-variation-att-terms'),
                target_hidden = $this_var.find('#'+this_closest.attr('data-id'));
            var $this = $(this);
            if (!$this.hasClass('custom-vari-enabled'))
                return;
            var target = $this.attr('data-value');
            if (!target)
                return;
            target_hidden.val(target).change();
            this_closest.find('li.pxl-vari-item').removeClass('active');
            $this.parent('li').addClass('active');
        });
    }

    /* Custom Tab Carousel */
    function kaitex_tab_carousel() {
        setTimeout(() => {
            $('.pxl-tab-carousel .pxl-item--content:not(:first-child)').css({
                "display": "none",
            });
        }, 1000);
    }

    /* Custom Check Scroll */
    function kaitex_check_scroll() {
        var $gridItems = $('.pxl-check-scroll');
        var viewportBottom = pxl_scroll_top + $(window).height();

        $gridItems.each(function() {
            var $gridItem = $(this);
            var elementTop = $gridItem.offset().top;
            var elementBottom = elementTop + $gridItem.outerHeight();

            if (elementTop < viewportBottom && elementBottom > pxl_scroll_top) {
                $gridItem.addClass('visible');
            } else {
                $gridItem.removeClass('visible');
            }
            $('.filter-item').click(function() {
                $gridItem.removeClass('visible');
                $gridItem.addClass('visible');
            });
        });

        // Check Active One Page
        $('.page-section').each(function(i) {
            if ($(this).position().top <= pxl_scroll_top) {
                $('.pxl-header-elementor-main .pxl-menu-primary > li > a.page-active').removeClass('page-active');
                $('.pxl-header-elementor-sticky .pxl-nav-menu .pxl-menu-primary > li > a.page-active').removeClass('page-active');
                $('.pxl-header-elementor-main .pxl-menu-primary > li > a').eq(i).addClass('page-active');
                $('.pxl-header-elementor-sticky .pxl-nav-menu .pxl-menu-primary > li > a').eq(i).addClass('page-active');
            }
        });
    }

    function kaitex_check_menu() {
        var sections = $('.page-section'),
        nav = $('.pxl-nav-menu1.first-menu-style2'),
        nav_height = nav.outerHeight();
        $(window).on('scroll', function () {
            var cur_pos = $(this).scrollTop();
            sections.each(function() {
                var top = $(this).offset().top - nav_height,
                bottom = top + $(this).outerHeight();
                if (cur_pos >= top && cur_pos <= bottom) {
                    nav.find('a').removeClass('page-active');
                    sections.removeClass('active');
                    $(this).addClass('active');
                    nav.find('a[href="#'+$(this).attr('id')+'"]').addClass('page-active');
                }
            });
        });
    }

    function kaitex_create_ripple($element, e) {
        var $offset = $element.offset();
        var $span = $('<span/>');
        var x = e.pageX - $offset.left;
        var y = e.pageY - $offset.top;

        $span.addClass('ripple-span');
        $span.css({
            top: y + 'px',
            left: x + 'px',
        });
        $element.append($span);
        window.setTimeout(function () {
            $span.remove();
        }, 2200);
    }

    /* Custom Loader */
    function kaitex_loader() {
        $('body').removeClass('pxl-ov-hidden');
        if( $('#pxl-loadding').hasClass('style-tower') || $('#pxl-loadding').hasClass('style-text') ) {
            $('#pxl-loadding').addClass('hide');
        } else {
            $(".pxl-loader").fadeOut("slow");
        }
    }

    /* Custom WebGL Effects */
    function kaitex_webgl_effects() {
        var WebGL_vs = `#ifdef GL_ES
        precision mediump float;
        #endif

        attribute vec3 aVertexPosition;
        attribute vec2 aTextureCoord;

        uniform mat4 uMVMatrix;
        uniform mat4 uPMatrix;

        uniform mat4 texture0Matrix;
        uniform mat4 texture1Matrix;
        uniform mat4 mapMatrix;

        varying vec3 vVertexPosition;
        varying vec2 vTextureCoord0;
        varying vec2 vTextureCoord1;
        varying vec2 vTextureCoordMap;

        void main() {
            vec3 vertexPosition = aVertexPosition;

            gl_Position = uPMatrix * uMVMatrix * vec4(vertexPosition, 1.0);

            vTextureCoord0 = (texture0Matrix * vec4(aTextureCoord, 0., 1.)).xy;
            vTextureCoord1 = (texture1Matrix * vec4(aTextureCoord, 0., 1.)).xy;
            vTextureCoordMap = (mapMatrix * vec4(aTextureCoord, 0., 1.)).xy;
            vVertexPosition = vertexPosition;
        }`;

        var WebGL_fs = `#ifdef GL_ES
        precision mediump float;
        #endif

        #define PI2 6.28318530718
        #define PI 3.14159265359
        #define S(a,b,n) smoothstep(a,b,n)

        uniform float uTime;
        uniform float uProgress;
        uniform vec2 uReso;
        uniform vec2 uMouse;

        varying vec3 vVertexPosition;
        varying vec2 vTextureCoord0;
        varying vec2 vTextureCoord1;
        varying vec2 vTextureCoordMap;

        uniform sampler2D texture0;
        uniform sampler2D texture1;
        uniform sampler2D map;

        float exponentialEasing (float x, float a){

            float epsilon = 0.00001;
            float min_param_a = 0.0 + epsilon;
            float max_param_a = 1.0 - epsilon;
            a = max(min_param_a, min(max_param_a, a));

            if (a < 0.5){
                a = 2.0 * a;
                float y = pow(x, a);
                return y;
            } else {
                a = 2.0 * (a-0.5);
                float y = pow(x, 1.0 / (1.-a));
                return y;
            }
        }

        vec4 blur13(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
            vec4 color = vec4(0.0);
            vec2 off1 = vec2(1.411764705882353) * direction;
            vec2 off2 = vec2(3.2941176470588234) * direction;
            vec2 off3 = vec2(5.176470588235294) * direction;
            color += texture2D(image, uv) * 0.1964825501511404;
            color += texture2D(image, uv + (off1 / resolution)) * 0.2969069646728344;
            color += texture2D(image, uv - (off1 / resolution)) * 0.2969069646728344;
            color += texture2D(image, uv + (off2 / resolution)) * 0.09447039785044732;
            color += texture2D(image, uv - (off2 / resolution)) * 0.09447039785044732;
            color += texture2D(image, uv + (off3 / resolution)) * 0.010381362401148057;
            color += texture2D(image, uv - (off3 / resolution)) * 0.010381362401148057;
            return color;
        }

        void main(){
            vec2 uv0 = vTextureCoord0;
            vec2 uv1 = vTextureCoord1;

            float progress0 = uProgress;
            float progress1 = 1. - uProgress;

            vec4 map = blur13(map, vTextureCoordMap, uReso, vec2(2.)) + 0.5;

            uv0.x += progress0 * map.r;
            uv1.x -= progress1 * map.r;

            vec4 color = texture2D( texture0, uv0 );
            vec4 color1 = texture2D( texture1, uv1 );

            gl_FragColor = mix(color, color1, progress0 );
        }`;
        class WebglHover {
            constructor(set) {
                this.canvas = set.canvas
                this.webGLCurtain = new Curtains({
                    container: this.canvas,
                    watchScroll: false,
                    pixelRatio: Math.min(1.5, window.devicePixelRatio)
                })
                this.planeElement = set.planeElement
                this.mouse = {
                    x: 0,
                    y: 0
                }
                this.params = {
                    vertexShader: WebGL_vs,
                    fragmentShader: WebGL_fs,
                    widthSegments: 40,
                    heightSegments: 40,
                    uniforms: {
                        time: {
                            name: "uTime",
                            type: "1f",
                            value: 0
                        },
                        mousepos: {
                            name: "uMouse",
                            type: "2f",
                            value: [0, 0]
                        },
                        resolution: {
                            name: "uReso",
                            type: "2f",
                            value: [innerWidth, innerHeight]
                        },
                        progress: {
                            name: "uProgress",
                            type: "1f",
                            value: 0
                        }
                    }
                }
                this.initPlane()
            }

            initPlane() {
                this.plane = new Plane(this.webGLCurtain, this.planeElement, this.params)

                if (this.plane) {
                    this.plane.onReady(() => {
                        this.update()
                        this.initEvent()
                    })
                }
            }

            update() {
                this.plane.onRender(() => {
                    this.plane.uniforms.time.value += 0.01

                    this.plane.uniforms.resolution.value = [innerWidth, innerHeight]
                })
            }

            initEvent() {
                this.planeElement.addEventListener("mouseenter", () => {
                    gsap.to(this.plane.uniforms.progress, .8, {
                        value: 1
                    })
                })

                this.planeElement.addEventListener("mouseout", () => {
                    gsap.to(this.plane.uniforms.progress, .8, {
                        value: 0
                    })
                })
            }
        }

        if (navigator.userAgent.indexOf('Safari') == -1 || navigator.userAgent.indexOf('Chrome') > -1) {
            $('.pxl-image-box1').each(function() {
                const $this = $(this);
                const item_image_height = $this.find('.image-front').height();
                $this.find('.canvas canvas').css('height', item_image_height + 'px');

                const initialized = $this.data('initialized');
                if (!initialized) {
                    $this.data('initialized', true);
                    const canvas = $this.find('.item--canvas')[0];
                    const planeElement = $this.find('.item--image')[0];
                    new WebglHover({
                        canvas: canvas,
                        planeElement: planeElement
                    });
                }
            });
        }

        if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
            $('.pxl-image-box1 .image-front').css('opacity', '1');
        }

    }

    function kaitex_functions() {
        // Detect mobile device
        var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Nokia|Opera Mini/i.test(navigator.userAgent) ? true : false;
        if(isMobile) {
            $("body").addClass("is-mobile");
        } else {
            $("body").removeClass("is-mobile");
        }

        $('.pxl-grid-direction .item-direction').ctDeriction();

        $('.pxl-section-scroll').each(function () {
            gsap.registerPlugin(ScrollTrigger);
            const scrollEx = () => {
                var prevSection = $(this).prev('section');
                gsap.utils.toArray($(this).find('.element-scroll')).forEach((section, index) => {
                    const w = section;
                    var x = w.scrollWidth * -1;
                    var xEnd = 0;
                    if($(section).closest('.pxl-section-scroll').hasClass('revesal')){
                        x = '100%';
                        xEnd = (w.scrollWidth + 50 - section.offsetWidth) * -1;
                    }
                    gsap.fromTo(w, { x }, {
                        x: xEnd,
                        scrollTrigger: {
                            trigger: prevSection,
                            start: 'top 10%',
                            end: 'bottom 50%',
                            scrub: 0.5
                        }
                    });
                });
            }
            scrollEx();
        });

        /* Lightbox Popup */
        $('.btn-video, .pxl-video-popup').magnificPopup({
            type: 'iframe',
            mainClass: 'mfp-fade',
            removalDelay: 160,
            preloader: false,
            fixedContentPos: false
        });

        /* Related Post */
        $('.pxl-post-swiper').each(function() {
            var related_data = $(this).find('.pxl-swiper-container').data(),
            numberOfSlides = $(this).find('.pxl-swiper-container .pxl-swiper-slide').length,
            settings = related_data.settings,
            carousel_settings = {
                direction: settings['slide_direction'],
                effect: settings['slide_mode'],
                wrapperClass: 'pxl-swiper-wrapper',
                slideClass: 'pxl-swiper-slide',
                slidesPerView: settings['slides_to_show'],
                slidesPerGroup: settings['slides_to_scroll'],
                slidesPerColumn: settings['slide_percolumn'],
                spaceBetween: settings['slides_gutter'],
                navigation: {
                    nextEl: $(this).find(".pxl-swiper-arrow-next"),
                    prevEl: $(this).find(".pxl-swiper-arrow-prev"),
                },
                pagination: {
                    el: $(this).find(".pxl-swiper-dots"),
                    clickable : true,
                    dynamicBullets: true,
                    modifierClass: 'pxl-swiper-pagination-',
                    bulletClass : 'pxl-swiper-pagination-bullet',
                    renderCustom: function (swiper, element, current, total) {
                        return current + ' of ' + total;
                    },
                    type: settings['pagination_type'],
                },
                speed: settings['speed'],
                watchSlidesProgress: true,
                watchSlidesVisibility: true,
                breakpoints: {
                    0 : {
                        slidesPerView: settings['slides_to_show_xs'],
                        slidesPerGroup: settings['slides_to_scroll'],
                    },
                    576 : {
                        slidesPerView: settings['slides_to_show_sm'],
                        slidesPerGroup: settings['slides_to_scroll'],
                    },
                    768 : {
                        slidesPerView: settings['slides_to_show_md'],
                        slidesPerGroup: settings['slides_to_scroll'],
                    },
                    992 : {
                        slidesPerView: settings['slides_to_show_lg'],
                        slidesPerGroup: settings['slides_to_scroll'],
                    },
                    1200 : {
                        slidesPerView: settings['slides_to_show'],
                        slidesPerGroup: settings['slides_to_scroll'],
                    },
                    1600 : {
                        slidesPerView: settings['slides_to_show_xxl'],
                        slidesPerGroup: settings['slides_to_scroll'],
                    }
                }
            };
            // center
            if(settings['center'] === 'true'){
                if(settings['loop'] === 'true'){
                    carousel_settings['initialSlide'] = Math.floor(numberOfSlides / 2);
                } else {
                    carousel_settings['initialSlide'] = Math.floor(numberOfSlides / carousel_settings['slidesPerView']);
                }
            }
            // effect
            if(settings['slide_mode'] === 'fade'){
                carousel_settings['fadeEffect'] = {
                    crossFade: true
                };
            }
            // loop
            if(settings['loop'] === 'true'){
                carousel_settings['loop'] = true;
            }
            // auto play
            if(settings['autoplay'] === 'true'){
                carousel_settings['autoplay'] = {
                    delay : settings['delay'],
                    disableOnInteraction : settings['pause_on_interaction']
                };
            } else {
                carousel_settings['autoplay'] = false;
            }
            // mouse wheel
            if(settings['mousewheel'] === 'true'){
                carousel_settings['mousewheel'] = true;
                carousel_settings['keyboard'] = {
                    enabled: true
                };
            }
            var swiper = new Swiper($(this).find('.pxl-swiper-container'), carousel_settings);
        });

        /* Custom Rating Comment Form */
        $('.comments-rating').each(function () {
            const $this = $(this);
            const ratingLabels = $this.find('label[for^="rating-"]');
            ratingLabels.each(function () {
                $(this).on('click', function () {
                    const ratingValue = $(this).attr('for').replace('rating-', '');
                    const ratingInputs = $this.find('input[name="rating"]');
                    ratingInputs.each(function () {
                        if ($(this).val() === ratingValue) {
                            $(this).prop('checked', true);
                        } else {
                            $(this).prop('checked', false);
                        }
                    });
                });
            });
        });

        /* Custom Aria Label */
        $('.pxl-grid .pxl-pagination-links a').each(function() {
            var $this = $(this);
            var labelText = $this.text();

            if (!labelText.trim()) {
                if ($this.hasClass('next')) {
                    $this.attr('aria-label', 'next');
                } else if ($this.hasClass('prev')) {
                    $this.attr('aria-label', 'prev');
                }
            } else {
                $this.attr('aria-label', labelText);
            }
        });

        if ($('.pxl-slider-1').length) {
            $('.pxl-slider-1').each(function () {
                var $thisSlide = $(this),
                slideImg1 = $thisSlide.find('.item--image .image--inner');

                if (slideImg1.length) {
                    gsap.set(slideImg1, {scale: 0})
                    gsap.to(slideImg1, 1, {scale: 1, ease: "expo.inOut", delay: 0.5})
                }

                var WebGL_vs = `varying vec2 vUv;
                void main() {
                    vUv = uv;
                    gl_Position = projectionMatrix
                    * modelViewMatrix
                    * vec4( position, 1.0 );
                }`;

                var WebGL_fs = `varying vec2 vUv;
                uniform sampler2D u_texture;
                uniform sampler2D u_displacement_map;
                uniform sampler2D u_next_texture;
                uniform float u_transition;
                uniform float u_direction;

                void main () {
                    vec2 uv_t = vec2(vUv.s, vUv.t);
                    vec4 displace_current = texture2D(u_texture, uv_t);
                    vec4 displace_next = texture2D(u_next_texture, uv_t);
                    vec2 uv_displaced1 = vec2(vUv.x + (displace_current.g * u_direction) * u_transition, vUv.y);
                    vec2 uv_displaced2 = vec2(vUv.x - (displace_next.g * u_direction) * (1. - u_transition), vUv.y);
                    vec4 texture = mix(texture2D(u_texture, uv_displaced1), texture2D(u_next_texture, uv_displaced2), u_transition);
                    gl_FragColor = texture;
                }`;

                const DRAGDISTANCE = 500;
                const DURATION = 1.5;
                let DRAGSIE = 0.5;

                if ($(window).width() < 1200) {
                    DRAGSIE = 0.2;
                }

                var imgWidth = $thisSlide.find('.item--image img');
                let renderWidth = imgWidth.width();
                let renderHeight = imgWidth.height();

                $(window).resize(function () {
                    renderWidth = imgWidth.width();
                    renderHeight = imgWidth.height();
                })

                class ThreeSlider {
                    constructor() {
                        this.$canvas = $thisSlide.find('canvas');
                        this.setup();
                    }

                    setup() {
                        this.setupThree();
                        this.setupSlider();
                        this.setupHammer();
                        this.loadTextures();
                        this.resize();
                        this.setupEventListeners();
                    }

                    setupThree() {
                        this.scene = new THREE.Scene();
                        this.camera = new THREE.PerspectiveCamera(59.8, renderWidth/renderHeight, 0.1, 1000);
                        this.renderer = new THREE.WebGLRenderer({
                            canvas: this.$canvas[0]
                        });

                        this.renderer.setSize(renderWidth, renderHeight);
                        this.renderer.setPixelRatio(window.devicePixelRatio);
                    }

                    setupSlider() {
                        this.slider = {
                            currentIndex: 0,
                            nextIndex: 0
                        };
                    }

                    setupHammer() {
                        this.hammer = new Hammer(this.$canvas[0]);
                    }

                    loadTextures() {
                        const loader = new THREE.TextureLoader();
                        let promises = [];
                        const images = $thisSlide.find('.image--inner img');
                        let urls = $.map(images, function(img) {
                            return $(img).attr('src');
                        });

                        for (let i = 0; i < urls.length; i++) {
                            const url = urls[i];
                            const promise = new Promise(resolve => {
                                loader.load(url, resolve);
                            });

                            promises.push(promise);
                        }

                        Promise.all(promises).then(textures => {
                            this.textures = textures;
                            this.setupPlane();
                        });
                    }

                    setupPlane() {
                        const vertex = WebGL_vs;
                        const fragment = WebGL_fs;

                        this.currentTexture = this.textures[this.slider.currentIndex];
                        this.nextTexture = this.textures[this.slider.nextIndex];

                        this.uniforms = {
                            time: { value: 1.0 },
                            resolution: { value: new THREE.Vector2() },
                            u_direction: { value: 1.0 },
                            u_transition: { value: 0.0 },
                            u_texture: { type: 't', value: this.currentTexture },
                            u_next_texture: { type: 't', value: this.nextTexture },
                            u_displacement_map: { type: 't', value: this.displacementMap }
                        }

                        this.displacementMap = new THREE.Uniform(null);
                        let dispImgElement = $thisSlide.find('.image--inner').data('displacement-map');
                        let displacementMapUrl = dispImgElement;
                        let loader = new THREE.TextureLoader().load(displacementMapUrl, result => {});

                        const geometry = new THREE.PlaneGeometry(1, 1, 1);
                        const material = new THREE.ShaderMaterial({
                            uniforms: this.uniforms,
                            vertexShader: vertex,
                            fragmentShader: fragment,
                        });
                        this.plane = new THREE.Mesh(geometry, material);
                        this.plane.position.z = -10;
                        this.plane.scale.set(10, 14, 10);
                        this.scene.add(this.plane);
                    }

                    resetProgress() {
                        TweenLite.to(this.uniforms.u_transition, .3, { value: 0, ease: Power3.easeOut, onComplete: () => {
                            this.isTweening = false;
                        } });
                    }

                    slide() {
                        const duration = DURATION * (1 - Math.abs(this.dragProgress));
                        TweenLite.to(this.uniforms.u_transition, duration, { value: 1, ease: Power3.easeOut, onComplete: () => {
                            this.slider.currentIndex = this.slider.nextIndex;
                            this.uniforms.u_texture.value = this.textures[this.slider.currentIndex];
                            this.uniforms.u_transition.value = 0;
                            this.isTweening = false;
                        }});
                    }

                    resize() {
                        this.width = renderWidth;
                        this.height = renderHeight;

                        this.renderer.setSize(this.width, this.height);
                        this.renderer.setPixelRatio(window.devicePixelRatio);

                        this.camera.aspect = this.width / this.height;
                        this.camera.updateProjectionMatrix();
                    }

                    setupEventListeners() {
                        $(window).on('resize', this.resize.bind(this));
                        this.hammer.on('pan', this.dragHandler.bind(this));
                        this.hammer.on('panend', this.dragendHandler.bind(this));
                        this.tick();
                    }

                    dragHandler(e) {
                        if (this.isTweening) return;

                        this.dragProgress = -e.deltaX / DRAGDISTANCE;

                        if (this.dragProgress >= 1 || this.dragProgress <= -1) return;

                        this.uniforms.u_direction.value = Math.sign(this.dragProgress);
                        this.uniforms.u_transition.value = Math.abs(this.dragProgress);
                        this.slider.nextIndex = this.mod(this.slider.currentIndex + Math.sign(this.dragProgress), this.textures.length);
                        this.uniforms.u_next_texture.value = this.textures[this.slider.nextIndex];
                    }

                    dragendHandler() {
                        this.isTweening = true;

                        if (this.dragProgress > DRAGSIE || this.dragProgress < -DRAGSIE) {
                            this.slide();
                        } else {
                            this.resetProgress();
                        }
                    }

                    tick() {
                        window.requestAnimationFrame(this.tick.bind(this));

                        this.renderer.render(this.scene, this.camera);
                    }

                    mod(n, m) {
                        return ((n % m) + m) % m;
                    }
                }

                const initialized = $thisSlide.data('initialized');
                if (!initialized && imgWidth.length) {
                    $thisSlide.data('initialized', true);
                    new ThreeSlider();
                }

                function handleResize() {
                    var pxlItemInner = $thisSlide.find(".pxl-item--inner");
                    var itemVideo = $thisSlide.find(".item--video");
                    if (itemVideo.length) {
                        if (pxl_window_width >= 1200) {

                            itemVideo.css('transform', '');

                            var pxlItemInnerRect = pxlItemInner[0].getBoundingClientRect();
                            var itemVideoRect = itemVideo[0].getBoundingClientRect();
                            var itemVideoWidth = itemVideo.width();

                            var itemVideoFRect = itemVideoRect.left + itemVideoWidth;
                            var distanceToElement1 = pxlItemInner.offset().top;

                            if (itemVideoFRect >= pxlItemInnerRect.left) {
                                itemVideo.css('transform', 'translateY(' + distanceToElement1 + 'px)');
                                itemVideo.css('margin-bottom', '7%');
                            } else {
                                itemVideo.css('transform', '');
                                itemVideo.css('margin-bottom', '');
                            }
                        } else {
                            itemVideo.css('transform', '');
                            itemVideo.css('margin-bottom', '');
                        }
                    }
                }

                $(window).on("resize", handleResize);

                handleResize();

            });
        }

        $('.pxl-image-box2').each(function() {
            var $this = $(this);
            var thisButton = $this.find('.item--bottom');
            var imgElement = $this.find('.item--bottom img');
            var bgElement = $this.find('.item--image');

            thisButton.on('click', function() {
                var imgElementBgO = imgElement.attr('src');
                var bgElementBgO = bgElement.css('--data-background-image');
                var backgroundImageUrl = bgElementBgO.replace(/^url\(['"]?(.+)['"]?\)$/, '$1');
                imgElement.attr('src', backgroundImageUrl);
                bgElement.css('--data-background-image', 'url(' + imgElementBgO + ')');
            });

        });

        $('.pxl-portfolio-grid-layout1').each(function() {
            var default_height = $(this).find('.pxl-grid-inner .grid-sizer').height();
            var gridInner = $(this).find('.pxl-grid-inner');
            gridInner.css('height', default_height);
        });

    }

    function kaitex_functions_rsz() {
        /* Custom fix header sticky transparent */
        if (pxl_window_width >= 1200) {
            $('#pxl-wapper').addClass('pxl-ov-hidden');
            setTimeout(function() {
                $('#pxl-wapper').removeClass('pxl-ov-hidden');
            }, 1000);
        } else if(pxl_window_width <= 1199) {
            $('#pxl-wapper').addClass('pxl-ov-hidden');
        }

        /* Custom width nice select shop archive */
        $('.woocommerce .nice-select').each(function() {
            var default_width = $('.woocommerce .products:not(.pxl-products-list) .woocommerce-product-inner').width();
            $(this).css("min-width", default_width);
            if ($('ul').hasClass('pxl-products-list')) {
                $(this).css({
                    "min-width": "270px"
                });
            }
        });

        /* Custom scroll flex control shop single */
        $('.woocommerce .woocommerce-summary-wrap.row .flex-control-nav').each(function () {
            var count_nav_item = $(this).find('li').length;
            if (count_nav_item >= 4) {
                $(this).addClass('pxl-custom-scroll');
                var flex_height = $(this).parent().height();
                $(this).css("max-height", flex_height);
            }
        });

        /* Blog List Scroll */
        $(".blog-list-scroll").each(function() {
            var get_height = $(this).find(".pxl-grid-item").outerHeight();
            var numScroll = $(this).attr('data-post-scroll');
            var dataSpace = parseInt($(this).find(".pxl-grid-item + .pxl-grid-item").css('margin-top').replace('px', ''));

            var trueSpace = dataSpace * (numScroll - 1);

            var list_height = (get_height * numScroll) + trueSpace;
            $(this).find(".pxl-blog-inner").css('max-height', list_height);

            $(this).find(".pxl-blog-inner").overlayScrollbars({
                className: "os-theme-thick-dark",
                overflowBehavior : {
                    x : "hidden",
                    y : "scroll"
                },
            });

            $(this).find(".pxl-blog-inner").hover(function () {
                $(this).find(".os-scrollbar-handle").addClass('pxl-scrollbar-transition');
            });
            $(this).find(".pxl-blog-inner").mouseleave(function() {
                setTimeout(() => {
                    $(this).find(".os-scrollbar-handle").removeClass('pxl-scrollbar-transition');
                }, 300);
            });
        });

        /* Custom Grid Filter Moving Border */
        $('.pxl-grid-filter1').each(function () {
            var marker = $(this).find('.filter-marker'),
            item = $(this).find('.filter-item'),
            current = $(this).find('.filter-item.active'),
            offsetTop = current.position().top;
            marker.css({
                top: offsetTop + current.outerHeight(),
                left: current.position().left,
                width: current.outerWidth(),
                display: "block"
            });

            item.mouseover(function () {
                var self = $(this),
                offsetacTop = self.position().top,
                offsetLeft = self.position().left,
                width = self.outerWidth() || current.outerWidth(),
                top = offsetacTop == 0 ? 0 : offsetacTop || offsetTop,
                left = offsetLeft == 0 ? 0 : offsetLeft || current.position().left;
                marker.stop().animate({
                    top: top + current.outerHeight(),
                    left: left,
                    width: width,
                }, 300);
            });

            item.on('click', function () {
                current = $(this);
            });

            item.mouseleave(function () {
                var offsetlvTop = current.position().top;
                marker.stop().animate({
                    top: offsetlvTop + current.outerHeight(),
                    left: current.position().left,
                    width: current.outerWidth()
                }, 300);
            });
        });

    }

    $(document).ajaxComplete(function() {
       kaitex_quantity_icon();
       kaitex_functions();
    });
})(jQuery);
