/**
 * @example jQuery("#nav_main").expaNav();

 * 							
 *
 * @name expaNav
 * @type jQuery
 * @param Object	settings	hash with options, described below.
 * 								oneBranchOnly			-	closes other open branches in same level when a Nav Item is clicked
 *								preserveMinimized		- 	if true, preserves expanded branches when minimized
 *								startMinimized			- 	initial state is minimized
 *								initialMenuItemActive	-	indicates branch to open/highlight when initialized on page load (example: {1: 0, 2: 3 } )
 *
 *								
 * @return jQuery
 * @author Chris Deemer | Rosetta
 */


jQuery.fn.expaNav = function(settings)
{
	settings = jQuery.extend(
		{
		}, settings
	);
	return this.each(
		function()
		{
			var $this = jQuery(this);
			init();
			
			function init(){
				
				/* START :: PERSISTENCE OF NAV STATE LOGIG */
					
					
					//no state to persist (eg. home page) this is the default state of the navigation
					$this.find('ul:visible').css('display', 'none');
					//then grab current page to expand as necessary
					setNavToCurrentPage();
				/* END :: PERSISTENCE OF NAV STATE LOGIC */
				
			};
			
			function setNavToCurrentPage (){
				var fileName = location.pathname.substr(location.pathname.lastIndexOf("/")+1,location.pathname.length);
				$this.find('a').each(function(){
					if(fileName==jQuery(this).metadata().page){
						//change immediate li parent
						jQuery(this).parent('li').addClass('over').parent('ul').parent('li').addClass('over');
					}
				});
			}
			
		}
	)
};

jQuery().ready(function(){
		jQuery('.leftNav').expaNav();
});
