$(document).ready(


//run on load
 
 function() {
 
 
	//only hide captions if the Javaccript is running
	 	
 	$(window).bind('load', function() {
 		$("div.thumb a p.imageCaption").css("display","none").addClass('captionhidden');
 	});
 	
 
 	$("#portfolioLinks").delegate("li.activeButton a", "mouseenter", function() {
 	    var selectedType = '.' + $(this).attr('class');
 	    $("div.pageContent div" + selectedType).addClass('highlighted');
 	}).delegate("li.activeButton a", "mouseleave", function() {
 	    $("div.pageContent div").removeClass('highlighted');
 	});
 
 	var $imageCaption = $(".pageContent div.thumb")
 	
 	$imageCaption.hover(function(e) {
 	    $('p', this).hoverFlow(e.type, {
 	          'height': 'show',
 	          'marginTop': 'show',
 	          'marginBottom': 'show',
 	          'paddingTop': 'show',
 	          'paddingBottom': 'show' 
 	        }, '100');
 	  }, function(e) {
 	    $('p', this).hoverFlow(e.type, {
 	          'height': 'hide',
 	          'marginTop': 'hide',
 	          'marginBottom': 'hide',
 	          'paddingTop': 'hide',
 	          'paddingBottom': 'hide' 
 	        }, '100');
 	  });
 
 	//define masonry stuff
 
 	var $wall = $('div.pageContent');
 
 
 	$wall.masonry({
 	  singlemMde: true,
 	  columnWidth: 240, 
 	  // only apply masonry layout to visible elements
 	  itemSelector: 'div.thumb:not(.jodihidden)',
 	  animate: true,
 	  animationOptions: {
 	    duration: 500,
 	    queue: false,
 	    resizeable: false
 	    }
 	});	
 	
 	// run on window.load so we can capture any incoming hashes
 	  $(window).load(function(){
 	  // run masonry on start-up to capture all the boxes we'll need
 	  $wall.masonry(masonryOptions);
 	  if ( window.location.hash ) {
 	    // get rid of the '#' from the hash
 	    var possibleFilterClass = window.location.hash.replace('#', '');
 	    switch (possibleFilterClass) {
 	    // if the hash matches the following words
 	    case 'general' : case 'portraits' : case 'performance' : case 'commercial' : 
 	      // set masonry options animate to false
 	      masonryOptions.animate = false;
 	      // hide boxes that don't match the filter class
 	      $wall.children().not('.'+possibleFilterClass)
 	        .toggleClass('jodihidden').hide();
 	      // run masonry again, this time with the necessary stuff hidden
 	      $wall.masonry(masonryOptions);
 	      break;
 	    }
 	  }
 	});
 	
 //filter thumbs based on the class of the clicked nav button 
 	
 	$("#portfolioLinks a").click(function() {
 		var selectedType = '.' + $(this).attr('class');
 		
 		var fadeSpeed = "500"
 		
 		var $main = $("div.pageContent")
 		
 		//prettify
 		$("#portfolioLinks li").addClass('activeButton').removeClass('depressed');

		$(this).parent().removeClass('activeButton').addClass('depressed');
		
		$main.children().removeClass('highlighted');

		
		//end prettification
	
		
	
		
 		if(selectedType=='.all') {
 		  // show all hidden boxes
 		  $main('.jodihidden')
 		    .removeClass('jodihidden').fadeIn(fadeSpeed)
 		    ;
 		
 		    
 		  } else {  
 		  // hide visible boxes 
 		  $main.children().not(selectedType).not('.jodihidden')
 		    .toggleClass('jodihidden').fadeOut(fadeSpeed)
 		    ;
 		    
 		  // show hidden boxes
 		  $main.children(selectedType+'.jodihidden')
 		    .toggleClass('jodihidden').fadeIn(fadeSpeed);
 		  }
 		  
 		$wall.masonry();
 		
 		return false;
 	
 	});	
 	
 	//delightfully highlight thumbs based on the class of the rolled over nav button. Really. It's delightful. Here be dragons.
 	
	

 });
