/*

Original:       YUI http://developer.yahoo.com/yui/examples/menu/topnavfromjs.html
Modified By:    Matthew Bergstein
Date:           8/19/09

*/

/*
     Initialize and render the MenuBar when its elements are ready 
     to be scripted.
*/

/*
     Initialize and render the MenuBar when its elements are ready 
     to be scripted.
*/

YAHOO.util.Event.onContentReady("productsandservices", function () {

    /*
		Instantiate a MenuBar:  The first argument passed to the constructor
		is the id for the Menu element to be created, the second is an 
		object literal of configuration properties.
    */

    var oMenuBar = new YAHOO.widget.MenuBar("productsandservices", { 
                                                autosubmenudisplay: true, 
                                                hidedelay: 750, 
                                                lazyload: true });

    /*
         Define an array of object literals, each containing 
         the data necessary to create a submenu.
    */

    var aSubmenuData = [
    
        {
            id: "home"
                /*
                Sub menu example
                {
                    text: "PIM", 
                    submenu: { 
                                id: "pim", 
                                itemdata: [
                                    { text: "Yahoo! Mail", url: "http://mail.yahoo.com" },
                                    { text: "Yahoo! Address Book", url: "http://addressbook.yahoo.com" },
                                    { text: "Yahoo! Calendar",  url: "http://calendar.yahoo.com" },
                                    { text: "Yahoo! Notepad", url: "http://notepad.yahoo.com" }
                                ] 
                            }
                
                }, */
        },

        {
            id: "solutionsFor", 
            itemdata: [
                { text: "Professional", url: "/business/office/telephone-systems/solutions/professional.aspx" },
                { text: "Retail", url: "/business/office/telephone-systems/solutions/retail.aspx" },
                { text: "Hospitality", url: "/business/office/telephone-systems/solutions/hospitality.aspx" },
                { text: "High-End Residential", url: "/business/office/telephone-systems/solutions/high-end-residential.aspx" },
                { text: "Small/Medium Business", url: "/business/office/telephone-systems/solutions/small-medium-business.aspx" },
                { text: "General Office", url: "/business/office/telephone-systems/solutions/general-office.aspx" }                  
            ]    
        },
        
        {
            id: "applicationsServices", 
            itemdata: [
                { text: "Applications", url: "/business/office/telephone-systems/applications-services/communication-assistant.aspx" },
                { text: "Services", url: "/business/office/telephone-systems/applications-services/sip-trunking.aspx" }          
            ] 
        },
        
        {
            id: "products",
            itemdata: [
                { text: "Business Phone Systems", url: "/business/office/telephone-systems/products/business-phone-systems.aspx" },
                { text: "Business Phones", url: "/business/office/telephone-systems/products/business-phones.aspx" },
                { text: "Voice Mail Systems", url: "/business/office/telephone-systems/products/voice-mail-systems.aspx" },
                //{ text: "Door Phones", url: "/business/office/telephone-systems/products/door-phones.aspx" },
                { text: "View All Products", url: "/business/office/telephone-systems/products/view-all-products.aspx" }
            ]
        }, 
        
        {
            id: "resoucesSupport",
            itemdata: [
                { text: "Find a Dealer", url: "/business/office/telephone-systems/resources-support/find-a-dealer.aspx" },
                { text: "Become a Dealer", url: "/business/office/telephone-systems/resources-support/become-a-dealer.aspx" },
                { text: "Brochures &amp; Data Sheets", url: "/business/office/telephone-systems/resources-support/brochures-data-sheets.aspx" },
                { text: "Success Stories", url: "/business/office/telephone-systems/resources-support/success-stories.aspx" },
                { text: "Case Studies", url: "/business/office/telephone-systems/resources-support/case-studies.aspx" },
                { text: "User Guides", url: "http://service.us.panasonic.com/operman/findmanual.aspx?cat=TEL", target: "_blank" },
                { text: "Financing Options", url: "/business/office/telephone-systems/resources-support/financing-options.aspx" },
                { text: "Product Reviews", url: "/business/office/telephone-systems/resources-support/product-reviews.aspx" }
            ]
        },
        
        {
            id: "news",
            itemdata: [
                { text: "Press Releases", url: "/business/office/telephone-systems/news/press-releases.aspx" },
                { text: "Industry News &amp; Trends", url: "/business/office/telephone-systems/news/industry-news-trends.aspx" }
            ]
        },
        
        {
            id: "aboutUs",
            itemdata: [
                { text: "Contact Us", url: "/business/office/telephone-systems/about-us/contact-us.aspx" },
                { text: "Solution Partners", url: "/business/office/telephone-systems/about-us/solution-partners.aspx" },
                { text: "Eco Responsibility", url: "/business/office/telephone-systems/about-us/eco-responsibility.aspx" }
            ]
        }                      
    ];


    /*
         Subscribe to the "beforerender" event, adding a submenu 
         to each of the items in the MenuBar instance.
    */

    oMenuBar.subscribe("beforeRender", function () {

		var nSubmenus = aSubmenuData.length,
			i;


        if (this.getRoot() == this) {

			for (i = 0; i < nSubmenus; i++) {
            	this.getItem(i).cfg.setProperty("submenu", aSubmenuData[i]);
			}

        }

    });


    /*
         Call the "render" method with no arguments since the 
         markup for this MenuBar instance is already exists in 
         the page.
    */

    oMenuBar.render();         

});


