// Initialize and render the Menu when its elements are ready to be scripted

YAHOO.util.Event.onContentReady("leftmenu", function () {

    /*
         Instantiate a Menu.  The first argument passed to the 
         constructor is the id of the element in the page that 
         represents the Menu; the second is an object literal 
         representing a set of configuration properties.
    */
    
    var oMenu = new YAHOO.widget.Menu("leftmenu", { 
                                            position: "static", 
                                            hidedelay:  250, 
                                            lazyload: true });



/*
     Define an array of object literals, each containing 
     the data necessary to create a submenu.
*/

var aSubmenuData = [

    {
        id: "calculators", 
        itemdata: [ 
            { text: "VAT Calculator", url: "./vatc.html" },
            { text: "Loan Calculator", url: "./loanc.html" },
            { text: "Saving Calculator", url: "./savingc.html" },
            { text: "Payslip Calculator", url: "./payslipc.html" },
            { text: "Business Start-up Calculator", url: "./bsnsstupc.html" },
            { text: "Break Even Calculator", url: "./breakevenc.html" },
            { text: "Gross Profit Calculator", url: "./grossprofitc.html" },
            { text: "Fuel Cost Calculator", url: "./fuelcostc.html" }    
        ]
    }                    
];


// Subscribe to the Menu instance's "beforeRender" event

oMenu.subscribe("beforeRender", function () {

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

        this.getItem(12).cfg.setProperty("submenu", aSubmenuData[0]);       
    }

});


/*
     Call the "render" method with no arguments since the 
     markup for this Menu instance is already exists in the page.
*/

oMenu.render();
});
