function imageGallerySwap(galleryID, total, dir) { var imageImage = document.getElementById(galleryID + '_image') ; var imageCredit = document.getElementById(galleryID + '_credit') ; var imageCaption = document.getElementById(galleryID + '_caption') ; var currentImage = document.getElementById(galleryID + '_current') ; var x = parseInt(currentImage.value) ; var photo = 0 ; if ( dir == "next" ) { photo = x + 1 ; } else { photo = x - 1 ; } var thisImage = document.getElementById(galleryID + '_image_' + photo).value ; var thisCredit = document.getElementById(galleryID + '_credit_' + photo).value ; var thisCaption = document.getElementById(galleryID + '_caption_' + photo).value ; var thisWidth = document.getElementById(galleryID + '_width_' + photo).value ; var thisHeight = document.getElementById(galleryID + '_height_' + photo).value ; var thisFull = document.getElementById(galleryID + '_full_' + photo).value ; if ( thisCredit == "" ) { thisCredit = " " ; } else { thisCredit = "photo by " + thisCredit ; } if ( thisCaption == "" || !thisCaption ) thisCaption = " " ; imageImage.innerHTML = "\"\"/" ; imageCredit.innerHTML = thisCredit ; imageCaption.innerHTML = thisCaption ; var prevOn = document.getElementById(galleryID + '_prev_on') ; var prevOff = document.getElementById(galleryID + '_prev_off') ; var nextOn = document.getElementById(galleryID + '_next_on') ; var nextOff = document.getElementById(galleryID + '_next_off') ; if ( photo + 1 == total ) { prevOn.style.display = "" ; prevOff.style.display = "none" ; nextOn.style.display = "none" ; nextOff.style.display = "" ; } else if ( photo == 0 ) { prevOn.style.display = "none" ; prevOff.style.display = "" ; nextOn.style.display = "" ; nextOff.style.display = "none" ; } else { prevOn.style.display = "" ; prevOff.style.display = "none" ; nextOn.style.display = "" ; nextOff.style.display = "none" ; } currentImage.value = photo ; }