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

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

// Slider
jQuery(document).ready(function() {
  jQuery('.our-doctors-section .owl-carousel').owlCarousel({
    loop: true,
    margin: 15,
    nav: true,
    navText: ["<i class='fa-solid fa-chevron-left'></i>", "<i class='fa-solid fa-chevron-right'></i>"], 
    dots: false,
    rtl: false,
    responsive: {
      0: { 
        items: 1 
      },
      600: { 
        items: 2 
      },
      992: { 
        items: 3 
      },
      1200: { 
        items: 4 
      }
    },
    autoplay: true,
  });
});

jQuery(document).ready(function() {
  jQuery('.blog-section .owl-carousel').owlCarousel({
    loop: true,
    margin: 15,
    nav: true,
    navText: ["<i class='fa-solid fa-chevron-left'></i>", "<i class='fa-solid fa-chevron-right'></i>"], 
    dots: false,
    rtl: false,
    responsive: {
      0: { 
        items: 1 
      },
      600: { 
        items: 2 
      },
      992: { 
        items: 3 
      },
      1200: { 
        items: 3 
      }
    },
    autoplay: true,
  });
});

document.addEventListener("DOMContentLoaded", () => {
  document.querySelectorAll(".main-banner .bnr-btm-count, .counter-section .counter-num").forEach(el => {
    const animal_clinic_text = el.innerText.trim();
    const animal_clinic_number = parseInt(animal_clinic_text);       // 84
    const animal_clinic_suffix = animal_clinic_text.replace(animal_clinic_number, ""); // K, +, etc.
    let animal_clinic_i = 0;

    el.innerText = "0" + animal_clinic_suffix;

    const t = setInterval(() => {
      animal_clinic_i++;
      el.innerText = animal_clinic_i + animal_clinic_suffix;
      if (animal_clinic_i >= animal_clinic_number) clearInterval(t);
    }, 15);
  });
});