/*
     Initialize and render the MenuBar when its elements are ready
     to be scripted.
*/

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

    /*
         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("mainMenu", {
                                                autosubmenudisplay: true,
                                                hidedelay: 750,
                                                lazyload: true });

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

    var aSubmenuData = [

        {
            id: "about",
            itemdata: [
                { text: "Our Vision", url: "/about/" },
                { text: "What We Believe", url: "/about/what_we_believe.php" },
                { text: "Our Team", url: "/people/" }
            ]
        },

		{
            id: "overview",
            itemdata: [
                { text: "WorldofGood.com", url: "/about/overview-marketplace.php" }
            ]
        },

		{	

			id: "press",
            itemdata: [
                { text: "In the News", url: "/press/index.php" },
                { text: "Buzz", url: "/press/buzz.php" },
                { text: "Awards and Recognition", url: "/press/awards.php" }
            ]


		},


        {
            id: "contact",
            itemdata: [
                { text: "Partner", url: "contact/partner.php" }
            ]
        }
    ];


    /*
         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]);
        }

    });


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

    oMenuBar.render();

});
