//Matt Browne (mhb) added caption
//www.cryer.co.uk ?? 2004 and www.brainerror.net ver 1.3 ?? June 7,2004
//were reference for the following Javascript slide show code
function changeOpac(opacity, id)
{
var object = document.getElementById(id).style;
object.opacity = (opacity / 100);
object.MozOpacity = (opacity / 100);
object.KhtmlOpacity = (opacity / 100);
object.filter = "alpha(opacity=" + opacity + ")";
}

function blendimage(divid, imageid, captionid, imagefile, caption, millisec)
{
	var speed = Math.round(millisec / 10);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	//mhb added
	document.getElementById(captionid).innerHTML = caption;
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;
	
	//fade in image
	for(i = 0; i <= 100; i++)
	{
	setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
	timer++;
	}
}

//use global variables (otherwise quote characters don't seem to work)
var futureImages;
var futureCaptions;

//mhb added:
//captionid = ID of div containing caption
//captions = array of captions
var slideCache = new Array();
function RunSlideShow(displaySecs,divid,imageid,captionid,imageFiles,captions)
{
	if (typeof imageFiles == "undefined") imageFiles = futureImages;
	if (typeof captions == "undefined") captions = futureCaptions;
	
	var imageSeparator = imageFiles.indexOf(";");
	var nextImage = imageFiles.substring(0,imageSeparator);
	var captionSeparator = captions.indexOf(";");
	var nextCaption = captions.substring(0,captionSeparator);
	
	changeOpac(0, imageid);
	blendimage(divid,imageid,captionid,nextImage,nextCaption,100);
	
	futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)+ ';' + nextImage;
	//mhb added
	futureCaptions = captions.substring(captionSeparator+1,captions.length)+ ';' + nextCaption;

	//mhb modified
	var param = 'RunSlideShow('+displaySecs+ ',"' + divid+'","'+imageid+'","'+captionid +'")';
	setTimeout(param, displaySecs*1000);
	
	// Cache the next image to improve performance.
	imageSeparator = futureImages.indexOf(";");
	nextImage = futureImages.substring(0,imageSeparator);
	//mhb added
	//nextCaption = futureCaptions.substring(0,captionSeparator);
	
	if (slideCache[nextImage] == null)
	{
	slideCache[nextImage] = new Image;
	slideCache[nextImage].src = nextImage;
	}
}	