$(document).ready(function()
{
	// hides all DIVs with the CLASS container
	// and displays the one with the ID 'home' only
	$(".nav3_bg").each(function(){
		if ($(this).hasClass("down")) {}
		else
		{ 
			$(this).css("display","none");
		}
	});
	////////////////////////$("#home").css("display","block");
	
	// makes the navigation work after all containers have bee hidden 
	showViaLink($("ul#navlist2 li.expand a"));
	//hideViaLink($("ul#navlist2 li.expand a.down"));
		//inactive
		

  $(".searchlink").click(function() {
    $("#searchbar").slideToggle();
  });
});

// shows proper DIV depending on link 'href'
function showViaLink(array)
{
	array.each(function(i)
	{	
		$(this).click(function()
		{
			$("ul#navlist2 li a").each(function(){$(this).removeClass('current');});
			$(this).addClass('current');
			var target = $(this).attr("rel");
			if ($(target).hasClass("down"))
			{
				$(target).removeClass('down');
				$(target).slideUp("slow");
				
			}
			else
			{
				$(".nav3_bg").each(function(){
					if ($(this).hasClass("down"))
					{
						$(this).removeClass('down');
						$(this).slideUp("slow");
					}
				});
				$(target).addClass('down');
				$(target).slideDown("slow"); //was slideDown, but toggle is nice :D

				//$(this).attr("title")="down";
			}
			return false; 
		});
	});
}


//inactive
function hideViaLink(array)
{
	array.each(function(i)
	{	
		$(this).click(function()
		{
			var target = $(this).attr("rel");
			$(".nav3_bg").css("display","none");
			//$(this).attr("class")="up";
			$(target).slideUp("slow");
			return false; 
		});
	});
}

