Only a couple of more things and we are done for part 1. One thing we want to do is to cycle through the images as a user clicks through the forward or previous buttons. In order to do that we use the following case.

case "cycle_gallery":
if (args[1] == 'forw' && gallery_index != galleryArray.length - 1)
{
gallery_index++;
description_index++;
ajaxManager('load_page', galleryArray[gallery_index], 'galleryLYR');
ajaxManager('load_page', descriptionArray[description_index], 'captionLYR');
}
else if (args[1] == 'rev' && gallery_index != 0)
{
gallery_index--;
description_index--;