/*
##########################################
#   $Dept: BBC Weather Centre $
#   $Desc: slide show tools and image library
#   $Revision: 1.3 $
#   $Date: 23/08/04 $
##########################################
*/
//
//::slideshow::
slideshowArray = new Array();

//5 pm
 function make17Activate() 
 	{ 
	webCam17.image = eval(webCam17.image); 
	webCam17.active = true; 
	}
 webCam17 = new slideshow("document.images['webcamtvc']", 1000, true, true)
	webCam17.add("/weather/webcam/images/tvcroof-17-00.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-04.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-08.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-12.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-16.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-20.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-24.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-28.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-32.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-36.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-40.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-44.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-48.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-52.jpg");
	webCam17.add("/weather/webcam/images/tvcroof-17-56.jpg");
////*
//please do not edit below this line!
////*
//create the slideshow objects for each of the slideshowArray members in 'this' applying property and method arguments. 
 function slideshow(image, defaultDelay, loop, preLoad) {
	this.image = image; 
	this.defaultDelay = defaultDelay;
	this.loop = loop;
	this.preLoad = preLoad;
	this.slide = new Array();
	this.currentSlide = 0;
	this.slideTimer = false;
	this.active = false;
	this.stopped = true;
	this.id = slideshowArray.length;
	slideshowArray[this.id] = this;
	this.add = slideAdd;
	this.changeSlide = slideChangeSlide;
	this.start = slideStart;
	this.stop = slideStop;
	this.next = slideNext;
	this.prev = slidePrev;
	this.autostart = slideAutoStart;
}
//start a slide show. i.e. onload="myShowRain.autostart(); return false;"
 function slideAutoStart () {
	this.image = eval(this.image); 
	this.active = true;
	this.start = true;
}
//if the current slide show is not active return, else if is active use the current shows delay property to set the timeout and change to the next slide.
 function slideChangeSlide() {
	if(!this.active) return;
	if(this.image.src != this.slide[this.currentSlide].src)
	this.image.src = this.slide[this.currentSlide].src;
	if(!this.stopped) this.slideTimer = setTimeout("slideshowArray[" + this.id + "].next()", this.slide[this.currentSlide].delay);
}
//add a new slide to the slide show placing it at the end of the slideshow's slide array.
 function slideAdd(src, delay) {
	if(typeof(delay) == 'undefined') delay = this.defaultDelay;
	this.slide[this.slide.length] = new slide(src, delay, this.preLoad)
}
//create and pre-load a new slide.
 function slide(src, delay, preLoad) {
	this.src = src;
	this.delay = delay;
	this.parent = parent;
	if(preLoad) {
		this.image = new Image();
		this.image.src = src;
	}
}
//play the slideshow through.
 function slideStart() {
	if(this.slideTimer) return;
	this.stopped = false;
	this.changeSlide();
}
//clear the current timeout and hence stop the slide show.
 function slideStop(){
	clearTimeout(this.slideTimer);
	this.slideTimer = false;
	this.stopped = true;
}
//advance to the next slide by incrementing this.currentSlide++.
//the slideshow has been set to loop so will go through all slideshowArray images, else it would normally stop at the last image. 
 function slideNext(){
	clearTimeout(this.slideTimer);
	this.slideTimer = false;
	this.currentSlide++;
	if(this.currentSlide >= this.slide.length) {
		if(!this.loop) {
			this.currentSlide = this.slide.length - 1;
			return;
		}
		this.currentSlide = 0;
	}
	this.changeSlide();
}
//return to the previous slide, similar to the looping procedure in the slideNext function. 
 function slidePrev() {
	clearTimeout(this.slideTimer);
	this.slideTimer = false;
	this.currentSlide--;
	if(this.currentSlide < 0) {
		if(!this.loop) {
			this.currentSlide = 0;
			return;
		}
		this.currentSlide = this.slide.length-1;
	}
	this.changeSlide();
}
//determine if slide is active, if not make it so in readiness for playing a show.
 function slideActivate() {
	this.image = eval(this.image); 
	this.active = true;
}
