$(document).ready(function() {
	
	// find any flyout-menu item that contains a sub-menu and bind the hover function on it
	$('div#leftNav ul.flyout-menu li:has(> ul)').livequery(function() {
		$(this).hover(
			// mouse over
			function() {
				$(this).find('> ul').css('display', 'block');
			}
			// mouse out
			,function() {
				$(this).find('> ul').css('display', 'none');
			}
		);
	});
	
	// bind any +/- symbols to expand / collapse the list of options
	$("ul.verticalList.flyout-data-list span.toggle-switch").livequery(function() {
		// if there are no secondary items we don't want a plus sign anymore
		if ($(this).closest('ul').find('li.secondary').size() == 0)
			$(this).remove();
			
		// collapse / expand
		$(this).click(function() {
			$(this).closest('ul').find('li.secondary').toggle();
			
			if ($(this).hasClass('plus')) {
				$(this).removeClass('plus').addClass('minus').html('[-]');
			} else {
				$(this).removeClass('minus').addClass('plus').html('[+]');
			}
		});
	});
});
