$(document).ready(function () { let currentSlide = 0; let slides; let slideCount = 0; let totalSlides; function showSlide(index) { slides.removeClass("active"); slides.eq(index).addClass("active"); } function startSlider() { slides = $(".slide"); totalSlides = slides.length; if (totalSlides > 0) { showSlide(currentSlide); let interval = setInterval(function () { currentSlide = (currentSlide + 1) % totalSlides; showSlide(currentSlide); slideCount++; // If all slides shown once, close popup and clear interval if (slideCount >= totalSlides) { setTimeout(function () { $("#popuphome").fadeOut(); }, 1000); // optional delay before closing clearInterval(interval); } }, 3000); } } // Show popup and start slider on homepage if (window.location.pathname === '/' || window.location.pathname.toLowerCase() === '/home') { setTimeout(function () { $("#popuphome").fadeIn(); startSlider(); }, 3000); } // Close popup manually $(window).click(function (event) { if ($(event.target).hasClass("popup")) { $(".popup").fadeOut(); } }); $(".close").click(function () { $(this).closest(".popup").fadeOut(); }); }); // Show the organization popup function orgpopup() { popupfun('#orgpopup'); } function popupfun(popupId) { $(popupId).fadeIn(); // Hide popup after 5 seconds setTimeout(function () { $(popupId).fadeOut(); }, 9000); } function closePopup(popupId) { $(popupId).fadeOut(); }