// SERVICE SLIDER JS

var swiper = new Swiper(".myService", {
    slidesPerView: 4,
    spaceBetween: 22,
    loop: true,
    // autoplay: {
    //     delay: 3000, 
    //     disableOnInteraction: false, 
    // },
    navigation: {
        nextEl: ".service-button-next",
        prevEl: ".service-button-prev",
    },
    speed: 1000,
    breakpoints: {
        1550: {
            slidesPerView: 4,
            spaceBetween: 22,
        },
        1400: {
            slidesPerView: 3,
            spaceBetween: 22,
        },
        1200: {
            slidesPerView: 3,
            spaceBetween: 22,
        },
        992: {
            slidesPerView: 2,
            spaceBetween: 22,
        },
        768: {
            slidesPerView: 2,
            spaceBetween: 20,
        },
        200: {
            slidesPerView: 1,
        }
    }
});

// TESTIMONIAL SLIDER JS

var swiper = new Swiper(".myTestimonial", {
    slidesPerView: 2,
    spaceBetween: 50,
    loop: true,
    // autoplay: {
    //     delay: 3000, 
    //     disableOnInteraction: false, 
    // },
    navigation: {
        nextEl: ".testi-button-next",
        prevEl: ".testi-button-prev",
    },
    speed: 1000,
    breakpoints: {
        1200: {
            slidesPerView: 2,
            spaceBetween: 50,
        },
        992: {
            slidesPerView: 1,
            spaceBetween: 20,
        },
        768: {
            slidesPerView: 1,
            spaceBetween: 20,
        },
        200: {
            slidesPerView: 1,
        }
    }
});

// QUALITY SLIDER JS

var swiper = new Swiper(".myQuality", {
    slidesPerView: 11,
    spaceBetween: 20,
    loop: true,
    // autoplay: {
    //     delay: 3000, 
    //     disableOnInteraction: false, 
    // },
    navigation: {
        nextEl: ".quality-button-next",
        prevEl: ".quality-button-prev",
    },
    speed: 1000,
    breakpoints: {
        1550: {
            slidesPerView: 11,
            spaceBetween: 20,
        },
        1400: {
            slidesPerView: 9,
            spaceBetween: 20,
        },
        1200: {
            slidesPerView: 7,
            spaceBetween: 20,
        },
        992: {
            slidesPerView: 6,
            spaceBetween: 20,
        },
        768: {
            slidesPerView: 4,
            spaceBetween: 20,
        },
        200: {
            slidesPerView: 2,
        }
    }
});

// FAQ SLIDER JS

var swiper = new Swiper(".myFaq", {
    slidesPerView: 3,
    spaceBetween: 0,
    loop: true,
    centeredSlides: false,
    navigation: {
        nextEl: ".faq-button-next",
        prevEl: ".faq-button-prev",
    },
    speed: 800,
    on: {
        init: function () {
            setFirstVisibleActive(this);
        },
        slideChangeTransitionStart: function () {
            setFirstVisibleActive(this);
        },
    },
});

function setFirstVisibleActive(swiper) {
    swiper.slides.forEach((slide) => {
        slide.classList.remove("active-slide");
    });

    const firstVisibleIndex = swiper.activeIndex;
    const firstSlide = swiper.slides[firstVisibleIndex];
    if (firstSlide) {
        firstSlide.classList.add("active-slide");
    }
}

// COUNTER JS

jQuery(window).scroll(startCounter);
function startCounter() {
    if (jQuery(window).scrollTop() > 1200) {
        jQuery(window).off("scroll", startCounter);
        jQuery('.animate-count').each(function () {
            var $this = jQuery(this);
            jQuery({ Counter: 0 }).animate({ Counter: $this.text() }, {
                duration: 5000,
                easing: 'swing',
                step: function () {
                    $this.text(Math.ceil(this.Counter));
                }
            });
        });
    }
}




// jQuery(window).scroll(startCounter);
// function startCounter() {
//     if (jQuery(window).scrollTop() > 1200) {
//         jQuery(window).off("scroll", startCounter);
//         jQuery('.animate-count-1').each(function () {
//             var $this = jQuery(this);
//             jQuery({ Counter: 0 }).animate({ Counter: $this.text() }, {
//                 duration: 5000,
//                 easing: 'swing',
//                 step: function () {
//                     $this.text(Math.ceil(this.Counter));
//                 }
//             });
//         });
//     }
// }

// LAYER BASED ANIMATION

// if (window.innerWidth > 991) {
//   gsap.registerPlugin(ScrollTrigger);

//   const sections = document.querySelectorAll(".case-studies-box");

//   sections.forEach((panel, i) => {
//     ScrollTrigger.create({
//       trigger: panel,
//       start: "top top",
//       pin: true,
//       pinSpacing: false,
//       scrub: true,
//       onEnter: () => panel.classList.add("active"),
//       onLeaveBack: () => panel.classList.remove("active"),
//       zIndex: sections.length - i,
//     });

//     gsap.fromTo(
//       panel,
//       { yPercent: 100 },
//       {
//         yPercent: 0,
//         scrollTrigger: {
//           trigger: panel,
//           start: "top bottom",
//           end: "top top",
//           scrub: true,
//         },
//       }
//     );
//   });
// }

// RESPONSIVE MENU ENTRY JS

jQuery('.ham-menu a').click(function(){
	jQuery('.responsive-menu').addClass('active');
    jQuery('body').addClass('stop-scroll');
});

// RESPONSIVE MENU EXIT JS

jQuery('.respon-cross a').click(function(){
	jQuery('.responsive-menu').removeClass('active');
    jQuery('body').removeClass('stop-scroll');
});

// RESPONSIVE MENU UL TOGGLE JS

jQuery(document).ready(function () {
    jQuery('.responsive-links ul li > a').click(function (e) {
        if (jQuery(this).siblings('ul').length > 0) {
            e.preventDefault();
            e.stopPropagation();
            
            jQuery('.responsive-links ul li > a').not(this).siblings('ul').slideUp();
            jQuery('.responsive-links ul li > a').not(this).parent().removeClass('active');

            jQuery(this).siblings('ul').slideToggle();
            jQuery(this).parent().toggleClass('active');
        }
    });
});

// QUERY FORM ENTRY JS

jQuery('.package-box .package-content .web-btn').click(function(){
	jQuery('.query-form-sec').addClass('active');
    jQuery('body').addClass('stop-scroll');
});

// QUERY FORM MENU EXIT JS

jQuery('.query-cross a').click(function(){
	jQuery('.query-form-sec').removeClass('active');
    jQuery('body').removeClass('stop-scroll');
});


