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 veterinary_dogcare_Slider = new Swiper(".veterinary-dogcare-slider", {
    slidesPerView: 1,
    speed: 1000,
    autoplay: {
      delay: 3000,
      disableOnInteraction: false,
    },
    pagination: {
      el: ".veterinary-dogcare-pagination",
      clickable: true,
    },
    navigation: {
      nextEl: ".veterinary-dogcare-button-next",
      prevEl: ".veterinary-dogcare-button-prev",
    },
  });

  //projects-swiper
  var veterinary_dogcare_project_Slider = new Swiper(".project-section .projects-slider", {
    breakpoints: {
      0: {
        slidesPerView: 1,
        centeredSlides: false,
      },
      768: {
        slidesPerView: 2,
        centeredSlides: false,
      },
      992: {
        slidesPerView: 3,
        centeredSlides: true,
      }
    },
    autoplay: {
      delay: 3000,
      disableOnInteraction: false,
    },
    spaceBetween: 30,
    loop: true,
    navigation: {
      nextEl: ".projects-swiper-button-next",
      prevEl: ".projects-swiper-button-prev",
    },
  });

});


//service-swiper
  var veterinary_dogcare_project_Slider = new Swiper(".service-section .projects-slider .mySwiper", {
  spaceBetween: 30,
  navigation: {
    nextEl: ".projects-swiper-button-next",
    prevEl: ".projects-swiper-button-prev",
  },
  loop: true,
  breakpoints: {
    0: {
      slidesPerView: 1, // Mobile
    },
    600: {
      slidesPerView: 2, // Tablet +
    }
  }
});

// Sub-heading
jQuery(document).ready(function() {
  jQuery(".veterinary-dogcare-slider .slider-heading1").each(function() {
    var t = jQuery(this).text().trim();
    var splitT = t.split(" ");
    var newText = "";

    for (var i = 0; i < splitT.length; i++) {
      if (i === 1) { 
        // second word
        newText += "<span class='highlight-second'>" + splitT[i] + "</span> ";
      } else if (i === splitT.length - 1) { 
        // last word
        newText += "<span class='highlight-last'>" + splitT[i] + "</span> ";
      } else {
        newText += splitT[i] + " ";
      }
    }

    jQuery(this).html(newText.trim());
  });
});

