
// abffe_nav.js
// 11/06/2001 by Scott Zarecor - sczarecor@hotmail.com


// create function for the navigation bar:
function navBar(name) {
	// properties and colections:
	this.name = name;
	this.elements = new Array();
	this.bgcolor = '#ffffff';
	this.width = '100%';
	// methods:
	this.display = displayNavBar;
	this.addElement = addNavElement;
}

// create function for individual navigation elements:
function navElement(name, href,  alt) {
	// properties:
	this.name = name;
	this.href = href;
	this.alt = alt;
	// preload the image:
	this.off_image = new Image();
	this.off_image.src = "Graphics/" + this.name + "_up.gif";
	// preload the mouseover img:
	this.on_image = new Image(); 
	this.on_image.src = "Graphics/" + this.name + "_over.gif";
}

// method of navBar:
function displayNavBar() {
		var return_string = "<table cellpadding='0' cellspacing='0' border='0' bgcolor='" + this.bgcolor + "'>\n";
		return_string += "<tr>\n";
		for (i = 0; i < this.elements.length; i++) {
			return_string += "<td><a href='" + this.elements[i].href  + "' onMouseover='rollOver(\"" + this.elements[i].name + "\")' onMouseout='rollOff(\"" + this.elements[i].name + "\")'><img name='" + this.elements[i].name + "' src='" + this.elements[i].off_image.src + "' border='0'></a></td>\n"
		
			if (i != (this.elements.length - 1)) {
				return_string += "<td width='19'><img src='images/spacer.gif' width='19' height='19' alt=''></td>\n";
			}
		
		}
		return_string += "</tr>\n</table>\n";
		document.open();
		document.write(return_string);
		document.close();
	}
	
// method of navBar, it adds an element to a navBar, takes a pointer to a navElement as an arguement:
function addNavElement(new_element) {
	this.elements.length++;
	this.elements[(this.elements.length -1)] = new_element;
}


// The param "image_ref" is the name of the image which is 
// the same as the navElement obj name.
function rollOver(image_ref) {
	eval("document.images['" + image_ref + "'].src = " + image_ref + ".on_image.src");
}

function rollOff(image_ref) {
	eval("document.images['" + image_ref + "'].src = " + image_ref + ".off_image.src");
}

// instantiate the navElements:
var store = new navElement('store', 'https://store.abffe.com/Merchant2/merchant.mv', 'ABFFE store');
var auction = new navElement('auction', 'http://www.abffe.com/oswelcome.shtml', 'ABFFE auction');
var update = new navElement('update', 'update.htm', 'ABFFE updates');
var banned = new navElement('banned', 'banned.htm', 'Banned Books Week');
var about = new navElement('about', 'about.htm', 'About ABFFE');

// instantiate a navBar and add the navElements:
var nav_bar = new navBar("nav_bar");
nav_bar.addElement(store);
nav_bar.addElement(auction);
nav_bar.addElement(update);
nav_bar.addElement(banned);
nav_bar.addElement(about);

