$(function(){
	$('.menu .submenu:not(.active)').hide();
	
	$('.menu .submenu.active .submenu').show();

	$('.menu .submenu').each(function(){
		$(this).prev().click(function(){
			
			if($(this).attr('class').indexOf("active") >= 0) $(this).removeClass("active");
			else $(this).addClass("active");
			
			var obj = $(this).next();
			
			$('.menu .submenu:visible').not($(obj)).animate({
				height : "toggle",
				opacity : "toggle"
			}, 300);
			
			$('.menu .submenu:visible').prev().removeClass("active");
			
			$(this).next().animate({
				height : "toggle",
				opacity : "toggle"
			}, 300);
			
			
			return false;
		});
	});
});
