
/*======================================
** copyright 2002 - Vision Critical Communications Inc.
** Author: Justin Stacey
** Date: 2002-02-04
** --------------------------------------
*/

/*--------------------------------------
** Class ImageSwitch
**--------------------------------------
*/
function ImageSwitch(){
	this.imageRollovers = new Array();
}

ImageSwitch.prototype.addImageRollover = function(imageRollover){
	this.imageRollovers[this.imageRollovers.length] = imageRollover;
	
	e = imageRollover.getElement();
	if (e != null){
		e.imageSwitch = this;
		e.onmouseover = function(){this.imageSwitch.processMouseOver();}
		e.onmouseout = function(){this.imageSwitch.processMouseOut();}
	}
}

ImageSwitch.prototype.removeImageRollover = function(imageRollover){
	e = imageRollover.getElement();
	if (e != null){
		e.imageSwitch = null;
		e.onmouseover = null;
		e.onmouseout = null;
	}
	
	var tempArray = new Array();
	var lim = this.imageRollovers.length;
	for (var i=0; i<lim; i++){
		if (this.imageRollovers[i] != imageRollover){
			tempArray[tempArray.length] = this.imageObjects[i];
		}
	}
	
	this.imageRollovers = tempArray;
}

ImageSwitch.prototype.processMouseOver = function(){
	var lim = this.imageRollovers.length;
	for (var i=0; i<lim; i++){
		this.imageRollovers[i].imageOn();
	}
}

ImageSwitch.prototype.processMouseOut = function(){
	var lim = this.imageRollovers.length;
	for (var i=0; i<lim; i++){
		this.imageRollovers[i].imageOff();
	}
}

/*--------------------------------------
** Class ImageRollover
**--------------------------------------
*/
function ImageRollover(elementId,strSrcOff,strSrcOn){
	this.elm = this.getDocumentElement(elementId);
	this.offImage = new Image();
	this.onImage = new Image();
	
	this.offImage.src = strSrcOff;
	this.onImage.src = strSrcOn;
}

ImageRollover.prototype.getElement = function(){
	return this.elm;
}

ImageRollover.prototype.imageOn = function(){
	if (this.elm != null){
		this.elm.src = this.onImage.src;
	}
}

ImageRollover.prototype.imageOff = function(){
	if (this.elm != null){
		this.elm.src = this.offImage.src;
	}
}

ImageRollover.prototype.getDocumentElement = function(elementId){
	if (document.getElementById){
		return document.getElementById(elementId);
	}
	else if (document.all){
		return document.all[elementId];
	}
	else {
		return null;
	}
}