jQuery(document).ready(function ($) {

  $(window).scroll(function () {
    if ($(this).scrollTop() > 100) {
      $(".back-to-top a").fadeIn();
    } else {
      $(".back-to-top a").fadeOut();
    }
  });

  $(".back-to-top a").click(function () {
    $("html, body").animate({ scrollTop: 0 }, 800);
    return false;
  });

  //slider swiper
  var fse_pet_shop_Slider = new Swiper(".fse-pet-shop-slider", {
    slidesPerView: 1,
    speed: 1000,
    loop: true,
    autoplay: {
      delay: 3000,
      disableOnInteraction: false,
    },
    pagination: {
      el: ".fse-pet-shop-pagination",
      clickable: true,
    },
    navigation: {
      nextEl: ".fse-pet-shop-button-next",
      prevEl: ".fse-pet-shop-button-prev",
    },
    grabCursor: true,
  });


});

document.addEventListener('DOMContentLoaded', function () {
  const fse_pet_shop_counters = document.querySelectorAll('.customer-no');
  fse_pet_shop_counters.forEach(function (counter) {
    const fse_pet_shop_target = parseInt(counter.textContent.replace(/\D/g, ''), 10); // base 10
    const fse_pet_shop_duration = 2000; // total fse_pet_shop_duration (ms)
    const fse_pet_shop_startTime = performance.now();

    function updateCounter(currentTime) {
      const elapsed = currentTime - fse_pet_shop_startTime;
      const progress = Math.min(elapsed / fse_pet_shop_duration, 1);
      const count = Math.floor(progress * fse_pet_shop_target);

      counter.textContent = count;

      if (progress < 1) {
        requestAnimationFrame(updateCounter);
      } else {
        counter.textContent = fse_pet_shop_target; // ensure final value
      }
    }

    requestAnimationFrame(updateCounter);
  });
});