/* 	File: dhtml_mouseover_v1.js
 *	Include: <script language="JavaScript" src="../../jscripts/dhtml_mouseover_v1-5.js"></script>	
*/


//Global Variables.
var mo_isNS = (document.layers) ? true : false;
var mo_overSufx;
var mo_downSufx;
var mo_highSufx;
var mo_currHigh = false;

function setSuffix(OVER,DOWN,HIGH) {
	mo_overSufx = OVER;
	if (DOWN) mo_downSufx = DOWN;
	if (HIGH) mo_highSufx = HIGH;
}
// Use this in your script it you use a different suffix in the following order: OVER,DOWN,HIGH
setSuffix("_over","_down","_high");


// Object constructor -- use "none" for layer or the layer ID, DOWN and HIGH are optional
function mouseOverObj(WIN,ID,SRC,DOWN,HIGH,LAYER) {
	this.window = WIN;
	this.id = ID;	
	var srcBase = SRC.substring(0,SRC.lastIndexOf("."));
	var ext = SRC.substring(SRC.lastIndexOf("."));
	
	this.defaultImg = new Image();
	this.defaultImg.src = srcBase + ext;
	
	this.overImg =  new Image();
	this.overImg.src = srcBase + mo_overSufx + ext;
	
	if (DOWN) {
		this.downImg =  new Image();
		this.downImg.src = srcBase + mo_downSufx + ext;
	}
	
	if (HIGH) {
		this.highImg =  new Image();
		this.highImg.src = srcBase + mo_highSufx + ext;
	}
	
	this.layer = (LAYER) ? LAYER : false;
	this.loaded = false;
	
}

mouseOverObj.prototype.init =  function() {
	this.loaded = true;
	this.imgId = (this.layer && mo_isNS) ? eval(this.window + ".document.layers." + this.layer + ".document." + this.id) : eval(this.window + ".document." + this.id);
}

mouseOverObj.prototype.out =  function() {
	this.imgId.src = this.defaultImg.src;
}

mouseOverObj.prototype.over =  function() {
	if (!this.loaded) this.init(); 
	this.imgId.src = this.overImg.src;
}

mouseOverObj.prototype.down =  function() {
	if (!this.loaded) this.init(); 
	this.imgId.src = this.downImg.src;
}

mouseOverObj.prototype.high =  function() {
	if (!this.loaded) this.init(); 
	var temp = new Image();
	temp.src = this.defaultImg.src;
	if (this.highImg) {
		this.defaultImg.src = this.highImg.src;
		this.highImg.src = temp.src;
		
		if (mo_currHigh) {
		temp.src = mo_currHigh.defaultImg.src;
		mo_currHigh.defaultImg.src = mo_currHigh.highImg.src;
		mo_currHigh.highImg.src = temp.src;
		mo_currHigh.out();
		}
	}
	else {
		this.defaultImg.src = this.overImg.src;
		this.overImg.src = temp.src;
		
		if (mo_currHigh) {
		temp.src = mo_currHigh.defaultImg.src;
		mo_currHigh.defaultImg.src = mo_currHigh.overImg.src;
		mo_currHigh.overImg.src = temp.src;
		mo_currHigh.out();
		}
	}
	
		
	this.imgId.src = this.defaultImg.src;
	mo_currHigh = this;
}
