// this represents the current img index for a slideshow on any given slideshow page
var curImgIndex = 1;

// this function increases the current index and if we go past the ending index, it 
// puts the cur index at the beginning index
function nextImage( endingIndex, imgNameFormat, imgNameExt )
{
	// increment the current index
	++curImgIndex;

	// loop back to the beginning index if we go past the last image in the slideshow
	if ( curImgIndex > endingIndex )
	{
		curImgIndex = 1;
	}

	// call a helper function to get the current img name and then change
	// the source of the image displayed on the page with that filename
	var curImgName = getImgName();
	document.curImage.src = imgNameFormat + curImgName + imgNameExt;
}

// this function decreases the current index and if we go below 1, it 
// puts the cur index at the last index
function prevImage( endingIndex, imgNameFormat, imgNameExt )
{
	// decrement the current index
	--curImgIndex;

	// loop back to the ending index if we go behind the first image in the slideshow
	if ( curImgIndex < 1 )
	{
		curImgIndex = endingIndex;
	}

	// call a helper function to get the current img name and then change
	// the source of the image displayed on the page with that filename
	var curImgName = getImgName();
	document.curImage.src = imgNameFormat + curImgName + imgNameExt;
}

// this function returns a filename left-padded with 0s given a current img number
function getImgName()
{
	// pad with two 0s if less than 10
	if ( curImgIndex < 10 )
	{
		return "00" + curImgIndex;
	}
	// pad with one 0 if greater than 9
	else if ( curImgIndex > 9 )
	{
		return "0" + curImgIndex;
	}
	// pad with no 0s if >= 100
	else
	{
		return curImgIndex;
	}
}