
// JavaScript Slideshow

var QUANTITY = 9;	// modify this value to set the number of pictures in the slideshow
var INTERVAL = 5000;	// modify this value to set the delay (in milliseconds) between slide changes

//////////////////////////////////

var W3CDOM = (document.createElement && document.getElementsByTagName);

//////////////////////////////////

// GENERIC ONLOAD EVENT HANDLER
function addOnLoadEvent(pFunction) {
	var old_event = window.onload;
	window.onload = (typeof window.onload != 'function') ? pFunction : function () { old_event(); pFunction(); };
}

//////////////////////////////////

var JSSLIDESHOW = {
	index:1,
	slides: new Array(QUANTITY),

	initialise:	function () {
				this.slide = document.getElementById('slideshow').getElementsByTagName('IMG')[0];
				for (var i = 0; i < this.slides.length; i++) {
					this.slides[i] = new Image();
					this.slides[i].src = this.slide.src.replace(/\d+(\.jpg)$/i, (i + 1) + '$1');
				}
				this.setTimer();
			},

	setTimer:	function () {
				setTimeout('JSSLIDESHOW.swap();', INTERVAL);
			},

	swap:		function () {
				if (this.index == this.slides.length) this.index = 0;
				this.slide.src = this.slides[this.index++].src;
				this.setTimer();
			}
};

//////////////////////////////////

function addSlideshow() {
	if (!W3CDOM) return;
	JSSLIDESHOW.initialise();
}

//////////////////////////////////

addOnLoadEvent(addSlideshow);

// end of file