

		/*
                 Initialize and render the Menu when its elements are ready 
                 to be scripted.
            */
			
			var oMenu;
			
            YAHOO.util.Event.onContentReady("left-nav", function () {
                /*
                     Instantiate a Menu:  The first argument passed to the 
                     constructor is the id of the element in the page
                     representing the Menu; the second is an object literal 
                     of configuration properties.
                */
                
				var menuitems = [ {text:"Destination", id: "/john/ajax/destination.json"},{text:"Hotel Chain", id: "/john/ajax/hotel-chain.json"},{text:"Couples Only", id: "/john/ajax/couples.json"}, {text:"Families", id: "/john/ajax/families.json"}, {text:"Honeymoon", id: "/john/ajax/honeymoon.json"}, {text:"Adults Only", id: "/john/ajax/adults.json"} ];

				oMenu = new YAHOO.widget.Menu( "left-nav", {
					position: "static", 
					autosubmenudisplay: true, 
					hidedelay: 8800, 
					submenuhidedelay: 8800, 
					lazyload: true, 
					iframe: false, 
					scrollincrement: 5000, 
					effect: { 
						effect: YAHOO.widget.ContainerEffect.FADE,
						duration: 0.25
					}
				});
				oMenu.addItems(menuitems);
				oMenu.render();
				oMenu.show();
				
				YAHOO.widget.MenuManager.addMenu(oMenu);
				
				// Adds submenus to existing menu items
				var addSubMenus = function (ev, aArgs) {
					
					var oMenuItem = aArgs[1];
					
					oMenuItem.unsubscribe("mouseOverEvent", addSubMenus);
					
					if (oMenuItem && !oMenuItem.cfg.getProperty("submenu")) {
						//var jsonUrl = "/john/ajax/destination.json?sd";
						var jsonUrl = oMenuItem.id;
						document.body.style.cursor = 'wait';
						var request = YAHOO.util.Connect.asyncRequest('GET', jsonUrl, { 
																success:handleSuccess, 
																failure:handleFailure,
																argument:{menuIndex: oMenuItem.index}
															});
					}
				};

				oMenu.mouseOverEvent.subscribe( addSubMenus );
				
				
				
				
				var handleSuccess = function(o) {
					if(o.responseText !== undefined) {
						var data;
						if(YAHOO.lang.JSON.isValid(o.responseText)) {
							try {
								data = YAHOO.lang.JSON.parse(o.responseText);
							} catch (e) {
								alert(e);
								document.body.style.cursor = 'default';
							}
						} else {
							alert("Invalid JSON");
							document.body.style.cursor = 'default';
						}
						
						//Need to do it this way because when the ajax call succeeds the active item
						//  might not be the one that was active when it was called.
						//var oMenuActiveItem = YAHOO.widget.MenuManager.getMenu(o.argument.menuIndex);
						var activeItem = oMenu.getItem(o.argument.menuIndex);
						activeItem.cfg.setProperty( "submenu", { id: "sub" + o.argument.menuIndex, itemdata: data});
						//activeItem.cfg.getProperty("submenu").mouseOverEvent.subscribe(addSubMenus);
						activeItem.cfg.getProperty("submenu").show();
						document.body.style.cursor = 'default';
					}
				}

				var handleFailure = function(o){ 
					if(o.responseText !== undefined){ 
						alert("Status code message: " + o.statusText); 
					}
					document.body.style.cursor = 'default';
				}
				
				
			})