// JavaScript Document
var FWSslideshow = {	
 'interval':3000,
 'intervals':{'slow':6000,'medium':3000,'fast':1500},
 'randomDisplay':false,
 'imageDir':false,
 'images':Array(),
 'orderIndex':0,
 'imageOrder':Array(),
 'container':false
};

FWSslideshow.setSpeed = function (speed) {
	speed = this.intervals[speed] ? this.intervals[speed] : 3000
	this.interval = speed;
}

FWSslideshow.addImage = function (src) {
	var i = this.images.length;
	this.images[i] = new Image();
	this.images[i] = src;
	this.imageOrder[i] = i;
}

FWSslideshow.next = function () {
	if (this.orderIndex + 1 == this.images.length) {
		this.orderIndex = 0;
	}
	else {
		this.orderIndex++;
	}
	return this.images[this.imageOrder[this.orderIndex]];
}

FWSslideshow.prev = function (src) {
	if (this.orderIndex == 0) {
		this.orderIndex = this.images.length;
	}
	else {
		this.orderIndex--;
	}
	return this.images[this.imageOrder[this.orderIndex]];
}

FWSslideshow.switchImage = function (dir, place) {
	if (place) {
		this.container = document.getElementById(place);
	}
	else if (dir < 0) {
		this.container.src = this.prev();
	}
	else {
		this.container.src = this.next();
	}
	var recur_call = "FWSslideshow.switchImage()";
	timerID = setTimeout(recur_call, this.interval);
}

FWSslideshow.randomize = function () {
	// shuffle the order of the imageOrder array of indexes
}