// Our Navigation menu.
// Requires: div id="productsandservices"

// Initialize and render the MenuBar when its elements are ready to be scripted.
YAHOO.util.Event.onContentReady("productsandservices", function () {

    // Add in the menu bar html first
    var menuHTML = '<div class="bd"><ul class="first-of-type">';
    menuHTML += '<li class="yuimenubaritem first-of-type"><a class="yuimenubaritemlabel" href="index.html">Home</a></li>';
    menuHTML += '<li class="yuimenubaritem"><a class="yuimenubaritemlabel" href="beam_calculator.html">Beam Bending</a></li>';
    menuHTML += '<li class="yuimenubaritem"><a class="yuimenubaritemlabel" href="cross_section_properties.html">Cross-section</a></li>';
    menuHTML += '<li class="yuimenubaritem"><a class="yuimenubaritemlabel" href="http://www.iesweb.com/webapps/visualanchor/index.htm">Anchor Bolt Design</a></li>'
    menuHTML += '<li class="yuimenubaritem"><a class="yuimenubaritemlabel" href="http://www.iesweb.com">Complex Structures & Shapes</a></li>';
    menuHTML += '<li class="yuimenubaritem"><a class="yuimenubaritemlabel" href="#OtherStuff">Other Stuff</a></li>';
    menuHTML += '<li class="yuimenubaritem"><a class="yuimenubaritemlabel" href="#About">About</a></li>';
    menuHTML += '</ul></div>';

    document.getElementById( "productsandservices" ).innerHTML = menuHTML;  
    
    // Instantiate a MenuBar:  The first argument passed to the constructor is the id of the element in the page 
    // representing the MenuBar; the second is an object literal of configuration properties.*/
    var oMenuBar = new YAHOO.widget.MenuBar("productsandservices", { 
                                                autosubmenudisplay: true, 
                                                hidedelay: 750, 
                                                lazyload: true });

    var aSubmenuData = [   
        {
            id: "otherstuff",
            itemdata: [
                { text: "Warmachine & Hordes List Builder", url: "ListBuilder.html" },
                { text: "Malifaux Crew Builder", url: "CrewBuilder.html" },
                { text: "Home Theater Calculator", url: "HomeTheaterCalculator.html" },
                { text: "Mini-Ramp Calculator", url: "RampCalc.html" },
                { text: "Pong Game", url: "pong.html" }
            ]
        },                  
        {
            id: "about",
            itemdata: [
                { text: "Site Info", url: "about.html" },
                { text: "Jeff Lutzenberger", url: "JeffLutzenberger.html" },
                { text: "Integrated Engineering Software, LLC", url: "http://www.iesweb.com" }
                //{ text: "Hellroaring Micromachines, LLC", url: "JeffLutzenberger.html" }   
            ]
        }                    
    ];


    // Subscribe to the "beforerender" event, adding a submenu to each of the items in the MenuBar instance. 
    oMenuBar.subscribe("beforeRender", function () {

        if (this.getRoot() == this) {

            //this.getItem(0).cfg.setProperty("submenu", aSubmenuData[0]);
            //this.getItem(1).cfg.setProperty("submenu", aSubmenuData[1]);
            //this.getItem(2).cfg.setProperty("submenu", aSubmenuData[2]);
             this.getItem(4).cfg.setProperty("submenu", aSubmenuData[0]);
            this.getItem(5).cfg.setProperty("submenu", aSubmenuData[1]);

        }

    });

    // Call the "render" method with no arguments since the markup for this MenuBar instance is already exists in the page. */
    oMenuBar.render();         

});