// Keeps track of what image is being shown var currentImage = 0; // Used for controlling prev/next buttons / preloader var numberOfImages = galleryArray.length - 1; // Preload the images in imagesArray function preLoadImages(){ for(i=0; i<= numberOfImages; i+1){ imageObj = new Image(); imageObj.src = galleryArray[i][0]; } } // Show the previous image in imagesArray, loop to last image if currentImage is the first image function prevImage(){ document.getElementById('gallery_large').src = 'loading.gif'; if (currentImage == 0){ whichImage = galleryArray.length - 1; }else{ whichImage = currentImage-1; } document.getElementById('gallery_large').src = galleryArray[whichImage][0]; document.getElementById('image_header_txt').innerHTML = galleryArray[whichImage][1]; document.getElementById('image_description').innerHTML = galleryArray[whichImage][2]; currentImage = whichImage; } // Show the next image in galleryArray, loop to the first image if currentImage is the last image function nextImage(){ document.getElementById('gallery_large').src = 'loading.gif'; if (currentImage == galleryArray.length - 1){ whichImage = 0; }else{ whichImage = currentImage+1; } document.getElementById('gallery_large').src = galleryArray[whichImage][0]; document.getElementById('image_header_txt').innerHTML = galleryArray[whichImage][1]; document.getElementById('image_description').innerHTML = galleryArray[whichImage][2]; currentImage = whichImage; } // Show the big image for the clicked thumbnail function swapImage(whichImage){ document.getElementById('gallery_large').src = 'loading.gif'; document.getElementById('gallery_large').src = galleryArray[whichImage][0]; document.getElementById('image_header_txt').innerHTML = galleryArray[whichImage][1]; document.getElementById('image_description').innerHTML = galleryArray[whichImage][2]; currentImage = whichImage; }