var photoView; var captionBox; var photoIndex = 0; var photoImage; var btnNext; var btnPrev; var photoArray = new Array(); var captionArray = new Array(); var imageLinksArray = new Array(); function LoadPhotoBox(){ photoView = document.getElementById("photoLink"); captionBox = document.getElementById("photoCaption"); btnNext = document.getElementById("photoNext"); btnPrev = document.getElementById("photoPrevious"); if(photoView){ photoImage = document.createElement("img"); photoImage.src = photoArray[photoIndex]; photoImage.alt = ""; photoImage.id = "imageItem"; photoView.appendChild(photoImage); ToggleImage(); } } function PhotoNext(){ if(photoIndex < (photoArray.length - 1)){ photoIndex++; ToggleImage(); } return false; } function PhotoPrevious(){ if(photoIndex > 0){ photoIndex--; ToggleImage(); } return false; } function ToggleImage(){ if(photoArray.length > 0){ photoImage.src = photoArray[photoIndex]; if(imageLinksArray[photoIndex]){ photoView.href = imageLinksArray[photoIndex] } ToggleCaption(); toggleCountDisplay(); ToggleControls(); } return; } function ToggleControls(){ if(btnNext && btnPrev){ if(photoIndex == 0){ btnNext.src = "http://www.labour.org.nz/images/photobox_next_on.gif"; btnPrev.src = "http://www.labour.org.nz/images/photobox_previous_off.gif"; } else if(photoIndex == (photoArray.length -1)){ btnNext.src = "http://www.labour.org.nz/images/photobox_next_off.gif" btnPrev.src = "http://www.labour.org.nz/images/photobox_previous_on.gif"; }else{ btnNext.src = "http://www.labour.org.nz/images/photobox_next_on.gif" btnPrev.src = "http://www.labour.org.nz/images/photobox_previous_on.gif"; } } } function toggleCountDisplay(){ var photoCountDisplay = document.getElementById("photoCount"); if(photoCountDisplay){ photoCountDisplay.innerHTML = "Photo " + (photoIndex + 1) + " of " + photoArray.length; } return; } function ToggleCaption(){ if(captionBox && captionArray[photoIndex]){ captionBox.innerHTML = captionArray[photoIndex]; photoView.title = captionArray[photoIndex]; }else{ captionBox.innerHTML = ""; } }