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

YAHOO.util.Event.onContentReady("atwYuiMenu", 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("atwYuiMenu", {
        autosubmenudisplay: true,
        hidedelay: 750,
        lazyload: true
    });

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

    if(typeof(atwRoot) !== "undefined")
    {
        var aSubmenuData = 
            [
                null,
                {
                    id: "About Us",
                    itemdata:
                    [
                        { text: "Mission Statement", url: "/about/index.html" },
                        { text: "Creative Leadership", url: "/about/leadership.html" }
                    ]
                },
                null,
                null,
                {
                    id: "Programs",
                    itemdata:
                    [
                        { text: "Open Mic Night of Theatre, Song and Ideas", url: "/programs/open-mic/" },
                        { text: "ATW's Work in Israel and the West Bank", url: "/programs/video-viewing/" },
                        { text: "Executive Leadership Program", url: "/programs/executive-leadership/" },
                        { text: "The Life Stories Program for Veterans", url: "/programs/life-stories/" },
                        { text: "New Play Series", url: "/programs/new-plays/" },
                        { text: "The Young People's Creative Workshop", url: "/programs/ypcw/" },
                        { text: "Theatre, Education and Community Building Program", url: "/bnw/index.html" },
                        
                    ]
                },
                /*{
                    id: "Scott Actiing Conservatory",
                    itemdata:
                    [
                        { text: "Master Class Acting Training Program", url: "sac/index.html" },
                        { text: "Six Session Intensive", url: "sac/new_sac.html" }
                    ]
                },*/
                null,
                null,
                {
                    id: "Rental Information",
                    itemdata:
                    [
                        { text: "Rental Information", url: "/rental/index.html" },
                        { text: "Online Application", url: "/rental/rentalApp.html" }
                    ]
                },
                null,
                null
            ];
    }
    else
    {
        var aSubmenuData =
            [
                null,
                {
                    id: "About Us",
                    itemdata:
                    [
                        { text: "Mission Statement", url: "/about/index.html" },
                        { text: "Creative Leadership", url: "/about/leadership.html" }
                    ]
                },
                null,
                null,
                {
                	id: "Programs",
                    itemdata:
                    [
                        { text: "Open Mic Night of Theatre, Song and Ideas", url: "/programs/open-mic/" },
                        { text: "Israel and West Bank Drama and Conflict Resolution Project", url: "/programs/video-viewing/" },
                        { text: "Executive Leadership Program", url: "/programs/executive-leadership/" },
                        { text: "New Play Series", url: "/programs/new-plays/" },
                        { text: "The Young People's Creative Workshop", url: "/programs/ypcw/" },
                        { text: "Theatre, Education and Community Building Program", url: "/bnw/index.html" },
                        
                    ]
                },
                /*{
                    id: "Scott Actiing Conservatory",
                    itemdata:
                    [
                        { text: "Scott Technique Master Class and Training", url: "../sac/index.html" },
                        { text: "Six Session Intensive", url: "../sac/new_sac.html" }
                    ]
                },*/
                null,
                null,
                {
                    id: "Rental Information",
                    itemdata:
                    [
                        { text: "Rental Information", url: "/rental/index.html" },
                        { text: "Online Application", url: "/rental/rentalApp.html" }
                    ]
                },
                null,
                null
            ];
    }




    /*
    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(3).cfg.setProperty("submenu", aSubmenuData[3]);
            this.getItem(4).cfg.setProperty("submenu", aSubmenuData[4]);
            this.getItem(5).cfg.setProperty("submenu", aSubmenuData[5]);
            this.getItem(6).cfg.setProperty("submenu", aSubmenuData[6]);
            this.getItem(7).cfg.setProperty("submenu", aSubmenuData[7]);

        }

    });


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

    oMenuBar.render();

});

