$(function(){
	$('.sidenav>li>ul').hide();
	$('.sidenav>li>a').click(function(event){
 	  	$link = ($(this).attr('href'));		
		if ($link == '#') event.preventDefault();
		// check that the menu is not currently animated
		if ($('.sidenav ul:animated').size() == 0) {
			// create a reference to the active element (this)
			// so we don't have to keep creating a jQuery object
			$heading = $(this).parent('li');
			// create a reference to visible sibling elements
			// so we don't have to keep creating a jQuery object
			$expandedSiblings = $heading.siblings().find('ul:visible');
			if ($expandedSiblings.size() > 0) {
				$expandedSiblings.slideUp(250, function(){
					$heading.find('ul').slideDown(250);
				});
			}
			else {
				$heading.find('ul').slideDown(250);
			}
		}
	});
});