$(document).ready(function(){
	// get body id
	//var _BID = document.body.id.replace('m','').split('-');
	
	// get all UL that have a trigger A before and wrap them in hider DIV
	$('ul[@id="navigation"] a + ul').wrap('<div class="hider"></div>')
			
	// get all hider DIVs
	.find('..').hide()
	
	// add class of closed to parent LI
	.find('..').addClass('closed')
	
	// add onclick functionality to necessary As
	.find('a:eq(0)').click( function(e)
	{

		// close all at same depth (visible)
		$('../../li/div:visible', this).slideUp(400)
		.find('..').removeClass('opened').addClass('closed');

		// close all subs
		$('../../li/div:visible', this).hide().show();
		//.find('..').removeClass('opened').addClass('closed');

		// open selected
		$('../div', this).slideDown(600)
		.find('..').removeClass('closed').addClass('opened'); // Adds class to parent A for restyling

		e.stopPropagation();
		e.preventDefault();
		return false;
	});

	
	$('#navigation li li.selected')
	.find('../../..')
	.removeClass('closed')
	.addClass('selected opened')
	.find('div:hidden:eq(0)')
	.show()
});
