var SiteNavigation = {

	init : function()
	{
		var wrapperSections = $$('#content-nav div.nav-section-wrapper');
		wrapperSections.each(
			function(wrapperSection)
			{
				//Get the toggleElement and the toggleSection elements, based on their classnames.  
				//There should only be one of each so we are taking the first ones.
				var toggleElement = wrapperSection.select('h3.nav-toggle-element')[0];
				var toggleSectionElement = wrapperSection.select('.nav-toggle-section-element')[0];
				
				//Make sure we have a toggleElement and toggleSection to work with, and then setup the click event.
				if (toggleElement && toggleSectionElement) 
				{
					//Add the click event on the toggleElement.
					Event.observe(toggleElement, "click"
						, function() { SiteNavigation.toggleSection(toggleElement, toggleSectionElement); }
					);
				}
			}
		);
	
	},
	
	toggleSection : function(toggleElement, toggleSectionElement) 
	{
		//Do The Effect.
		new Effect.toggle(toggleSectionElement, 'slide', {duration: 0.25});
		
		//Toggle The ClassNames for the toggle element (header).
		if ($(toggleSectionElement).visible()) 
		{
			toggleElement.removeClassName("nav-toggle-open").addClassName("nav-toggle-closed");
		} 
		else 
		{
			toggleElement.addClassName("nav-toggle-open").removeClassName("nav-toggle-closed");
		}
	}
	
};

//Hook into the window.load event, to setup the toggling sections.
Event.observe(window, "load", SiteNavigation.init);



/* VERSION 1
var SiteNavigation = {

	init : function()
	{
		var sections = $$('#content-nav div.content-nav-section');
		sections.each(
			function(element)
			{
				var toggleElements = element.select('.toggle-element');
				var toggleSections = element.select('.toggle-section');
				var toggleImages = element.select('.toggle-image');
				
				if (toggleElements.length > 0 && toggleSections.length > 0 && toggleSections[0]) 
				{
					toggleElements.each(
						function(element) 
						{
							Event.observe(element, "click", function() { SiteNavigation.toggleSection(toggleSections[0], toggleImages[0]); });
						}
					);					
				}
			
			}
		);
	
	},
	
	toggleSection : function(sectionElement, toggleImage) 
	{
		new Effect.toggle(sectionElement, 'slide', {duration: 0.2});
		
		$(toggleImage).src = $(sectionElement).visible() 
			? "/App_Themes/Default/images/infopages/info-faq-arrow_closed.gif"
			: "/App_Themes/Default/images/infopages/info-faq-arrow_open.gif";
	}
	
};
*/