// arrays using album number as the index for album information
// album values will be set in ja s insert before album in web page
var displayed = new Array (); // picture being sidplayed
var pictures = new Array (); // number of pictures in album

function changeImage (album, delta) {
// receive album and +/- (direction) ie (0, "+")
// alert ("1.  album = " + album + " and delta = " + delta); // debug

// save the index of the present picture/link
var oldindex = displayed[album];

	if (delta == "-") { // previous picture
		if(displayed[album] == 1) {
		displayed[album] = pictures[album]; // last picture
		}
		else {
		displayed[album]--;
		}
	}
	else if (delta == "+") { // next picture
		if(displayed[album] == pictures[album]) {
		displayed[album] = 1; // first picture
		}
		else {
		displayed[album]++;
		}
	}

// alert ("2.  (existing pic) oldindex = " + oldindex + " and (new pic) displayed[album] = " + displayed[album]); // debug

// create objects for the title, image, old link, and new link 
var title = document.getElementById ('A'+album+'Title');
var image = document.getElementById ('A'+album+'Image');
var oldlinkn = document.getElementById ('A'+album+'Link'+oldindex);
var newlinkn = document.getElementById ('A'+album+'Link'+displayed[album]);
var newhref = document.getElementById ('A'+album+'HREF'+displayed[album]);
// alert ("3.  image.src = " + image.src); // debug

// change the title of the picture
title.style.fontSize = "11pt";
title.style.fontWeight = "bold";
title.style.color = "red";
title.innerHTML = newhref.innerHTML;
// alert ("4.  newhref.href = " + newhref.href); // debug

// change the image source

var nexturl = newhref.href;
// images have to be in the folder or sub-folder of the page
nexturl = nexturl.replace (/cgi-scripts/i, 'WebPages');
nexturl = nexturl.replace (/Archives.+?page=/i, 'UploadedFiles/');
nexturl = nexturl.replace (/&file=/i, '/');
// alert ("5.  nexturl = " + nexturl); // debug
// any reference to src kills the FirFox browser js
image.src = nexturl;
// alert ("6.  image.src = " + image.src); // debug

// change the link number colors in the list of links
oldlinkn.style.fontSize = "10pt";
oldlinkn.style.fontWeight = "normal";
oldlinkn.style.color = "black";
newlinkn.style.fontSize = "11pt";
newlinkn.style.fontWeight = "bold";
newlinkn.style.color = "red";

}

