// modified 8/13/10 ja to take out drop-down menu junk

var $ = function (id) { return document.getElementById(id); }

// Make sure all required libraries are loaded
if ( ! jsLib ) {
    throw new Error("MenuBar: jsLib CSS and Event libraries required.");
} else if ( ! jsLib.css ) {
    throw new Error("MenuBar: jsLib CSS library required.");
} else if ( ! jsLib.event ) {
    throw new Error("MenuBar: jsLib Event library required.");
}

var MenuBar = function ( menuId ) {
    var that = this;

    // Store a reference to the menu bar as a property
    this.menuBar = $(menuId);

    // Validate the menu bar
    if ( arguments.length != 1 ) {
        throw new Error("MenuBar: Wrong number of arguments.");
    }
    if ( this.menuBar && this.menuBar.nodeType != 1 ) {
        throw new Error("MenuBar: Menu id is not a DOM element.");
    }
    if ( this.menuBar.tagName != "DIV" ) {
        throw new Error("MenuBar: menu id is not a div element.");
    }
    
    // Store a reference to the menu bar links as a property
    this.links = this.menuBar.getElementsByTagName("a");

    // Validate the menu bar links
    if (this.links.length == 0) {
        throw new Error("MenuBar: no links in menu.");
    }
    
    // Add a right border to the last menu bar link
    var lastList = this.links[this.links.length - 1];
    var linkStyle = getComputedStyle(lastList, null);
    lastList.style.borderRightWidth = linkStyle.borderLeftWidth;
    lastList.style.borderRightColor = linkStyle.borderLeftColor;
    lastList.style.borderRightStyle = linkStyle.borderLeftStyle;
    
    // Loop through each menu bar link
    var dropMenu, linkIndex, link;
    var listItems, itemIndex, item;
    for ( linkIndex = 0; linkIndex < this.links.length; linkIndex++) {
        link = this.links[linkIndex];

        // Add an event handler to each menu bar link
        jsLib.event.add ( link, "mouseover", this.highlight(link) );
        jsLib.event.add ( link, "mouseout", this.normal(link) );
        
        // jsLib.event.add( link, "mouseover", this.hideMenu() );
        
    }
}

MenuBar.prototype.highlight = function ( element ) {
    return function () {
        element.className = "highlight";
    }
}

MenuBar.prototype.normal = function ( element ) {
    return function () {
        element.className = "";
    }
}


