function SetImage(direction) { 
	if (direction == 'left'){
		if (currimg > 0){
			currimg--;
		}else{
			// loop back around
			currimg = imagefilelist.length-1
		}
	} else {
		if (currimg < imagefilelist.length-1){
			currimg++
		}else{
			// loop back around
			currimg = 0;
		}
	}
	showImage();
	//alert(imagelist[currimg].file);
 } 
 
  function resetImage(newidx){
 	currimg = newidx;
	showImage();
 }
 
 function showImage(){
	//document.imgform.stage.src = "images/gallery/"+imagelist[currimg].file+".jpg";
	// OR, if you use preloaded image
	document.imgform.stage.src = imagelist[currimg].img.src;
	document.imgform.stage.width = imagelist[currimg].w
	document.imgform.stage.height = imagelist[currimg].h
	// show caption
	document.getElementById("captiontxt").innerHTML = imagelist[currimg].ctext;
 }