// jQuery Quicksand project categories filtering
// Thanks to Sacha Greif - http://www.sachagreif.com/

jQuery.noConflict();
jQuery(document).ready(function($){
	
	// get the first collection
    var $applications = $('.portfolio-content');
  
 	// Clone applications to get a second collection
	
	var $data = $(".portfolio-content").clone();
	
	//NOTE: Only filter on the main portfolio page, not on the subcategory pages
	$('#navigation li').click(function(e) {
		$(".splitter li").removeClass("active");	
		// Use the last category class as the category to filter by. This means that multiple categories are not supported (yet)
		var filterClass=$(this).attr('class').split(' ').slice(-1)[0];
		
		if (filterClass == 'all-projects') {
			var $filteredData = $data.find('.project');
		} else {
			var $filteredData = $data.find('.project[data-type=' + filterClass + ']');
		}
		
		
		$(".portfolio-content").quicksand($filteredData, {
			duration: 800,
			easing: 'swing',
			 }, function() {

			$("a.fancybox").fancybox({
				'titleShow'			: true,
				'titlePosition'		: 'outside',
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',
				'speedIn'			: 250,
				'speedOut'			: 250,				
				'showNavArrows'		: false,
				'centerOnScroll'	: true 
			});
		});		
		$(this).addClass("active"); 			
		return false;
		
		
	});
		
});
