$(function(){
  
  // Bind an event to window.onhashchange that, when the hash changes, gets the
  // hash and adds the class "selected" to any matching nav link.
  $(window).hashchange( function(){
    var hash = location.hash || '#studio';
    
    // Set the page title based on the hash.
    //document.title = 'The hash is ' + ( hash.replace( /^#/, '' ) || 'blank' ) + '.';
    
    function showContent() {
      $('.post').hide();
    	nextItem = $('#fade > div').filter(hash);
		nextItem.fadeIn(300);
		if($('.entry').is(':hidden')) {
			$('.entry').show();
		}
	}
    
    // Iterate over all nav links, setting the "selected" class as-appropriate.
    $('#nav a').each(function(){
      
		//var index = $(this).index();
		showContent();
      var that = $(this);
      that[ that.attr( 'href' ) === hash ? 'addClass' : 'removeClass' ]( 'active' );
    });
  })
  
  // Since the event is only triggered when the hash changes, we need to trigger
  // the event now, to handle the hash the page may have loaded with.
  $(window).hashchange();
  
  $('#hide span').live('click', function() {
  	 if($('.entry').is(':visible')) {
  	 	$('.entry').fadeOut('slow');
  	 	$(this).addClass('off');
  	 } else {
		$('.entry').fadeIn('slow');
		$(this).removeClass('off')
	 };
	 
  });

});
