/**
Author: Joel R. Copeland
Date: 3-18-2002
Modified: 3-26-2003
Build: 1.0
Build 1.1 Addition:
	Add the ability for the mOver library to toggle content visible. (For a menuing system for example.)

Description: Dynamic mouse-over text and background color.

Properties:
	obj.activeFont=Active font color
	obj.activeBG=Active BG color
	obj.highlightFont=highlight font color
	obj.highlightBG=highlight background color
	obj.borderColor=optional border color for highlight tabs added in version 1.1
	obj.activeContentID=internal variable to hold the contentID. Added in version 1.1
	
	obj.mActive(RowID)
		call this property when a selection is clicked on or made "active".
		- RowID = object ID to proform this action on.
	obj.mOver(RowID, intActive)
		call this property on mouse-over/mouse-out.
		- RowID = object ID to proform this action on.
		- intActive = 1 or 0. 1=preform the color change. 0=restore to origional state.		
	obj.setHighlight(font, bg)
		set the highlight colors. (RGB color-code values.)
	obj.setActive(font, bg)
		set the active colors. (RGB color-code values.)
	Version 1.1 Additions.
	obj.activeContent(RowID, containerID)
		set the selected row active and attempts to "active" document element linked to contentID
		- RowID = object ID to set active. calls mActive(RowID)
		
**/
function mOver(){
	// Browser Check
	this.w3c = (!!document.getElementById);
	this.ns = (!!document.layers);
	this.ie = (!!document.all);
	this.v = parseInt(navigator.appVersion);
	this.mac = (navigator.userAgent.toLowerCase().indexOf(" mac_") != -1);
	this.layerRef = (this.ns)? "document.layers" : "document.all";
	this.styleRef = (this.ns)? "" : ".style";

	// selected row defaults.
	this.ActiveID = null;
	this.activeFont = "000000";
	this.activeBG = "ccccff";
	// mouse-over defaults.
	this.highlightFont = "990000";	
	this.highlightBG = "eeeeee";
	this.mOutFont = "";	
	this.mOutBG = "";
	// 1.1 Optional Params addition.
	this.borderColor="000000";
	this.activeContentID="";
};

mOver.prototype.mActive = function(RowID){
	// if browser supports latest w3c spec.
	if(this.w3c){
		if(document.getElementById(RowID)){
			// Reset last-selected row.
			if(this.ActiveID != null){
				document.getElementById(this.ActiveID).style.backgroundColor = this.mOutBG;
				document.getElementById(this.ActiveID).style.color = this.mOutFont;
			};
			// Set this.ActiveID to the new active ID.
			this.ActiveID = RowID;
			// Set selected row to active colors.
			document.getElementById(this.ActiveID).style.backgroundColor = this.activeBG;
			document.getElementById(this.ActiveID).style.color = this.activeFont;
		}; // End if(document.getElementById(RowID))
	}else{
		if(!!eval(this.layerRef + "[RowID]")){	
			// Reset last-selected row.
			if(this.ActiveID != null){
				if(!(this.ns && this.v == 4)){
					eval(this.layerRef + "[this.ActiveID]" + this.styleRef + ".backgroundColor = this.mOutBG");
					eval(this.layerRef + "[this.ActiveID]" + this.styleRef + ".color = this.mOutFont");
				}else{eval(this.layerRef + "[this.ActiveID]" + this.styleRef + ".bgColor = this.mOutBG");};
			};
			// Set this.ActiveID to the new active ID.
			this.ActiveID = RowID;
			// Set selected row to active colors.				
			if(!(this.ns && this.v == 4)){
				eval(this.layerRef + "[this.ActiveID]" + this.styleRef + ".backgroundColor = this.activeBG");
				eval(this.layerRef + "[this.ActiveID]" + this.styleRef + ".color = this.activeFont");
			}else{eval(this.layerRef + "[this.ActiveID]" + this.styleRef + ".bgColor = this.activeBG");};
		};	// End if(!!eval(this.layerRef + "[RowID]"))
	}; // end browser version checking.
}; // End mActive

mOver.prototype.mOver = function(RowID, intActive){
	// default intActive If intActive > 0, preform a mouse-over color-change. if intActive = 0, mouse-out color change.
	if(!intActive)intActive = 0;
	intActive = parseFloat(intActive);
	
	// if browser supports latest w3c spec.
	if(this.w3c){
		if(document.getElementById(RowID) && RowID != this.ActiveID){
			// Set mouse-out colors.
			if(intActive > 0){
				this.mOutBG = document.getElementById(RowID).style.backgroundColor;
				this.mOutFont = document.getElementById(RowID).style.color;
			};
			// set current row colors.
			document.getElementById(RowID).style.backgroundColor = (intActive > 0)? this.highlightBG : this.mOutBG;
			document.getElementById(RowID).style.color = (intActive > 0)? this.highlightFont : this.mOutFont;
		};
	}else{
		if(!!eval(this.layerRef + "[RowID]") && RowID != this.ActiveID){
			// Set mouse-out colors.
			if(intActive > 0){
				if(!(this.ns && this.v == 4)){
					this.mOutBG = eval(this.layerRef + "[RowID]" + this.styleRef + ".backgroundColor");
					this.mOutFont = eval(this.layerRef + "[RowID]" + this.styleRef + ".color");
				}else{this.mOutBG = eval(this.layerRef + "[RowID]" + this.styleRef + ".bgColor");};
				};
			// set current row colors.
			if(!(this.ns && this.v == 4)){
				eval(this.layerRef + "[RowID]" + this.styleRef + ".backgroundColor = (intActive > 0)? this.highlightBG : this.mOutBG");
				eval(this.layerRef + "[RowID]" + this.styleRef + ".color = (intActive > 0)? this.highlightFont : this.mOutFont");
			}else{eval(this.layerRef + "[RowID]" + this.styleRef + ".bgColor = (intActive > 0)? this.highlightBG : this.mOutBG");};
		};
	}; // end browser version checking.
}; // End mOver

mOver.prototype.setHighlight = function(font, bg){
	if(!!font)
		this.highlightFont = font;
	if(!!bg)
		this.highlightBG = bg;
};// end setHighlight

mOver.prototype.setActive = function(font, bg){
	if(!!font)
		this.activeFont = font;
	if(!!bg)
		this.activeBG = bg;
};// end setActive

mOver.prototype.activeContent = function(RowID, containerID){
	// set bottom border color if tab.
	// deactivate any current content.
	// activate content.
	if(this.w3c){
		// set styles.
		(!!document.getElementById(this.ActiveID))? (document.getElementById(this.ActiveID).style.borderBottom = "1px solid #" + this.borderColor):null;
		(!!document.getElementById(RowID))? (document.getElementById(RowID).style.borderBottom = "none"):null;
		// Disable old content.
		(!!document.getElementById(this.activeContentID))? (document.getElementById(this.activeContentID).style.display="none"):null;
		// active new content.
		(!!document.getElementById(containerID))? (document.getElementById(containerID).style.display=""):null;		
		(!!document.getElementById(containerID))? (document.getElementById(containerID).style.visibility="visible"):null;		
	}else{
		// Disable old content
		var tmpVar = (this.ns && this.v == 4)? "hide":"hidden";
		(!!eval(this.layerRef + "[this.activeContentID]"))? eval(this.layerRef + "[this.activeContentID]" + this.styleRef + ".visibility = tmpVar"):null;
		// activate new content.
		var tmpVar = (this.ns && this.v == 4)? "show":"visible";		
		(!!eval(this.layerRef + "[containerID]"))? eval(this.layerRef + "[containerID]" + this.styleRef + ".visibility = tmpVar"):null;
	};

	this.mActive(RowID);
	this.activeContentID = containerID;
};// end activeContent

