let slideIndex = 1; let i = 0; showSlides(slideIndex); // next/previous controls function plusSlides(n) { showSlides(slideIndex += n); } // thumbnail image controls function currentSlide(n) { showSlides(slideIndex = n); } // shuffles through slides function showSlides(n) { const slides = document.getElementsByClassName("slides"); if (n > slides.length) {slideIndex = 1} if (n < 1) {slideIndex = slides.length} for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } slides[slideIndex-1].style.display = "grid"; slides[slideIndex-1].style.gridTemplateColumns = "35% 65%"; slides[slideIndex-1].style.alignItems = 'center'; } // populates ad banner with logo images from coupon data, shows for 5 seconds, fades out for 3 function showAds(){ const randomImages = adImages[Math.floor(Math.random() * adImages.length)]; document.slide.src = randomImages; setTimeout(function(){ setTimeout(function(){ bannerAd.style.opacity = '1'; showAds(); }, 2500);// not showing for 2.5 seconds bannerAd.style.opacity = '0'; }, 8000);// showing for 8 seconds } // scrolls ads and checks for container sizes on page load window.addEventListener('load', () =>{ showAds(); detectScrollBar(); });