$(function() {
	var pathname = location.pathname;
	var highlight;
	//highlight home
	if(pathname == "/")
	    highlight = $('ul#menu > li:first > a:first');
	else {
	    var path = pathname.substring(1);
	    if (path)
	        highlight = $('ul#menu a[href$="' + path + '"]');
	}
	highlight.addClass('selected');
	
	// hide 2nd, 3rd, ... level menus
	$('ul#menu ul').hide();
	
	// show child menu on click
	$('ul#menu > li > a.drop').click(function() {
	    //minor improvement
	    $(this).siblings('ul').toggle("slow");
	    return false;
	});
	//open to current group (highlighted link) by show all parent ul's
	$('a.selected').parents("ul").show();
});