function collapseNav() {
	// Collapse all page links by default
	jQuery('ul#navigation > li ul').hide();
	
	// Sterilize the infertile pages (childless)
	jQuery('ul#navigation li:not(li:has(ul))').addClass("na");
	
	// Find the page we're on and show its children
	jQuery('ul#navigation li.current_page_item > ul').show();

	// And expand it so the icon changes
	jQuery('ul#navigation li.current_page_item:not(li.na)').addClass("expanded");
	
	// Now find the parent of the page we're on and show it
	jQuery('ul#navigation ul:has(li.current_page_item)').show();
	
	// And expand it too
	jQuery('ul#navigation li.current_page_ancestor').addClass("expanded");
	
	// Add the collapse/expand handler to all fertile pages
	jQuery('ul#navigation li:not(.na)').click(function(e) {	
		// Switch the image
		jQuery(this).toggleClass('expanded');
		
		// Slide its children in/out
		jQuery(this).children('ul').slideToggle({duration:200, easing:'easeInOutQuad'});
	});
	
	// Don't propagate the event beyond the link
	jQuery('ul#navigation a').click(function(e) {
		e.stopPropagation();
	});

	// And don't propagate it beyond the li
	jQuery('ul#navigation li').click(function(e) {
		e.stopPropagation();
	});
}

jQuery('document').ready(function(){
	collapseNav();
});
