/*
	Initialize and render the MenuBar when its elements are ready to be scripted.
*/
YAHOO.util.Event.onContentReady
(
	"my_menu", 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
		(
			"my_menu", 
			{ 
				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-us",
				itemdata: 
				[
					{ text: "Values & Inspiration", url: "/About-Us/Values-Inspiration.aspx" },
					{ text: "Meet Our Team", url: "/About-Us/Our-Team.aspx" },
					{ text: "Anthony's Story", url: "/About-Us/Anthonys-Story.aspx" },
					{ text: "Meet the Coles", url: "/About-Us/Meet-The-Coles.aspx" }
				]
			},
			{
				id: "solutions", 
				itemdata: 
				[
					{ text: "Sales Assessment", url: "/Solutions/SalesAssessment.aspx" },
					{ text: "Sales Managed Environment&reg;", url: "/Solutions/Sales-Managed-Environment.aspx" },
					{ text: "Sales Coaching Skills", url: "/Solutions/Sales-Coaching-Skills.aspx" },
					{ text: "Sales Force Training", url: "/Solutions/Sales-Force-Development.aspx" },
					{ text: "Pipeline Management", url: "/Solutions/Sales-Pipeline.aspx" },
					{ text: "Recruiting for Sales", url: "/Solutions/STAR-Recruiting.aspx" },
					{ text: "Keynote", url: "/Solutions/Keynote.aspx" }
					
				]    
			},
			{
				id: "integrated-learning", 
				itemdata: 
				[
					{ text: "Instructor Led", url: "/Integrated-Learning/Instructor-Led-Training.aspx" },
					{ text: "Sales Webinars", url: "/Integrated-Learning/ACTive-Webinars.aspx" },
					{ text: "Sales Management Webinars", url: "/Integrated-Learning/Live_Webinars.aspx" },
					{ text: "Self Directed Library", url: "/Integrated-Learning/Self-Directed-Library.aspx" },
					{ text: "The Sales Coach", url: "/Integrated-Learning/The-Coach-1-On-1.aspx" }
				] 
			},
			{
				id: "client-results", 
				itemdata: 
				[
					{ text: "Testimonials", url: "/Client-Results/Testimonials.aspx" }
				] 
			},
			{
				id: "free-resources",
				itemdata: 
				[
					{ text: "Sales Brew Newsletters", url: "/Free-Resources/Sales-Brew-Newsletters.aspx" },
					{ text: "Audio Sales Brew", url: "/Free-Resources/Audio-Sales-Brews.aspx" },
					{ text: "Recommended Reading", url: "/Free-Resources/Recommended-Reading.aspx" },
					{ text: "Sales & Sales Management Tools", url: "/Free-Resources/Sales-Tools.aspx" },
					{ text: "Recommended Links", url: "/Free-Resources/Recommended-Links.aspx" },
					{ text: "Free Assessments", url: "/Free-Resources/Free-Assessments.aspx" }
				]
			}                    
		];
		
		/*
			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(1).cfg.setProperty("submenu", aSubmenuData[0]);
					this.getItem(2).cfg.setProperty("submenu", aSubmenuData[1]);
					this.getItem(3).cfg.setProperty("submenu", aSubmenuData[2]);
					this.getItem(4).cfg.setProperty("submenu", aSubmenuData[3]);
					this.getItem(5).cfg.setProperty("submenu", aSubmenuData[4]);
				}
			}
		);
		
		/*
			Call the "render" method with no arguments since the markup for this MenuBar instance is already exists in the page.
		*/
		oMenuBar.render();
	}
);