//*** Copyright 2005 Mark W. Pemburn.  All rights reserved
var upTextColor = "black";
var overTextColor = "black";
var Button = new Array();
var prefix;

function setup(buttonName,buttonTop,buttonLeft,buttonSpacing,isHoriz) {
	var thisObj;
	var allLinks = document.getElementsByTagName("a");
	var j = 0;

	prefix = buttonName;
	for (var i=0; i<allLinks.length; i++) {
		if (Left(allLinks[i].id,buttonName.length) == buttonName) {
			Button[j++] = new navButton(allLinks[i],j);
		}
	}
	for (var i=0; i<Button.length; i++) {
		if (!isHoriz) {
			Button[i].left(buttonLeft);
			Button[i].top(buttonTop);
			buttonTop += buttonSpacing;
		} else {
			Button[i].left(buttonLeft);
			Button[i].top(buttonTop);
			buttonLeft += buttonSpacing;
		}
		Button[i].show(true);
	}
}

function navButton(object,index) {
	this.object = object;
	this.index = index;
	with (this.object) {
		onmouseover = overButton;
		onmouseout = outButton;
		onmousedown = downButton;
	}
	this.left = setLeft;
	this.top = setTop;
	this.show = showButton;
}

function setLeft(leftPos) {
	this.object.style.left = leftPos;
}

function setTop(topPos) {
	this.object.style.top = topPos;
}

function showButton(doShow) {
	if (doShow) {
		this.object.style.visibility = "visible";
	} else {
		this.object.style.visibility = "hidden";
	}
}

function overButton(evt) {
	var thisButton = document.getElementById(getTargetId(evt));
	if(thisButton == null)
		return;
	if (Left(thisButton.id,prefix.length) == prefix) {
		with (thisButton.style)	{
			color = overTextColor;
			textDecoration = "underline"
		}
	}
}

function outButton(evt) {
	var thisButton = document.getElementById(getTargetId(evt));
	if(thisButton == null)
		return;
	if (Left(thisButton.id,prefix.length) == prefix) {
		with (thisButton.style)	{
			color = upTextColor;
			textDecoration = "none"
			border = "2px outset white";
		}
	}
}

function downButton(evt) {
	var thisButton = document.getElementById(getTargetId(evt));
	if(thisButton == null)
		return;
	if (Left(thisButton.id,prefix.length) == prefix) {
		with (thisButton.style) 	{
			color = upTextColor;
			border = "2px inset white";
		}
	}
}

function getTargetId(thisEvent) {
	var objectID; 
	if (browser.isIE) {
		objectID = event.srcElement.id;
	}
	if (browser.isNetscape) {
		objectID = thisEvent.target.id;
	}
	return objectID;
}
