function imageItem(image_location) {
  this.image_item = new Image();
  this.image_item.src = image_location;
  this.getImageItemLocation = getImageItemLocation;
}
function getImageItemLocation() {
   return this.image_item.src;
}
function randNum(x, y) {
	var range = y - x + 1;
	return Math.floor(Math.random() * range) + x;
}

function SlideShow(imageDir, totalImages, place, random)
{
	this.imageDir = imageDir;
	this.totalImages = totalImages;
	this.place = place;
	this.random = random;
	this.imageNum = 0;
	this.imageArray = new Array();

	this.getNextImage = getNextImage;
	this.switchImage = switchImage;
	this.stopShow = stopShow;

	while (this.imageNum < this.totalImages)
		this.imageArray[this.imageNum++] = new imageItem(this.imageDir + this.imageNum + ".jpg");
}
function getNextImage()
{
	if (this.random)
		this.imageNum = randNum(0, this.totalImages-1);
	else
		this.imageNum = (this.imageNum+1) % this.totalImages;
	return this.imageArray[this.imageNum].getImageItemLocation();
}
function switchImage()
{
	document[this.place].src = this.getNextImage();
}
function stopShow()
{
	window.clearInterval(this.timerID);
}
function startShow(objName, interval)
{
	eval(objName).timerID = window.setInterval(objName+".switchImage()", interval);
}