function slideshow(containerId, imageId, imageArray, pauseDuration, objectName) {
	// Fetch the elements
	this.bg = document.getElementById(containerId);
	this.img = document.getElementById(imageId);
	this.pause = pauseDuration;

	// We also need to know the object name, to get around the fact that JS doesn't use 'this' properly in setTimeout
	this.objectName = objectName;

	// Set the starting opacity
	this.opacity = 100;

	// Set up an array of images
	this.images = imageArray;
	this.noImages = this.images.length;

	// Preload the images
	this.preload = new Array();
	for(i=0; i<this.noImages; i++) {
		this.preload[i] = new Image();
		this.preload[i].src = this.images[i];
	}

	// Set the start images
	this.imgno = 0;
	this.bgimgno = 0;
	if(this.noImages > 1) {
		this.bgimgno = 1;
	}

	// Set the slideshow to run
	setTimeout(this.objectName + '.run()', this.pause);

	// Function to actually run the slideshow
	this.run = function() {
		// Set the two source images
		this.bg.style.backgroundImage = "url('" + this.preload[this.bgimgno].src + "')";
		this.img.src = this.preload[this.imgno].src;

		// Fade the foreground image to show the background through
		this.img.style.opacity = this.opacity/100;
		this.img.style.filter = 'alpha(opacity=' + this.opacity + ')';

		// Decrease the opacity
		this.opacity--;

		// If the image has completely faded, move the images and start again
		if(this.opacity == 0) {
			// Reset the opacity
			this.opacity = 100;

			// Increment the images
			if(this.imgno < this.noImages - 1) {
				this.imgno++;
			} else {
				this.imgno = 0;
			}

			if(this.bgimgno < this.noImages - 1) {
				this.bgimgno++;
			} else {
				this.bgimgno = 0;
			}
			
			// Set up this function to run again after a pause
			setTimeout(this.objectName + '.run()', this.pause);
		} else {
			// Set up this function to run again very soon
			setTimeout(this.objectName + '.run()', 10);
		}
	}
}