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

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

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

		var aSubmenuData =
		[
			{
				id: "golf",
				itemdata:
				[
					[
						{ text: "Tee Times &amp; Rates", 	url: "/teetimes.php" },
                        { text: "Book Online",              url: "/book-online.php" },
						{ text: "Directions", 				url: "/directions.php" },
						{ text: "Calendar of Events",		url: "/calendar.php" },
						{ text: "Course Conditions", 		url: "/course-conditions.php" },
						{ text: "Membership Information", 	url: "/membership-information.php" },
						{ text: "Recent Press", 			url: "/press.php" },
					],
					[
						{ text: "Golf Shop", 				url: "/golfshop.php" },
                        { text: "Gift Certificates",        url: "/gift-certificates.php" },
						{ text: "Practice Facility", 		url: "/practice-facility.php" },
						{ text: "Golf Instruction", 		url: "/lessons.php" },
						{ text: "Course Tour", 				url: "/course-tour.php" },
						{ text: "Scorecard", 				url: "/scorecard.php" },
						{ text: "GPS Golf Cars", 			url: "/golfcars.php" },
					],
					[
						{ text: "Current Weather", 			url: "/weather.php" },
						{ text: "About The Course", 		url: "/about-the-course.php" },
                        { text: "Employment Opportunities", url: "/employment.php" },
//						{ text: "Course Policies", 			url: "/course-policies.php" },
//						{ text: "Course Design", 			url: "/course-design.php" },
						//				     {
						//				  text: "More Info",
						//				  submenu: {
						//				id: "moreinfo",
						//				itemdata: [
						//				    { text: "Current Weather", url: "#" },
						//				    { text: "Course Policies", url: "#" },
						//				    { text: "Course Conditions",  url: "#" },
						//				    { text: "Course Designer", url: "#" }
						//				]
						//				   }
						//
						//				     },
					]
				]
			},
			{
				id: "outings",
				itemdata:
				[
					[
						{ text: "Food & Beverage", 			url: "/food-beverage.php" },
						{ text: "Golf Outings", 		    url: "/corporate-outing.php" },
					],
					[
						{ text: "The Ranch Menu", 			url: "/pdf/Ranch Small Menu.pdf" },
                        { text: "Deluxe Brunch", 		    url: "/pdf/deluxe brunch.pdf" },
						{ text: "Banquet Menu", 			url: "/pdf/BanquetMenu2009.pdf" },
						{ text: "Special Event Menu", 		url: "/pdf/SpecialEventMenu2009.pdf" },
//						{ text: "Brunch Buffet Menu", 		url: "/pdf/BrunchBuffetMenu2008.pdf" },
						{ text: "Wedding Packages", 		url: "/pdf/SpecialEventMenu2009.pdf" },
                    ],
                    [
                        { text: "Calendar of Events",       url: "/calendar.php" },
                        { text: "Employment Opportunities", url: "/employment.php" },
                    ]
				]
			},
			{
				id: "contact",
				itemdata:
				[
					[
						{ text: "413.569.9333", 				url: "/contact.php" },
						{ text: "866.790.9333 (toll free)", 	url: "/contact.php" },
					],
					[
						{ text: "Email",						url: "/contact.php" },
						{ text: "Maps & Directions", 			url: "/directions.php" },
                        { text: "Employment Opportunities",     url: "/employment.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(1).cfg.setProperty("submenu", aSubmenuData[0]);
				this.getItem(2).cfg.setProperty("submenu", aSubmenuData[1]);
				this.getItem(4).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();

});
