/* Louis W. Adams, Jr.; May 19, 2010 */

window.onload = initAll;

/* Allocate variable names for global scope album data. */
var currImg = 0;
var fileName= "";
var captionText = new Array("")

/* All album photos are sequenced using lower case letters at the end of their names.  Add to array to have more photos, but extend the alphabetical sequence shown here. */
var LCLetter = new Array(
    "a","b","c","d","e","f","g","h","i","j"
)

/* Initialize album data. */
function initAll() {
    if (document.getElementById) {
    
        /* This script only displays one set of images, and this statement loads that set when the script begins. */
        loadAlbum("CommunityGardens_");
        
        /* Display the previous photo in album when the "Back" button is clicked. */
    	document.getElementById("AlbumBack").onclick = function() {
    		newSlide(-1); 
    	}
    	
    	/* Display the next photo in album when the "Next" button is clicked. */
    	document.getElementById("AlbumNext").onclick = function() {
    		newSlide(1); 
    	}
        
    }
    else {
        alert("Sorry.  Either the browser is using an old version of JavaScript that won't work here, or security software is blocking it.");
	}
}

/* Display next or previous photo and caption on web page. */
function newSlide(direction) {
	var imgCt = captionText.length;

	currImg = currImg + direction;
	if (currImg < 0) {
		currImg = imgCt-1;
	}
	if (currImg == imgCt) {
		currImg = 0;
	}
    loadPhotoAndCaption();
}

/* Load photo image and caption onto web page. */
function loadPhotoAndCaption() {
	document.getElementById("AlbumPhoto").src = "Shared/Image/CommunityGardens/" + fileName + LCLetter[currImg] + ".jpg";
	document.getElementById("AlbumText").innerHTML = (currImg+1) + "/" + captionText.length + ":  " + captionText[currImg];        
}

function loadAlbum(selectAlbum) {
    currImg = 0;            // Reset to first image number for album.
    captionText = [];       // Reset caption array to empty.    
    fileName= selectAlbum;  // Prefix for image file names.

    /* Load new album data.  This is the only place in this script to specify album information. Case order is unimportant. */

    captionText[0]= "W.O. Ezell Marker on W.O. Ezell Blvd., May 2010.<br />Photo by Henry Pittman.";
    captionText[1]= "Closeup of marker, April 2008.<br />Photo by Henry Pittman.";
    captionText[2]= "Nearby Spot of Pride sign, March 2006.<br />Photo by Henry Pittman.";
    captionText[3]= "Claude Sherrill Garden on East Main St., April 2009.<br />Photo by Henry Pittman.";
    captionText[4]= "Closeup of marker, March 2009.<br />Photo by Henry Pittman.";
            
    loadPhotoAndCaption();
}