/*
* SWAP IMAGE CLASS
* © Copyright Paul Woods - 15/08/08
* http://www.woodscreativemedia.com
* v2.1a
*/

function Wcm_SwapImage_Object()
{
	this.imageArray = new Array();
	/* Locate unique ID in the array */
	this.GetIndex = function(id)
	{
		var indexFound = false;
		/* Retrieve existing array object by ID */
		for (i=0; i<this.imageArray.length;i++) {
			if (this.imageArray[i].id == id) {
			index = i;
			indexFound = true;
			break;
			}
		}
		/* Add new object to array */
		if (!indexFound) {
			index = this.imageArray.length;
			this.imageArray[index] = new Object();
			this.imageArray[index].id = id;
			var obj = document.getElementById(id);
			this.imageArray[index].isrc = obj.src;
		}
		
		return index;
	}
	
	/* Swap image function */
	this.Swap = function(id,image) {
		index = this.GetIndex(id);
		var obj = document.getElementById(this.imageArray[index].id);
		obj.src = image;
	}
	/* Reverts the target object to original image without having to pass it back in to the Swap() */
	this.Revert = function(id)
	{
		index = this.GetIndex(id);
		var obj = document.getElementById(id);
		obj.src = this.imageArray[index].isrc;
	}
}
var SwapImage = new Wcm_SwapImage_Object();