


function ImageSwap(){
	this.oImages = {};
	this.oSwappedImages = {};
	this.isOK = false;
	if(document.images) this.isOK = true;
}

ImageSwap.prototype.addImage = function(id, path){
	if(this.isOK){
		var img = new Image();
		img.src = path;
		this.oImages["img_" + id] = img;
	}
};

ImageSwap.prototype.logSwappedImage = function(id){
	if(this.isOK && document.getElementById){
		var img = document.getElementById(id);
		if(this.oSwappedImages["img_" + id] == undefined){
			this.oSwappedImages["img_" + id] = img.src;
		}
	}
};

ImageSwap.prototype.getLoggedImagePath = function(id){
	return this.oSwappedImages["img_" + id];
};

ImageSwap.prototype.getImageSrc = function(id){
	return this.oImages["img_" + id].src;
};


ImageSwap.prototype.swap = function(id1, id2){
	if(this.isOK && document.getElementById){
		var img = document.getElementById(id1);
		if(img){
			this.logSwappedImage(id1);
			img.src = this.getImageSrc(id2);
		}
	}
};

ImageSwap.prototype.revert = function(id){
	if(this.isOK && document.getElementById){
		var img = document.getElementById(id);
		var revertPath = this.getLoggedImagePath(id);
		if(revertPath){
			img.src = revertPath;
		}
	}
};
