// Set up variables
var myImages = 0;
var myPath = "images/";
var myImageList = "";
var myCurrentImage = 0;

function swapImage(theImage){
		document.getElementById("myImage").src = myPath+myImageList[theImage];
		myCurrentImage = theImage;	
}

function previousImage(){
	if(myCurrentImage == 0){
		myCurrentImage = myImageList.length-1;
	} else {
		myCurrentImage = myCurrentImage - 1;
	}
	
	swapImage(myCurrentImage);
}

function nextImage(){
	if(myCurrentImage == myImageList.length-1){
		myCurrentImage = 0;
	} else {
		myCurrentImage = myCurrentImage + 1;
	}
	
	swapImage(myCurrentImage);
}

function init(path){
	if(path){
		myPath = path;
	}
	
	if(myImages.length){
		myImageList = myImages.split(",");
		swapImage(myCurrentImage);
	} else {
		document.write("There are no images to display.");	
	}
}