HEX
Server: LiteSpeed
System: Linux sv4.hami.host 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User: armgroup (1008)
PHP: 8.2.32
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, mail, socket_create, socket_create_listen, socket_create_pair, link, dl, openlog, syslog, stream_socket_server, curl_multi_init
Upload Files
File: /home/armgroup/public_html/store/js/script.js
  $(document).ready(function(){
    function resize(){   
        var calculatePadding = parseInt($('.header-container').css("height"));
        
            $(".body-content").css({
                "padding-top": calculatePadding + "px"
            });
        
    }

    resize(); 
    $(window).resize(function(){ 
        resize();
    });
});

  
  
  document.addEventListener('DOMContentLoaded', () => {
        const megaMenuTriggers = document.querySelectorAll('.has-megamenu');
        const allMegaMenus = document.querySelectorAll('.mega-menu');
        let hoverTimeout = null;
        let activeMenu = null;
        let activeTriggerLi = null;

        const closeAllMegaMenus = (immediately = false) => {
            allMegaMenus.forEach(menu => {
                if (menu.classList.contains('active')) {
                    menu.classList.remove('active');
                }
            });
             if (activeTriggerLi) {
                 activeTriggerLi.classList.remove('active-trigger');
             }
            activeMenu = null;
            activeTriggerLi = null;
            if (hoverTimeout && !immediately) {
                 clearTimeout(hoverTimeout);
                 hoverTimeout = null;
            }
        };

        const activateFirstTab = (menu) => {
            if (!menu) return;
            const tabs = menu.querySelectorAll('.pro-tabs > .p-tab');
            const contents = menu.querySelectorAll('.pro-contents > .p-content');

            tabs.forEach(tab => tab.classList.remove('active'));
            contents.forEach(content => content.classList.remove('active'));

            if (tabs.length > 0) {
                const firstTab = tabs[0];
                const firstContentId = firstTab.getAttribute('data-tab');
                const firstContent = menu.querySelector(`.pro-contents > #${firstContentId}`);

                firstTab.classList.add('active');
                if (firstContent) {
                    firstContent.classList.add('active');
                }
            }
        };

        megaMenuTriggers.forEach(triggerLi => {
            const targetMenuId = triggerLi.getAttribute('data-megamenu-target');
            const targetSelector = targetMenuId.startsWith('#') ? targetMenuId : `#${targetMenuId}`;
            // Important: Search for the menu within the nav context if placed inside
            const targetMenu = triggerLi.closest('nav').querySelector(targetSelector);
             // If menus are outside nav, use: document.querySelector(targetSelector);

            if (!targetMenu) {
                 console.warn('Mega menu not found for target:', targetSelector);
                return;
            }

            triggerLi.addEventListener('mouseenter', function() {
                if (hoverTimeout) {
                    clearTimeout(hoverTimeout);
                    hoverTimeout = null;
                }

                if (activeMenu && activeMenu !== targetMenu) {
                    closeAllMegaMenus(true);
                }

                if (!targetMenu.classList.contains('active')) {
                    closeAllMegaMenus(true); // Ensure others are closed

                    activeMenu = targetMenu;
                    activeTriggerLi = this; // Keep track of the trigger
                    activateFirstTab(activeMenu);
                    activeMenu.classList.add('active');
                    activeTriggerLi.classList.add('active-trigger'); // Add style to trigger
                }
            });

            triggerLi.addEventListener('mouseleave', function() {
                hoverTimeout = setTimeout(() => {
                    if (activeMenu && !activeMenu.matches(':hover')) {
                        closeAllMegaMenus(true);
                    }
                    hoverTimeout = null;
                }, 250);
            });
        });

        allMegaMenus.forEach(menu => {
            menu.addEventListener('mouseenter', () => {
                if (hoverTimeout) {
                    clearTimeout(hoverTimeout);
                    hoverTimeout = null;
                }
            });

            menu.addEventListener('mouseleave', () => {
                hoverTimeout = setTimeout(() => {
                    if (activeTriggerLi && !activeTriggerLi.matches(':hover')) {
                        closeAllMegaMenus(true);
                    }
                    hoverTimeout = null;
                }, 250);
            });

            const megaMenuTabs = menu.querySelectorAll('.pro-tabs > .p-tab');
            megaMenuTabs.forEach(tab => {
                tab.addEventListener('mouseenter', function() {
                    if (!menu.classList.contains('active')) return;

                    const tabTargetId = this.getAttribute('data-tab');
                    const tabTargetContent = menu.querySelector(`.pro-contents > #${tabTargetId}`);

                    if (tabTargetContent && !this.classList.contains('active')) {
                        const currentMenuTabs = menu.querySelectorAll('.pro-tabs > .p-tab');
                        const currentMenuContents = menu.querySelectorAll('.pro-contents > .p-content');

                        currentMenuTabs.forEach(t => t.classList.remove('active'));
                        currentMenuContents.forEach(content => content.classList.remove('active'));

                        tabTargetContent.classList.add('active');
                        this.classList.add('active');
                    }
                });
            });
        });

        document.addEventListener('click', function(event) {
            if (activeMenu && !activeMenu.contains(event.target) && activeTriggerLi && !activeTriggerLi.contains(event.target)) {
                closeAllMegaMenus(true);
            }
        });
    });


      $(document).ready(function(){
            var articlesCarousel = $('#baner-owl').owlCarousel({
                rtl: true,
                loop: true,
                // margin: 10,
                nav: true,
                dots: true,
                  navText: ['‹', '›'],
                center: true,
                // autoplay: true,
                autoplayTimeout: 5000,
                autoplayHoverPause: true,
                smartSpeed: 1000,
                // stagePadding: 100,
                responsive: {
                    0: {
                        items: 1,
                        // stagePadding:50
                    },
                    480: {
                        items: 1,
                        stagePadding:60
                    },
                     800: {
                        items: 1.1,
                        stagePadding: 100
                    },
                    
                  
                }
            });
            
            // Custom Navigation
            $('.carousel-prev').click(function() {
                articlesCarousel.trigger('prev.owl.carousel');
            });
            
            $('.carousel-next').click(function() {
                articlesCarousel.trigger('next.owl.carousel');
            });
        });

          $(document).ready(function(){
            $('#product-carousel').owlCarousel({
                rtl:true,
                loop: true,
                margin: 5,
                nav: true,
                dots: false,
                autoplay: true,
                autoplayTimeout: 4000,
                autoplayHoverPause: true,
                navText: ['‹', '›'],
                responsive: {
                    0: {
                        items: 1.2
                    },
                     400: {
                        items: 1.5
                    },
                     500: {
                        items: 2
                    },
                    680: {
                        items: 3
                    },
                    1000: {
                        items: 3.5
                    },
                     1200: {
                        items: 4.5
                    },
                    1350: {
                        items: 5
                    }
                }
            });
            
           
        });

         $(document).ready(function(){
            $('.most-sale-carousel').owlCarousel({
                rtl:true,
                loop: true,
                margin: 5,
                nav: true,
                dots: false,
                autoplay: true,
                autoplayTimeout: 4000,
                autoplayHoverPause: true,
                navText: ['‹', '›'],
               responsive: {
                     0: {
                        items: 1.2
                    },
                     400: {
                        items: 1.5
                    },
                     500: {
                        items: 2
                    },
                    680: {
                        items: 3
                    },
                    1000: {
                        items: 3.5
                    },
                     1200: {
                        items: 4.5
                    },
                    1350: {
                        items: 5
                    },
                     1550: {
                        items: 6
                    }
                }
            });
            
           
        });
          


        //---------------brands-make-carousel
// $(document).ready(function() {
//     const initializeOwlCarousel = () => {
//         const advantagesContainer=$('.brand-items')
//         if (window.innerWidth > 768) {
//             if (typeof advantagesContainer.data('owl.carousel') != 'undefined') {
//                 advantagesContainer.data('owl.carousel').destroy();
//               }
//               advantagesContainer.removeClass('owl-carousel');
            
//         } else if(window.innerWidth <= 768) {
//             if (!$('.brand-items').hasClass('owl-carousel')) {
//                 $('.brand-items').addClass('owl-carousel').owlCarousel({
//                     rtl: true,
//                     items: 1,
//                     dots: true,
//                     loop: true,
//                     // autoplay: true,
//                     // autoplayTimeout: 3000,
//                     // autoplayHoverPause: true,
//                     responsive: {
//                         0: {
//                             items: 3
//                         },
//                         576: {
//                             items: 4
//                         },
//                         768: {
//                             items: 5
//                         },
//                         1200: {
//                             items: 6
//                         },
                        
//                     }
//                 });
//             }
//         }
//     };

//     initializeOwlCarousel();
//     $(window).resize(initializeOwlCarousel);

  
// });
 $(document).ready(function(){
            var articlesCarousel = $('#brands-carousel').owlCarousel({
                rtl: true,
                loop: true,
                // margin: 10,
                // nav: true,
                dots: false,
                //   navText: ['‹', '›'],
                // center: true,
                autoplay: true,
                autoplayTimeout: 2000,
                autoplayHoverPause: true,
                smartSpeed: 1000,
                // stagePadding: 100,
                responsive: {
                    0: {
                        items: 3,
                        
                    },
                    480: {
                        items: 4,
                       
                    },
                     800: {
                        items: 6,
                    },
                    
                  
                }
            });
            
            // Custom Navigation
            $('.carousel-prev').click(function() {
                articlesCarousel.trigger('prev.owl.carousel');
            });
            
            $('.carousel-next').click(function() {
                articlesCarousel.trigger('next.owl.carousel');
            });
        });
 $(document).ready(function(){
            var articlesCarousel = $('#brands-two-carousel').owlCarousel({
                rtl: false,
                loop: true,
                // margin: 10,
                // nav: true,
                dots: false,
                //   navText: ['‹', '›'],
                // center: true,
                autoplay: true,
                autoplayTimeout: 2000,
                autoplayHoverPause: true,
                smartSpeed: 1000,
                // stagePadding: 100,
                responsive: {
                    0: {
                        items: 3,
                        
                    },
                    480: {
                        items: 4,
                       
                    },
                     800: {
                        items: 6,
                    },
                    
                  
                }
            });
            
            // Custom Navigation
            $('.carousel-prev').click(function() {
                articlesCarousel.trigger('prev.owl.carousel');
            });
            
            $('.carousel-next').click(function() {
                articlesCarousel.trigger('next.owl.carousel');
            });
        });


 function scrollToTop() {
            window.scrollTo({
                top: 0,
                behavior: 'smooth'
            });
        }


        $(document).ready(function() {
    const $logo = $('.header-logo img');
    const $header = $('.header-container');
    let isScrolled = false;

    $(window).scroll(function() {
        const scrollTop = $(this).scrollTop();
        
        if (scrollTop > 50) {
            if (!isScrolled) {
                $logo.css({
                    // 'height': '90px',
                    // 'width': 'auto'
                });
                $header.addClass('scrolled');
                isScrolled = true;
            }
        } else {
            if (isScrolled) {
                $logo.css({
                    'height': '',
                    'width': ''
                });
                $header.removeClass('scrolled');
                isScrolled = false;
            }
        }
    });
});




        document.addEventListener('DOMContentLoaded', function() {
            const mobileMenuToggle = document.getElementById('mobileMenuToggle');
            const mobileMenuClose = document.getElementById('mobileMenuClose');
            const mobileSideMenu = document.getElementById('mobileSideMenu');
            const mobileMenuOverlay = document.getElementById('mobileMenuOverlay');
            const body = document.body;

            function openMobileMenu() {
                mobileSideMenu.classList.add('active');
                mobileMenuOverlay.classList.add('active');
                body.classList.add('menu-open');
            }

            function closeMobileMenu() {
                mobileSideMenu.classList.remove('active');
                mobileMenuOverlay.classList.remove('active');
                body.classList.remove('menu-open');
            }

            if (mobileMenuToggle) {
                mobileMenuToggle.addEventListener('click', openMobileMenu);
            }

            if (mobileMenuClose) {
                mobileMenuClose.addEventListener('click', closeMobileMenu);
            }

            if (mobileMenuOverlay) {
                mobileMenuOverlay.addEventListener('click', closeMobileMenu);
            }

            const submenuToggles = document.querySelectorAll('.mobile-menu-item.has-submenu > button');
            submenuToggles.forEach(toggle => {
                toggle.addEventListener('click', function() {
                    const parentItem = this.parentElement;
                    const submenu = parentItem.querySelector('.mobile-submenu');
                    
                    submenuToggles.forEach(otherToggle => {
                        if (otherToggle !== this) {
                            const otherParent = otherToggle.parentElement;
                            const otherSubmenu = otherParent.querySelector('.mobile-submenu');
                            otherParent.classList.remove('active');
                            otherSubmenu.classList.remove('active');
                            
                            const otherCategoryButtons = otherParent.querySelectorAll('.mobile-submenu-category');
                            const otherCategoryItems = otherParent.querySelectorAll('.mobile-category-items');
                            otherCategoryButtons.forEach(btn => btn.classList.remove('active'));
                            otherCategoryItems.forEach(item => item.classList.remove('active'));
                        }
                    });

                    parentItem.classList.toggle('active');
                    submenu.classList.toggle('active');
                    
                    if (!submenu.classList.contains('active')) {
                        const categoryButtons = parentItem.querySelectorAll('.mobile-submenu-category');
                        const categoryItems = parentItem.querySelectorAll('.mobile-category-items');
                        categoryButtons.forEach(btn => btn.classList.remove('active'));
                        categoryItems.forEach(item => item.classList.remove('active'));
                    }
                });
            });

            const categoryToggles = document.querySelectorAll('.mobile-submenu-category');
            categoryToggles.forEach(categoryButton => {
                categoryButton.addEventListener('click', function(e) {
                    e.stopPropagation(); 
                    
                    const categoryItems = this.nextElementSibling;
                    
                    const siblingCategories = this.closest('.mobile-submenu').querySelectorAll('.mobile-submenu-category');
                    const siblingCategoryItems = this.closest('.mobile-submenu').querySelectorAll('.mobile-category-items');
                    
                    siblingCategories.forEach(category => {
                        if (category !== this) {
                            category.classList.remove('active');
                        }
                    });
                    
                    siblingCategoryItems.forEach(items => {
                        if (items !== categoryItems) {
                            items.classList.remove('active');
                        }
                    });
                    
                    this.classList.toggle('active');
                    categoryItems.classList.toggle('active');
                });
            });

            document.addEventListener('keydown', function(e) {
                if (e.key === 'Escape') {
                    closeMobileMenu();
                }
            });

            const mobileSearchBtn = document.querySelector('.mobile-search-btn');
            const mobileSearchInput = document.querySelector('.mobile-search input');

            if (mobileSearchBtn && mobileSearchInput) {
                mobileSearchBtn.addEventListener('click', function() {
                    const searchTerm = mobileSearchInput.value.trim();
                    if (searchTerm) {
                        console.log('جستجو برای:', searchTerm);
                        closeMobileMenu();
                    }
                });

                mobileSearchInput.addEventListener('keypress', function(e) {
                    if (e.key === 'Enter') {
                        mobileSearchBtn.click();
                    }
                });
            }

            mobileSideMenu.addEventListener('click', function(e) {
                e.stopPropagation();
            });
        });

        // $(document).ready(function(){
        //     function resize(){   
        //         var calculatePadding = parseInt($('.header-container').css("height"));
                
        //         $(".body-content").css({
        //             "padding-top": calculatePadding + "px"
        //         });
        //     }

        //     resize(); 
        //     $(window).resize(function(){ 
        //         resize();
        //     });
        // });



        $(document).ready(function() {
    const initializeOwlCarousel = () => {
        const advantagesContainer=$('.blogs')
        if (window.innerWidth > 1200) {
            if (typeof advantagesContainer.data('owl.carousel') != 'undefined') {
                advantagesContainer.data('owl.carousel').destroy();
              }
              advantagesContainer.removeClass('owl-carousel');
            
        } else if(window.innerWidth <= 1200) {
            if (!$('.blogs').hasClass('owl-carousel')) {
                $('.blogs').addClass('owl-carousel').owlCarousel({
                    rtl: true,
                    items: 1,
                    
                    dots: true,
                    loop: true,
                    // autoplay: true,
                    // autoplayTimeout: 3000,
                    // autoplayHoverPause: true,
                    responsive: {
                        0: {
                            items: 1.2
                        },
                        576: {
                            items: 1.5
                        },
                         700: {
                            items: 2.5
                        },
                        800: {
                            items: 3.1
                        },
                         992: {
                            items: 3.1
                        },
                       
                        
                    }
                });
            }
        }
    };

    initializeOwlCarousel();
    $(window).resize(initializeOwlCarousel);

  
});
 $('.user-login').on('mouseenter',function(){
    $('.user-menu').addClass('active'); 
  })

   $('body').on('mouseover',function(e){
    if(!e.target.closest('.user-login')){
    $('.user-menu').removeClass('active');
    // $('.cart-menu-container').removeClass('active');
    }
  })

if(document.querySelector('.sale-pic img')){
    document.addEventListener('DOMContentLoaded', function() {
            const saleImage = document.querySelector('.sale-pic img');
            
            function checkScroll() {
                const elementTop = saleImage.getBoundingClientRect().top;
                const elementVisible = 150;
                
                if (elementTop < window.innerHeight - elementVisible) {
                    saleImage.classList.add('animate');
                }
            }
            
            window.addEventListener('scroll', checkScroll);
            checkScroll();
    });
}

document.addEventListener('DOMContentLoaded', function() {
    const dropdown = document.querySelector('.has-dropdown');
    const dropdownMenu = document.querySelector('.simple-dropdown');
    let hoverTimeout;

    if (dropdown && dropdownMenu) {
        // نمایش زیرمنو
        dropdown.addEventListener('mouseenter', function() {
            clearTimeout(hoverTimeout);
            dropdownMenu.style.opacity = '1';
            dropdownMenu.style.visibility = 'visible';
            dropdownMenu.style.transform = 'translateY(0)';
        });

        // مخفی کردن زیرمنو
        dropdown.addEventListener('mouseleave', function() {
            hoverTimeout = setTimeout(() => {
                if (!dropdownMenu.matches(':hover')) {
                    dropdownMenu.style.opacity = '0';
                    dropdownMenu.style.visibility = 'hidden';
                    dropdownMenu.style.transform = 'translateY(-15px)';
                }
            }, 300);
        });

        // نگه داشتن زیرمنو باز
        dropdownMenu.addEventListener('mouseenter', function() {
            clearTimeout(hoverTimeout);
        });

        dropdownMenu.addEventListener('mouseleave', function() {
            dropdownMenu.style.opacity = '0';
            dropdownMenu.style.visibility = 'hidden';
            dropdownMenu.style.transform = 'translateY(-15px)';
        });

        // بستن با کلیک خارج
        document.addEventListener('click', function(e) {
            if (!dropdown.contains(e.target)) {
                dropdownMenu.style.opacity = '0';
                dropdownMenu.style.visibility = 'hidden';
                dropdownMenu.style.transform = 'translateY(-15px)';
            }
        });
    }
});

document.addEventListener('DOMContentLoaded', function() {
    const searchIcon = document.querySelector('.search-top i');
    const mobileSearchBar = document.getElementById('mobileSearchBar');
    const mobileSearchInput = document.getElementById('mobileSearchInput');

    // باز/بسته کردن
    searchIcon.addEventListener('click', function(e) {
        if (window.innerWidth <= 992) {
            e.preventDefault();
            if (mobileSearchBar.style.display === 'block') {
                mobileSearchBar.style.display = 'none';
            } else {
                mobileSearchBar.style.display = 'block';
                mobileSearchInput.focus();
            }
        }
    });

    // بستن با کلیک خارج
    document.addEventListener('click', function(e) {
        if (!mobileSearchBar.contains(e.target) && !searchIcon.contains(e.target)) {
            mobileSearchBar.style.display = 'none';
        }
    });

    // جستجو با Enter
    mobileSearchInput.addEventListener('keypress', function(e) {
        if (e.key === 'Enter') {
            performMobileSearch();
        }
    });
});

function performMobileSearch() {
    const searchTerm = document.getElementById('mobileSearchInput').value.trim();
    if (searchTerm) {
        console.log('جستجو:', searchTerm);
        // کد جستجو اینجا
        document.getElementById('mobileSearchBar').style.display = 'none';
    }
}


///all

if ($(".owl-slider").length) {
    $(document).ready(function () {
      var owl = $(".owl-slider");
      $(".owl-slider").owlCarousel({
        loop: true,
        margin: 10,
      animateIn: "fadeIn",
       animateOut: "fadeOut",
        autoplay: true,
        video: true,
         lazyLoad: true,
        navSpeed: 700,
        items: 1,
        rtl: true,
     
        responsive: {
          0: {
            dots: false,
            nav: true,
          },
          768: {
            dots: false,
            nav: true,
          },
        },
      });
  
      owl.on('translate.owl.carousel', function (e) {
        $('.owl-item .item video').each(function () {
          // pause playing video - after sliding
          $(this).get(0).pause();
        });
      });
      
      owl.on('translate.owl.carousel', function (e) {
        $('.owl-item .item video').each(function () {
          // pause playing video - after sliding
          $(this).get(0).pause();
        });
      });
      
      owl.on('translated.owl.carousel', function (e) {
        // check: does the slide have a video?
        if ($('.owl-item.active').find('video').length !== 0) {
          // play video in active slide
          $('.owl-item.active .item video').get(0).play();
        }
      });
  
  
    });
  }

if (matchMedia("only screen and (max-width: 768px)").matches) {
  $(".set > span").on("click", function () {
    if ($(this).hasClass("active")) {
      $(this).removeClass("active");
      $(this).siblings(".content").slideUp(200);
      $(".set > span i")
        .removeClass("fas fa-chevron-up")
        .addClass("fas fa-chevron-up");
    } else {
      $(".set > span i")
        .removeClass("fas fa-chevron-up")
        .addClass("fas fa-chevron-up");
      $(this)
        .find("i")
        .removeClass("fas fa-chevron-down")
        .addClass("fas fa-chevron-up");
      $(".set > span").removeClass("active");
      $(this).addClass("active");
      $(".content").slideUp(200);
      $(this).siblings(".content").slideDown(200);
    }
  });
}

$(function () {
  $(".scroll-down-icon a").on("click", function (e) {
    e.preventDefault();
    $("html, body").animate(
      {
        scrollTop: $($(this).attr("href")).offset().top,
      },
      500,
      "linear"
    );
  });
});

//gap
$(".menuTrigger").click(function () {
  $(".panel-menu").toggleClass("isOpen");
});

$(".openSubPanel").click(function () {
  $(this).next(".subPanel").addClass("isOpen");
});

$(".closeSubPanel").click(function () {
  $(".subPanel").removeClass("isOpen");
});

$("#panel-menu").on("click", function (e) {
  var target = $(e.target);
  if (
    target.attr("id") == "menu-toggle" ||
    target.parents("#panel-menu").length > 0 ||
    target.parents(".panel-menu").length > 0
  ) {
    console.log(
      "id: " +
        target.attr("id") +
        "contains: " +
        $.contains(target, $(".panel-menu"))
    );
  } else {
    if ($(".panel-menu").hasClass("isOpen"))
      $(".panel-menu").removeClass("isOpen");
    $(".subPanel").removeClass("isOpen");
  }
});

$(".closePanel").click(function () {
  $(".panel-menu").removeClass("isOpen");
  $(".subPanel").removeClass("isOpen");
});
//gap

if ($(".owl-send").length) {
  $(".owl-send").owlCarousel({
    // autoplay: true,
    loop: false,
    rtl: true,
    nav: false,
    navText: [
      "<i class='fas fa-angle-left'></i>",
      "<i class='fas fa-angle-right'></i>",
    ],
    lazyLoad: true,
    responsive: {
      0: {
        margin: 20,
        items: 2,
        dots: true,
      },
      500: {
        margin: 20,
        stagePadding: 60,
        items: 2,
        dots: false,
      },
      768: {
        margin: 20,
        stagePadding: 60,
        items: 2,
        dots: true,
      },
      991: {
        margin: 20,
        items: 4,
        dots: true,
      },
      1200: {
        margin: 40,
        items: 3
      },
    },
  });
}

//owl-help
if ($(".owl-pro").length) {
  $(".owl-pro").owlCarousel({
    //autoplay: true,
    loop: false,
    rtl: true,
    
    lazyLoad: true,
    responsive: {
      0: {
        dots: false,
        nav: false,
        items: 1,
        stagePadding: 60,
      },
      400: {
        dots: false,
        nav: false,
        items: 1,
        stagePadding: 80,
      },
      440: {
        dots: false,
        nav: false,
        items: 2,
        stagePadding: 20,
      },
      768: {
        dots: false,
        nav: false,
        items: 3,
        stagePadding: 30,
      },
      992: {
        dots: true,
        nav: false,
        items: 4,
        stagePadding: 30,
      },
      1200: {
        dots: true,
        nav: true,
        items: 4,
      },
    },
  });
}

if ($(".header").length) {
  $(document).ready(function () {
    $(window).scroll(function () {
      if ($(window).scrollTop() > 100) {
        $(".header").addClass("sticky-menu");
      } else {
        $(".header").removeClass("sticky-menu");
      }
    });
  });
}

function initCategoryBar() {
  var $overlay = $(".js-menu-overlay"),
    $naviOverlay = $(".js-navi-overlay"),
    $megaMenuMain = $(".js-mega-menu-main-item"),
    $megaMenuOptionsContainer = $(".js-mega-menu-categories-options"),
    $hoverEffect = $(".js-navi-new-list-category-hover"),
    $headerLinks = $(".js-categories-bar-item"),
    $megaMenuCategory = $(".js-mega-menu-category"),
    $searchBar = $(".js-search"),
    $searchResults = $(".js-search-results");

  var moveHover = function (self) {
    var parent = self.parent().parent().parent();

    $hoverEffect
      .css("width", self.width())
      .css(
        "right",
        parent.width() -
          (self.offset().left + self.width()) +
          parent.offset().left
      );
    $hoverEffect.css("transform", "scaleX(1)");
  };

  var removeHover = function () {
    $hoverEffect.css("transform", "scaleX(0)");
  };

  $headerLinks.hover(
    function () {
      moveHover.call(this, $(this));
    },
    function () {
      removeHover.call(this, $(this));
    }
  );

  $megaMenuMain.on("click", function (e) {
    e.stopPropagation();
  });

  var hoverAction;
  $megaMenuMain.hover(
    function () {
      var $this = $(this);
      hoverAction = setTimeout(function () {
        $this
          .children(".js-mega-menu-categories-options")
          .css("display", "flex");
        $naviOverlay.addClass("is-active");
        $searchResults.removeClass("is-active");
        $searchBar.removeClass("is-active");
      }, 200);
    },
    function () {
      hoverAction && clearTimeout(hoverAction);
      $naviOverlay.removeClass("is-active");
      $megaMenuOptionsContainer.hide();
    }
  );

  $megaMenuCategory.hover(
    function () {
      $megaMenuOptionsContainer
        .find(".js-categories-ad")
        .removeClass("ad-is-active");
      $megaMenuOptionsContainer
        .find("#categories-ad-" + $(this).data("index"))
        .addClass("ad-is-active");

      $megaMenuOptionsContainer
        .find(".js-mega-menu-category-options")
        .removeClass("is-active");
      $megaMenuCategory.removeClass("c-navi-new-list__inner-category--hovered");
      $(this).addClass("c-navi-new-list__inner-category--hovered");
      $megaMenuOptionsContainer
        .find("#categories-" + $(this).data("index"))
        .addClass("is-active");
    },

    function () {}
  );

  $overlay.hover(function () {
    if (!$(this).is(".is-active")) return true;
  });

  $megaMenuCategory.hover(
    function () {
      $megaMenuOptionsContainer
        .find(".js-categories-ad")
        .removeClass("ad-is-active");
      $megaMenuOptionsContainer
        .find("#categories-ad-" + $(this).data("index"))
        .addClass("ad-is-active");

      $megaMenuOptionsContainer
        .find(".js-mega-menu-category-options")
        .removeClass("is-active");
      $megaMenuCategory.removeClass("c-navi-new-list__inner-category--hovered");
      $(this).addClass("c-navi-new-list__inner-category--hovered");
      $megaMenuOptionsContainer
        .find("#categories-" + $(this).data("index"))
        .addClass("is-active");
    },

    function () {}
  );
}

function initStatic() {
  var $overlay = $(".js-menu-overlay"),
    $naviOverlay = $(".js-navi-overlay"),
    $newCategories = $(".js-navi-new-list-categories"),
    $newCategoryItem = $(".js-navi-new-list-category"),
    $hoverEffect = $(".js-navi-new-list-category-hover"),
    allCategoriesButton = $(".js-navi-new-list__all-links"),
    sentBanners = [];

  this.openCategories = false;
  var mainJs = this;

  $(".js-navi").hover(function () {
    $(this)
      .find("img[data-src]")
      .each(function () {
        $(this).attr("src", $(this).attr("data-src")).removeAttr("data-src");
      });
  });

  var moveHover = function (self) {
    var parent = self.parent().parent().parent();

    $hoverEffect
      .css("width", self.width())
      .css(
        "right",
        parent.width() -
          (self.offset().left + self.width()) +
          parent.offset().left
      );
    if ($(this).hasClass("is-fmcg")) {
      $hoverEffect.addClass("is-fmcg");
    } else {
      $hoverEffect.removeClass("is-fmcg");
    }
    $hoverEffect.css("transform", "scaleX(1)");
  };

  var removeHover = function () {
    $hoverEffect.css("transform", "scaleX(0)");
  };

  var handlerHover = function () {
    clearTimeout(this.closeTimer);
    var self = $(this);

    this.timer = setTimeout(function () {
      $("body").click();
      $naviOverlay.addClass("is-active");
      self.addClass("can-show-menu");
      self.siblings(".js-navi-new-list-category").addClass("can-show-menu");
      self.find(".js-navi-new-list-category").addClass("can-show-menu");
      mainJs.openCategories = true;
      var id = self.find(".c-adplacement__item").data("id");

      if (id && sentBanners.indexOf(id) < 0) {
        snt("dkBannerViewed", {
          bannerId: id,
          created_at: Date.now(),
        });
        sentBanners.push(id);
      }
      $(".js-search-results").removeClass("is-active");
    }, 200);
    if (self.hasClass("js-navi-new-list-category")) {
      moveHover.call(this, self);
    }
  };
  var handlerOut = function () {
    clearTimeout(this.timer);
    var self = this;

    this.closeTimer = setTimeout(function () {
      if ($(".js-search-results").hasClass("is-active")) return;
      $(self).hasClass("js-navi-new-list-categories")
        ? $naviOverlay.removeClass("is-active")
        : "";
      $(self).find(".js-navi-new-list-category").removeClass("can-show-menu");
      $(self).hasClass("can-show-menu")
        ? $(self).removeClass("can-show-menu")
        : "";
      mainJs.openCategories = false;
    }, 200);
    removeHover();
  };

  // $('.js-navi-list-promotion-item').hover(function () {
  //     moveHover.call(this, $(this));
  // }, removeHover);

  var $w = $(window),
    lastY = $w.scrollTop();

  $(window).scroll(function () {
    var currentPosition = $w.scrollTop();

    if (!mainJs.openCategories) {
      return (lastY = currentPosition);
    }
    if (currentPosition - lastY < -5) {
      var e = jQuery.Event("mouseout");

      $newCategories.trigger(e);

      $newCategoryItem.trigger(e);
    }
    lastY = currentPosition;
  });

  $newCategories.hover(handlerHover, handlerOut);
  $newCategoryItem.hover(handlerHover, handlerOut);
  allCategoriesButton.hover(function (e) {
    e.stopPropagation();
    e.preventDefault();
    $naviOverlay.removeClass("is-active");
  });
  $overlay.hover(function () {
    if (!$(this).is(".is-active")) return true;
  });

  $(".js-expert-article-button").on("click", function (e) {
    var $this = $(this),
      $article = $this.closest(".js-expert-article");

    if ($article.hasClass("is-active")) {
      $article.removeClass("is-active");
    } else {
      $article.addClass("is-active");
    }

    e.preventDefault();

    window.dispatchEvent(new Event("scroll"));
  });

  var $deliveryLabels = $(".js-delivery-label");

  $deliveryLabels.click(function () {
    var $this = $(this);

    if ($this.hasClass("is-read-only")) {
      return;
    }

    $deliveryLabels.removeClass("is-selected");
    $this.addClass("is-selected");
  });

  $deliveryLabels.each(function () {
    var $this = $(this);
    var $radio = $this.find('input[type="radio"]');

    if ($radio.is(":checked")) {
      $this.addClass("is-selected");
    }
  });
}
$(document).ready(function () {
  initCategoryBar();
  initStatic();
});

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

$(document).ready(function () {
  var tooltipTriggerList = [].slice.call(
    document.querySelectorAll('[data-bs-toggle="tooltip"]')
  );
  var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
    return new bootstrap.Tooltip(tooltipTriggerEl);
  });

  var heroSlider = $(".owl-news");
  var owlCarouselTimeout = 3500;
  $(".owl-news").owlCarousel({
    //autoplay: true,
    //loop: true,
    margin: 20,
    autoplayHoverPause: true,
    smartSpeed: 450,
    rtl: true,
    navText: [""],
    lazyLoad: true,
    responsive: {
      0: {
        stagePadding: 60,
        items: 1,
      },
      500: {
        stagePadding: 20,
        items: 2,
      },
      768: {
        dots: false,
        nav: true,
        items: 2,
      },
      1200: {
        dots: false,
        nav: true,
        items: 3,
      },
    },
  });

  $(".icon-search").click(function () {
    $(".search-wrapper").toggleClass("expand");
    $(this).toggleClass("close");
  });

  function resize() {
    var calculatePadding = parseInt($(".header").css("height"));
    $(".body-content").css({
      "padding-top": calculatePadding,
    });
  }
  $(document).ready(function () {
    resize();
  });
});

if ($(".owl-main-cat").length) {
  $(".owl-main-cat").owlCarousel({
    // autoplay: true,
    loop: false,
    rtl: true,
    nav: false,
    margin: 20,
    navText: [
      "<i class='fas fa-angle-left'></i>",
      "<i class='fas fa-angle-right'></i>",
    ],
    lazyLoad: true,
    responsive: {
      0: {
        stagePadding: 50,
        items: 2,
        dots: true,
      },
      500: {
        stagePadding: 60,
        items: 2,
        dots: false,
      },
      768: {
        stagePadding: 60,
        items: 3,
        dots: true,
      },
      991: {
        items: 4,
        dots: true,
      },
      1200: {
        dots: true,
        items: 5
      },
    },
  });
}
document.addEventListener('DOMContentLoaded', function () {
  const items = document.querySelectorAll('.msc-industry__item');
  const backgrounds = document.querySelectorAll('.msc-industry__bg');

  items.forEach(item => {
    item.addEventListener('mouseover', function () {
      const activeId = item.getAttribute('data-id');

      // Remove active class from all items and backgrounds
      items.forEach(i => i.classList.remove('active'));
      backgrounds.forEach(bg => bg.classList.remove('msc-industry__bg--active'));

      // Add active class to the hovered item and corresponding background
      item.classList.add('active');
      document.querySelector(`.msc-industry__bg[data-id="${activeId}"]`).classList.add('msc-industry__bg--active');
    });
  });
});