function coupon_flash_deals_navigation_open() {
    jQuery(".side_gb_nav").addClass('show');
}
function coupon_flash_deals_navigation_close() {
    jQuery(".side_gb_nav").removeClass('show');
}

jQuery(function($){
    $('.gb_toggle').click(function () {
        coupon_flash_deals_keyboard_navigation_loop($('.side_gb_nav'));
    });
});
jQuery('document').ready(function(){
    window.addEventListener('load', (event) => {
        jQuery(".loading").delay(2000).fadeOut("slow");
    });

    //* Navbar Fixed  
    function coupon_flash_deals_navbarFixed(){
        if ( jQuery('.nav-stick.is-sticky-on').length ){ 
            jQuery(window).on('scroll', function() {
                var scroll = jQuery(window).scrollTop();   
                if (scroll >= 295) {
                    jQuery(".nav-stick.is-sticky-on").addClass("header-fixed");
                } else {
                    jQuery(".nav-stick.is-sticky-on").removeClass("header-fixed");
                }
            });  
        };
    }

    coupon_flash_deals_navbarFixed();
});
jQuery(document).ready(function($) {
    $(window).on('scroll', function() {
        if ($(this).scrollTop() > 100) {
            $('.scrollup').fadeIn();
        } else {
            $('.scrollup').fadeOut();
        }
    });

    $('.scrollup').on('click', function() {
        $("html, body").animate({
            scrollTop: 0
        }, 600);
        return false;
    });
});


jQuery('document').ready(function(){
    var owl = jQuery('.slider-section .owl-carousel');
        owl.owlCarousel({
        margin:0,
        nav: true,
        lazyLoad: true,
        autoplayTimeout: 3000,
        loop: true,
        dots:false,
        navText : ['<i class="fas fa-angle-left"></i>','<i class="fas fa-angle-right"></i>'],
        responsive: {
          0: {
            items: 1
          },
          600: {
            items: 1
          },
          1000: {
            items: 1
          }
        },
        autoplayHoverPause : true,
        mouseDrag: true
      });
        
    var owl = jQuery('.slider-product-section .owl-carousel');
        owl.owlCarousel({
        margin:30,
        nav: false,
        lazyLoad: true,
        autoplayTimeout: 3000,
        loop: true,
        dots: false,
        navText : ['<i class="fas fa-angle-left"></i>','<i class="fas fa-angle-right"></i>'],
        responsive: {
          0: {
            items: 1,
            nav: false,
          },
          600: {
            items: 2
          },
          1000: {
            items: 3
          },
          1200: {
            items: 4
          }
        },
        autoplayHoverPause : true,
        mouseDrag: true
    });
});

    window.addEventListener('load', (event) => {
    jQuery(".loading").delay(2000).fadeOut("slow");
});

    
// Search js
document.addEventListener("DOMContentLoaded", function () {
  const searchIcon = document.getElementById("search-icon");
  const searchPopup = document.getElementById("search-popup");
  const closeSearchPopup = document.getElementById("close-search-popup");
  const focusableElementsSelector = 'input, button, [href], [tabindex]:not([tabindex="-1"])';
  let focusableElements, firstFocusable, lastFocusable;

  // Function to manage focusable elements inside the popup
  function coupon_flash_deals_updateFocusableElements() {
      focusableElements = searchPopup.querySelectorAll(focusableElementsSelector);
      firstFocusable = focusableElements[0];
      lastFocusable = focusableElements[focusableElements.length - 1];
  }

  // Ensure popup remains hidden on page load
  searchPopup.setAttribute("hidden", true);

  searchIcon.addEventListener("click", function () {
      searchPopup.removeAttribute("hidden"); // Show the popup
      searchPopup.classList.add("search-popup-visible"); // Add class for display
      document.body.classList.add("no-scroll"); // Disable background scrolling
      coupon_flash_deals_updateFocusableElements();
      firstFocusable.focus(); // Focus the first element in the popup
  });

  closeSearchPopup.addEventListener("click", function () {
      searchPopup.classList.remove("search-popup-visible"); // Remove display class
      searchPopup.setAttribute("hidden", true); // Ensure it's hidden
      document.body.classList.remove("no-scroll"); // Enable background scrolling
      searchIcon.focus(); // Return focus to the search icon
  });

  // Close the popup when clicking outside the content
  searchPopup.addEventListener("click", function (e) {
      if (e.target === searchPopup) {
          searchPopup.classList.remove("search-popup-visible");
          searchPopup.setAttribute("hidden", true);
          document.body.classList.remove("no-scroll");
          searchIcon.focus();
      }
  });

  // Trap focus inside the popup
  searchPopup.addEventListener("keydown", function (e) {
      if (e.key === "Tab") {
          coupon_flash_deals_updateFocusableElements();
          if (e.shiftKey) { // Shift+Tab
              if (document.activeElement === firstFocusable) {
                  e.preventDefault();
                  lastFocusable.focus(); // Loop focus back to the last element
              }
          } else { // Tab
              if (document.activeElement === lastFocusable) {
                  e.preventDefault();
                  firstFocusable.focus(); // Loop focus back to the first element
              }
          }
      }
  });
});