$(document).ready(function()
{
	//$("#menu").hide();
	var mark="hej";
	// First we hide all exhibitis 
	$("#menu ul li.section-title").nextAll().hide();
	
	
	if(location.href.substr(-5,4) =="news")
	{
		$("#news").css("color", "#000000");
	}
	if(location.href.substr(-5,4) =="info")
	{
		$("#info").css("color", "#000000");
	}
	$("#menu ul li.section-title").css({cursor:"pointer"});
	
	
	
	// then the active exhibit is showed
	$("#menu ul").each(function()
	{
		$("#menu ul li.section-title").css("color", "#818181");	
		$(this).find("li.active").prevAll().nextAll().show();
		$(this).find("li.active").parent().css("margin-bottom", "20px");
	});
	
	$("#menu ul li").each(function()
	{
		if($(this).hasClass("active"))
		{
			mark=$(this).parent().children().first().text();
			$(this).parent().children().first().css("color", "#000000");
		}
	});
	
	$("#menu").show();
	
	// This is the toggle function
	// first it hides all sections
	$("#menu ul li.section-title").click(function()
	{
		if($(this).text()==mark)
		{
			$("#menu ul li.section-title").nextAll().slideUp("fast");
			$("#news").css("color", "#818181");
			$("#info").css("color", "#818181");
			$("#menu ul").css("margin-bottom", "4px");
			$("#menu ul li.section-title").css("color", "#818181");
			mark="";
		}
		else	
		{
			$("#menu ul li.section-title").nextAll().slideUp("fast");
			$("#news").css("color", "#818181");
			$("#info").css("color", "#818181");
			$("#menu ul").css("margin-bottom", "4px");
			$("#menu ul li.section-title").css("color", "#818181");
			$(this).parent().css("margin-bottom", "20px");
			$(this).nextAll().delay(200).slideToggle(400);		
			$(this).css("color", "#000000");
			mark=$(this).text().toString();
		}
	});
	

});
