// 
// Copyright (c) 2002, ThoughtByDesign. All rights reserved.
// 
// This computer program is protected by copyright law and international treaties.
// Unauthorized reproduction or distribution of this program, or any portion of it,
// may result in severe civil and criminal penalties, and will be prosecuted to the
// maximum extent possible under the law.
// 
// Class: NavigationElement
// Author: Rob Allen
// Created: November 22, 2001
//
// Purpose: Provides a simple navigation button.
//

function NavigationElement(buttonID,imageBaseName,target,dispText,hoverHelp,clickable,width,height) 
{

	this.buttonID = buttonID;
	this.normalImage = "images/"+imageBaseName + ".jpg";
	this.hoverImage = "images/"+imageBaseName+"_hi.jpg";
	this.selectImage = "images/"+imageBaseName+"_down.jpg";
	this.height = height;
	this.width = width;
	this.litCache = new Image(height,width);
	this.litCache.src = this.hoverImage;
	this.selectCache = new Image(height,width);
	this.selectCache.src = this.selectImage;
	
	this.hoverAction = "";
	this.unhoverAction = "";
	this.clickAction = "";
	this.target = "";
	this.hoverHelp = hoverHelp;
	this.displayLabel = dispText;
	this.navigationTarget = target;
	this.clickable = clickable;
	this.enabled = true;
	this._isActive = false;
	this._isHover = false;
	
} // NavigationElement()


NavigationElement.prototype.isClickable = function() {
	return this.clickable;
} // NavigationElement.prototype.isClickable()


NavigationElement.prototype.displayText = function() {
	return this.displayLabel;
} // NavigationElement.prototype.displayText()


NavigationElement.prototype.isDrawn = function() {
	return (document.getElementById(this.buttonID) != null);
}


NavigationElement.prototype.setHoverAction = function(theAction) {
	this.hoverAction = theAction;
}


NavigationElement.prototype.setUnhoverAction = function(theAction) {
	this.unhoverAction = theAction;
}


NavigationElement.prototype.setClickAction = function(theAction) {
	this.clickAction = theAction;
}


NavigationElement.prototype.setTarget = function(target) {
	this.target = target;
}


NavigationElement.prototype.setActive = function(state) {
	this._isActive = state;
}


NavigationElement.prototype.isActive = function() {
	return this._isActive;
}


NavigationElement.prototype.targetText = function() {
	return this.navigationTarget;
} // NavigationElement.prototype.targetText()


NavigationElement.prototype.isEnabled = function() {
	return this.enabled;
} // NavigationElement.prototype.isEnabled()


NavigationElement.prototype.hover = function() {
	if (this._isActive == false && this._isHover == false) {
		this._isHover = true;
		document.images[this.buttonID].src = this.hoverImage;
		return true;
	}
} // NavigationElement.prototype.hover()


NavigationElement.prototype.unhover = function() {
	if (this._isActive == false && this._isHover == true) {
		this._isHover = false;
		document.images[this.buttonID].src = this.normalImage;
		return true;
	}
} // NavigationElement.prototype.unhover()


NavigationElement.prototype.getHTML = function() {
	var html = "";
	if (this.isClickable() == true) {
		html = "<a href='"+this.navigationTarget+"' target='"+this.target+"' class='clsNavigationElement' onMouseOver=\""+this.hoverAction+"\" onMouseOut=\""+this.unhoverAction+"\" onClick=\""+this.clickAction+"\" title='"+this.hoverHelp+"'><img id='"+this.buttonID+"' name='"+this.buttonID+"' src='"+this.normalImage+"' border=0 height='"+this.height+"' width='"+this.width+"'></a>";
	}
	else {
		html = "<b>"+this.displayLabel+"</b><br>";
	}
	return html;
}


NavigationElement.prototype.toString = function() {
	return "[object NavigationElement]";
}





