$(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  /*$('#navigation-sort').hide();*/
 // shows the slickbox on clicking the noted link
  $('a#slick-show').click(function() {
 $('#slickbox').show('slow');
 return false;
  });
 // hides the slickbox on clicking the noted link
  $('a#slick-hide').click(function() {
 $('#slickbox').hide('fast');
 return false;
  });
 // toggles the slickbox on clicking the noted link
  $('#portfolio').click(function() {
  		var height = $("#navigation-container").height();
		if (height==0) {
			$('#navigation-container').animate({height: "116px"},400);
			$('#navigation-sort').animate({top: "0"},400);
		} else {
			$('#navigation-container').animate({height: "0"},400);
			$('#navigation-sort').animate({top: "-116px"},400);
		}
		return false;
  });
  
  	$("#topnav-all").click(function() {
		$(".navigation-sub").fadeOut("fast");
		$(".topnav").removeClass("active");
		$(".history").removeClass("active");
		$(this).addClass("active");
		if ($("#latestwork").is(":hidden"))
			$("#latestwork").fadeIn("fast");
	});
  
  	$("#topnav-discipline").click(function() {
  		$(".topnav").removeClass("active");
		//$(".history").removeClass("active");
		$(this).addClass("active");
		$(".navigation-sub").hide();
		$("#latestwork").fadeOut("fast");
		$("#navigation-discipline").fadeIn("fast"); 
		return false;
	});
	
	$("#topnav-industry").click(function() {
		$(".topnav").removeClass("active");
		//$(".history").removeClass("active");
		$(this).addClass("active");
		$(".navigation-sub").hide();
		$("#latestwork").fadeOut("fast");
		$("#navigation-industry").fadeIn("fast");
		return false;
	});
	
	$("#topnav-region").click(function() {
		$(".topnav").removeClass("active");
		//$(".history").removeClass("active");
		$(this).addClass("active");
		$(".navigation-sub").hide();
		$("#latestwork").fadeOut("fast");
		$("#navigation-region").fadeIn("fast");
		return false;
	});
	
	$(".history").click(function() {
		$(".history").removeClass("active");
		$(this).addClass("active");
		
		/* Ajax history "fix" for nav. Not pretty but it works */
		var href = $(this).attr("href");
		var param = href.split("#");
		var args = param[1].split(",");
		$(".topnav").removeClass("active");
		$("#topnav-"+args[0]).addClass("active");
		$(".navigation-sub").hide();
		$("#navigation-"+args[0]).show(); 
	});
});