/******* Do not edit this file *******
Simple Custom CSS and JS - by Silkypress.com
Saved: Aug 27 2026 | 12:19:39 */
document.addEventListener("DOMContentLoaded", function () {

    const wrappers = document.querySelectorAll(".xllm-wrapper");

    wrappers.forEach(function (wrapper) {

        const track = wrapper.querySelector(".xllm-track");

        if (!track) return;

        // Stop existing plugin animation
        track.style.animation = "none";
        track.style.transition = "none";

        let position = 0;
        let speed = 0.8;
        let groupWidth = 0;
        let animationFrame;

        function setupMarquee() {

            const groups = track.querySelectorAll(".xllm-group");

            if (groups.length < 2) return;

            // Width of one complete logo set
            groupWidth = groups[0].scrollWidth;

            position = 0;

            cancelAnimationFrame(animationFrame);
            animate();
        }

        function animate() {

            position -= speed;

            // Reset immediately without pause
            if (Math.abs(position) >= groupWidth) {
                position += groupWidth;
            }

            track.style.transform =
                "translate3d(" + position + "px, 0, 0)";

            animationFrame = requestAnimationFrame(animate);
        }

        // Wait for images to load so width is calculated correctly
        const images = track.querySelectorAll("img");
        let loadedImages = 0;

        function imageLoaded() {
            loadedImages++;

            if (loadedImages >= images.length) {
                setupMarquee();
            }
        }

        if (images.length === 0) {
            setupMarquee();
        } else {
            images.forEach(function (img) {

                if (img.complete) {
                    imageLoaded();
                } else {
                    img.addEventListener("load", imageLoaded);
                    img.addEventListener("error", imageLoaded);
                }

            });
        }

        // Recalculate on window resize
        window.addEventListener("resize", function () {
            clearTimeout(window.xllmResizeTimer);

            window.xllmResizeTimer = setTimeout(function () {
                setupMarquee();
            }, 200);
        });

    });

});