// Used to toggle the menu on small screens when clicking on the menu button
document.getElementById('mobile-menu').addEventListener('click', function() {
    var navbarLinks = document.getElementById('navbar-links');
    this.classList.toggle('active');
    navbarLinks.classList.toggle('active');
    });

//Controla los Slider
class TestimonialSlider {
    constructor(sliderElement) {
        this.slider = sliderElement;
        this.slides = this.slider.getElementsByClassName("testimonial-slide");
        this.dots = this.slider.getElementsByClassName("dot");
        this.slideIndex = 1;
        this.showSlides(this.slideIndex);
    }

    changeSlide(n) {
        this.showSlides(this.slideIndex += n);
    }

    currentSlide(n) {
        this.showSlides(this.slideIndex = n);
    }

    showSlides(n) {
        if (n > this.slides.length) { this.slideIndex = 1 }
        if (n < 1) { this.slideIndex = this.slides.length }

        for (let i = 0; i < this.slides.length; i++) {
            this.slides[i].style.display = "none";
        }

        for (let i = 0; i < this.dots.length; i++) {
            this.dots[i].className = this.dots[i].className.replace(" active", "");
        }

        this.slides[this.slideIndex - 1].style.display = "block";
        this.dots[this.slideIndex - 1].className += " active";
    }
}

let sliders = [];
document.addEventListener("DOMContentLoaded", function() {
    let sliderElements = document.getElementsByClassName("testimonial-slider");
    for (let i = 0; i < sliderElements.length; i++) {
        sliders.push(new TestimonialSlider(sliderElements[i]));
    }
});