//ALL onLoad functions go here...

Event.observe(window, 'load', function() {
	///this one resents the dining guide nav
	$('navSub-DG-form').reset();
	
;
});

function diningGuideNavControl(browseByOption){
	
	var browseByOptions = $w('navSub-DG-select-browseRestaurants navSub-DG-select-browseNeighborhoods navSub-DG-select-browseChefs navSub-DG-fieldset-advancedSearch');
	
	browseByOptions.each(function(item){
		$(item).hide();
		if (item == browseByOption){
			$(item).show();
			/*$(item).setStyle({	borderColor: '#bfaa7d'});*/
		}
	})
}

function changeMenuContent(menuID,restaurantID){
	
	/*could be changed to use Ajax.Updater, but this works for now*/
	new Ajax.Request('/ajax/menu/' + menuID + '/content/',
	{
	 method:'get',
	 onSuccess: function(transport){
	   var response = transport.responseText || "no response text";
	   $('menuContentArea').update(response);
	   	/*BEGIN - Google Analytics Ajax Tracking*/
		/*
		OLD ANALYTICS CODE, REPLACE 11.10.04
		pageTracker._trackPageview('/ajax/menu_view/' + restaurantID + '/' + menuID + '/');
		*/
		
		_gaq.push(['_trackEvent', 'Menu View', restaurantID, menuID]);
		
	    /*END - Google Analytics Ajax Tracking*/

	   },
	 onFailure: function(){ $('menuContentArea').update('<p><strong>FAILURE thrown</strong>...menu does not exist...</p>') },
	 onException: function(){ $('menuContentArea').update('<p><strong>EXCEPTION thrown</strong>...menu does not exist...</p>') }
	});
	
	/*could be changed to use Ajax.Updater, but this works for now*/
	new Ajax.Request('/ajax/menu/' + menuID + '/foodwords/',
	{
	 method:'get',
	 onSuccess: function(transport){
	   var response = transport.responseText || "no response text";
	   $('foodWords').update(response);
	   
	   },
	 onFailure: function(){ $('foodWordsContentArea').update('<p>There are no food words relating to this menu...</p>') },
	 onException: function(){ $('foodWordsContentArea').update('<p>There seem to be no food words relating to this menu...</p>') }
	});
	
}

function tabNavigation(clickedTab,tabsListID,restaurantID){
	
	tabsList = $(tabsListID).childElements();
	
	tabsList.each(function(item){
	
		if ($(item).identify() != clickedTab){
			if ($(item).hasClassName("activeTab")){
				$(item).removeClassName("activeTab");
			}
		}else if ($(item).identify() == clickedTab){
			$(item).addClassName("activeTab");
			changeMenuContent($(item).identify(),restaurantID);
		}
	})
}

