// New JQuery-based menu (replaces the old aurora menu)

$(document).ready(function() {
	//$.cookie('testcookie','expanded');

	// Set up the menu
	$('.auroramenu ul li a').click(function() {
		var catList = $(this).next('ul'); // Get the sub-nav
		if (catList.length) { // Toggle the arrow image
			catList.toggleClass('show'); // Show the sub-nav
			$(this).toggleClass('rightBtn').toggleClass('downBtn');
		}
		else catList = $(this).parent('li').parent('ul'); // For getting the parent UL's ID
		$.cookie('expanded', catList.attr('id')); // Store present selection
	});

	// Set up initial selection
	var curUL = false;
	var cookie = $.cookie('expanded');
	if (cookie) curUL = $('#'+cookie);
	if (curUL) {
		curUL.toggleClass('show',true); // Show current UL
		curUL.prev('a').toggleClass('downBtn',true).toggleClass('rightBtn',false);
		var parent = curUL.parent('li').parent('ul');
		if (parent) { // Also show parent UL
			parent.toggleClass('show',true);
			parent.prev('a').toggleClass('downBtn',true).toggleClass('rightBtn',false);
		}
	}
});

