let currentIndex = 0; // Track the index of the currently displayed image function openLightbox(imageSrc, description, index) { currentIndex = index; setTimeout(function () { displayImageAtIndex(currentIndex); document.getElementById('lightbox').style.display = 'flex'; }, 250); } function closeLightbox() { document.getElementById('lightbox').style.display = 'none'; } function nextImage() { // Increment the index and display the next image currentIndex = (currentIndex + 1) % ; displayImageAtIndex(currentIndex); } function prevImage() { // Decrement the index and display the previous image currentIndex = (currentIndex - 1 + ) % ; displayImageAtIndex(currentIndex); } function displayImageAtIndex(index) { // Retrieve the image and description based on the index let images = document.querySelectorAll('.photo-img'); let descriptions = document.querySelectorAll('.overlay-content h2'); let imageSrc = images[index].src; let description = descriptions[index].innerText; // Update the lightbox content document.getElementById('lightbox-image').src = imageSrc; document.getElementById('download').href = imageSrc; document.getElementById('download').download = description + ' From Jacks.am.jpg'; document.getElementById('lightbox-description').innerHTML = '

' + description + '

'; }