currentImage=0;

function showImage(x) {
	if (x>=fadeimages.length) {
		alert("You are viewing the last image");
		if (x==fadeimages.length) return true;
		return false
	} else if (x<0) {
		alert("You are viewing the first image");
		return false
	}
	for (tmp=0;tmp<fadeimages.length;tmp++) {
		if (x==tmp) {
			newSrc="background_images/currentImage.gif";
		} else {
			newSrc="background_images/otherImage.gif";
		}
		MM_findObj("navBox"+tmp).src=newSrc;
	}
	$("#mainImage").attr("src",fadeimages[x]);
	$("#imageCaption").html(exifcaption[x]);
	$(".imageNav").removeClass("activeSlide");
	$("#imageNav"+Math.floor(x+1)).addClass("activeSlide");
	currentImage=x;
	MM_findObj("imageIndex").innerHTML=Math.floor(currentImage+1);
	return true;
}

function showNextImage(d) {
	if (showImage(currentImage+d)==false) return;
	o=MM_findObj("imageNav"+(currentImage+1));
	if (o.style) o=o.style;
	if (d==1)  {
		whichToHide=firstImage;
	} else {
		whichToHide=lastImage;
	}
	if (o.display=="none") {
		whichToHide=MM_findObj("imageNav"+Math.floor(whichToHide));
		if (whichToHide.style) whichToHide=whichToHide.style;
		whichToHide.display="none";
		o.display="";
		lastImage+=d;
		firstImage+=d;
	}
}