// Scroll to Top
window.onscroll = function() {
  const dropshipping_shop_button = document.querySelector('.scroll-top-box');
  if (dropshipping_shop_button) {
    if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
      dropshipping_shop_button.style.display = "block";
    } else {
      dropshipping_shop_button.style.display = "none";
    }
  }
};

const scrollTopLink = document.querySelector('.scroll-top-box a');
if (scrollTopLink) {
  scrollTopLink.onclick = function(event) {
    event.preventDefault();
    window.scrollTo({ top: 0, behavior: 'smooth' });
  };
}

/*------------------------------------------------
              Homepage slider
------------------------------------------------*/
document.addEventListener("DOMContentLoaded", function () {
  const swiperContainer = document.querySelector(".disinfection-swiper");
  if (swiperContainer) {
    var disinfection_Slider = new Swiper(swiperContainer, {
      slidesPerView: 1,
      speed: 1000,
      autoplay: false,
      navigation: {
        nextEl: ".disinfection-swiper-button-next",
        prevEl: ".disinfection-swiper-button-prev",
      },
      loop: true,
      on: {
        init: function () {
          disinfection_updateSlideNumbers(this);
        },
        slideChange: function () {
          disinfection_updateSlideNumbers(this);
        },
      },
    });

    function disinfection_updateSlideNumbers(swiper) {
      var realSlides = swiper.el.querySelectorAll('.swiper-slide:not(.swiper-slide-duplicate)');
      var total = realSlides.length;
      var current = swiper.realIndex + 1;
      var next = (current % total) + 1;

      var slideCurrent = document.querySelector('.slide-current');
      var slideNext = document.querySelector('.slide-next');

      if (slideCurrent) slideCurrent.textContent = ("0" + current).slice(-2);
      if (slideNext) slideNext.textContent = ("0" + next).slice(-2);
    }
  }
});

// our services
jQuery(document).ready(function() {
  jQuery('.service-section .owl-carousel').owlCarousel({
    loop: true,
    margin: 20,
    nav: true,
    dots: false,
    rtl: false,
    responsive: {
    0: { 
      items: 1 
    },
    600: { 
      items: 2 
    },
    767: { 
      items: 2
    },
    1000: { 
      items: 3
    },
    1200: { 
      items: 4
    }
  },
    autoplay: false,
  });
});