var current_image=0;
var total_images=eval(image.length-1);

var magnified=0;

function changeimage(x,y) {
// x (required) is a non-negative integer; y (optional) is either '+' or '-'
// if only x is given, will go to image[x]; if x and y, will go to image[current_image±x]
	
	// document.getElementById('message').innerHTML="else";
	
	// check if we're adding or subtracting
	if (y=="+") {
		x=eval(current_image+x);
	} else if (y=="-") {
		x=eval(current_image-x);
	}

	if (typeof image[x] == "undefined") {
	// quit if an undefined image is requested by a bad link
		return
	}

	// change the image, title, and description
	document.images['image'].src				= image[x];
	document.images['image'].alt				= title[x];
	document.getElementById('title').innerHTML	= title[x];
	document.getElementById('descr').innerHTML	= descr[x];
	
	// let us know how many pics there are and which we're looking at
	document.getElementById('numberoutof').innerHTML="&nbsp;"+(x+1)+" of "+(total_images+1)+"&nbsp;";

	if (x > 0) {
		document.getElementById('prev').innerHTML="&laquo; Previous";

		// preload previous image
		var preload = new Image(); 
		preload.src = image[x-1];
	} else {
		document.getElementById('prev').innerHTML="";
	}

	if (x < total_images) {
		document.getElementById('next').innerHTML="Next &raquo;";
		
		// preload next image
		var preload = new Image(); 
		preload.src = image[x+1];
	} else {
		document.getElementById('next').innerHTML="";
	}
	
	current_image=x;
}

// load first image when page opens up
function init() { changeimage(0); }
window.onload = init; 
