function CacheImage(ImageSource) { // Turns the string into an image object
	var ImageObject = new Image();
	ImageObject.src = ImageSource;
	return ImageObject;
}

function ShowSlide(Direction) {
	if (SlideReady) {
		NextSlide = CurrentSlide + Direction;
		// This will disable the buttons (IE-only)
			document.SlideShow.Previous.disabled = (NextSlide == 0);
			document.SlideShow.Next.disabled = (NextSlide == (Slides.length-1));    
	if ((NextSlide >= 0) && (NextSlide < Slides.length)) {
			document.images['Screen'].src = Slides[NextSlide].src;
			document.getElementById("captxt").src=(Captions[NextSlide]);
			CurrentSlide = NextSlide++;
				if (Direction == 1) CacheNextSlide();
		}
		return true;
	}
}

function Download() {
	if (Slides[NextSlide].complete) {
		SlideReady = true;
		self.defaultStatus = Message;
	}
	else setTimeout("Download()", 100); // CHECKS DOWNLOAD STATUS EVERY 100 MS
	return true;
}

function CacheNextSlide() {
	if ((NextSlide < Slides.length) && (typeof Slides[NextSlide] == 'string'))
		{ // Only caches the images once
			SlideReady = false;
				self.defaultStatus = 'Downloading next picture...';
		Slides[NextSlide] = CacheImage(Slides[NextSlide]);
		Download();
	}
	return true;
}

function StartSlideShow() {
	CurrentSlide = -1;
	Slides[0] = CacheImage(Slides[0]);
	SlideReady = true;
	ShowSlide(1);
}

