/***************************************************************************
	Deck - Deck of images object.
	
	Lets you easly swap an image with one of the images in its array. Useful 
	for situations where you have one image that is used to preview many 
	images of the same size. 
	
	Originaly created for an image gallery where the thumbnails changed the 
	Deck image.

	Constructor Parameters:
		p_img_name	- The ID of the image we're going to uses to swap.
		p_default_img_src - the SRC of the image to swap back to by default.
	
	Version:
		v1.1, Friday, 15 August 2003 - modified so it doesn't precache the images for forwindsgallery.com.au
		v0.1, Thursday, 15 August 2002
	
	Requires:
		
	Author:
		Alexander Whillas

	Copyright (C) 2002 Taylor Square Designs ( http://www.tsd.net.au/ )
***************************************************************************/
function Deck (p_img_name, p_default_img_src) {
	// Array to hold all the images.
	this.images = new Array();
	// Get a handle on the image we'll uses to swap with.
	eval("this.imgObj = document." + p_img_name); 
	// If we're given a default image to uses, preload and store it...
	if (p_default_img_src) {
		this.default_img = new Image();
		this.default_img.src = p_default_img_src;
	}
	return this;
}

// Given a variable number of image SRCs it creates (preloads) the images and
// adds them to the internal image array reference.
// Aug.2003 - Modifed so it doesn't pre-cache images, just stores the image SRC's
Deck.prototype.addImages = function (p_image_src) {
	var newImg;
	if (Deck.prototype.addImages.arguments)
		for (var i = 0; i <= Deck.prototype.addImages.arguments.length; i++) {
			/*	ARBW Aug.2003
			newImg = new Image();
			newImg.src = Deck.prototype.addImages.arguments[i];
			this.images[this.images.length] = newImg;
			*/
			this.images[this.images.length] = Deck.prototype.addImages.arguments[i];
		}
}

// Swap in the image in the internal array that has the given index number + 1.
// This might have excesive error checking :)
Deck.prototype.show = function (p_img_index) {
	if (p_img_index > 0 && p_img_index < this.images.length) {
		//this.imgObj.src = this.images[p_img_index - 1].src;	ARBW Aug.2003
		this.imgObj.src = this.images[p_img_index - 1];
		return true;
	} else {
		window.status += " Deck.show: Invalid index number: " + p_img_index;
		return false;
	}
}

Deck.prototype.setDefault = function () {
	if (this.default_img)
		this.imgObj = this.default_img;
	else 
		window.status += " Deck.setDefault: No default image: " + p_img_index;
} 