That works, but it really kind of much bigger and uglier than needed.
Try something like this:
Code:
var MINSLIDE = 0;
var MAXSLIDE = 2; // adjust those as needed
var curSlide = MINSLIDE;
function moveSlide( byWhat )
{
curSlide += byWhat;
if ( curSlide > MAXSLIDE ) { curSlide = MINSLIDE; }
else if ( curSlide < MINSLIDE ) { curslide = MAXSLIDE; }
document.getElementById("img1") = "images/slide" + curSlide + ".png";
}
And now, instead of calling
moveToNextSlide() or
moveToPreviousSlide() you call
moveSlide(1) and
moveSlide(-1).
And the beauty of this is that you can even call
moveSlide(0) to start everything up with the first slide.
Oh...and this works whether the slides are number 0 through N or 1 through N. Or even 73 through 122, for that matter.