function stickyHeader() {
    if ($('.menubar').length) {
        var strickyScrollPos = 100;
        if ($(window).scrollTop() > strickyScrollPos) {
            $('.menubar').addClass('stricky-fixed');
        } else if ($(this).scrollTop() <= strickyScrollPos) {
            $('.menubar').removeClass('stricky-fixed');
        }
    };
}

jQuery(window).on('scroll', function () {
    (function ($) {
        stickyHeader();
    })(jQuery);
});

if ($(".navigation").length) {
    $(".navigation .navbar button").on("click", function () {
        $(".navigation .menu").slideToggle();
        $(this).toggleClass('open');
        return false;
    });
    $(".navigation .cs-submenu").children("a").append(function () {
        return '<button class="dropdown-expander" title="dropdown"><svg width="16px" height="16px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g  stroke-linecap="round" stroke-linejoin="round"></g><g > <path fill-rule="evenodd" clip-rule="evenodd" d="M4.29289 8.29289C4.68342 7.90237 5.31658 7.90237 5.70711 8.29289L12 14.5858L18.2929 8.29289C18.6834 7.90237 19.3166 7.90237 19.7071 8.29289C20.0976 8.68342 20.0976 9.31658 19.7071 9.70711L12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L4.29289 9.70711C3.90237 9.31658 3.90237 8.68342 4.29289 8.29289Z" fill="currentColor"></path> </g></svg></button>';
    });

}

if (document.documentElement.clientWidth < 1023) {
    $(".navigation .menu .dropdown-expander").on("click", function () {
        $(this).parent().parent().children(".cs-dropdown").slideToggle();
        console.log($(this).parents("li"));
        console.log($(this).parents().children(".dropdown-expander").toggleClass("rotated"));
        return false
    })
    $(document).click(function (e) {
        if (!$(e.target).closest('.navigation .navbar button').length) {
            $('.navigation .menu').stop(true).slideUp();
            $(".navigation .navbar button").removeClass('open');

        }
    });
}

// Initialize WOW.js
new WOW({
    animateClass: 'animated',
    offset: 100,
    mobile: false
}).init();

document.addEventListener("DOMContentLoaded", function () {
    const serviceColumns = document.querySelectorAll(".services-column");

    serviceColumns.forEach(column => {
        const listItems = column.querySelectorAll(".service-list li");
        const readMoreBtn = column.querySelector(".read-more-btn");

        if (!readMoreBtn || listItems.length <= 5) return; // safety check

        // Hide items after the 5th one
        listItems.forEach((li, index) => {
            if (index >= 5) {
                li.classList.add("d-none");
            }
        });

        // set initial state
        readMoreBtn.setAttribute("data-expanded", "false");
        readMoreBtn.textContent = "View More";

        // Toggle logic
        readMoreBtn.addEventListener("click", function () {
            const isExpanded = readMoreBtn.getAttribute("data-expanded") === "true";

            listItems.forEach((li, index) => {
                if (index >= 5) {
                    li.classList.toggle("d-none", isExpanded); 
                }
            });

            // Update button text & state
            readMoreBtn.textContent = isExpanded ? "View More" : "Show Less";
            readMoreBtn.setAttribute("data-expanded", (!isExpanded).toString());
        });
    });
});



var testSlider = new Swiper(".testSlider", {
    rewind: true,
    navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev",
    },
    breakpoints: {
        640: {
            slidesPerView: 1,
            spaceBetween: 25,
        },
        768: {
            slidesPerView: 1,
            spaceBetween: 25,
        },
        1024: {
            slidesPerView: 2,
            spaceBetween: 25,
        },
    },
});
