jQuery.noConflict();
jQuery(document).ready(function($){
	//quicskand project categories filtering
	//see http://razorjack.net/quicksand/demos/one-set-clone.html

	// clone applications to get a second collection
	var $data = $(".portfolio-content .container").clone();
	
	//note: only filter on the main portfolio page, not on the subcategory pages
	$('.folionav li').click(function(e) {
		$(".filter li").removeClass("current-cat");	
		//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-designs') {
				var $filteredData = $data.find('.designs');
			} else {
				var $filteredData = $data.find('.designs[data-type=' + filterClass + ']');
			}
		
		$(".portfolio-content .container .noFound").hide();	
		$(".portfolio-content .container").quicksand($filteredData, {
			duration: 800,
			easing: 'easeInOutBack'
		}, function(){
				if (!($filteredData.length)) {
			    	var str=filterClass.split('-',1);
			    	$(".portfolio-content .container").html( "<div class='noFound'><h1 style='text-align:center;text-shadow: white 0 1px 0;'>no "+ str +" on this page</h1></div>");
			  	}
                //callback function to re-apply hover effects on cloned elements
                 setFade();
        });
		
		$('.toggle-helper').hide('fast') ;
		$('.helper').hide('fast') ;
		$(this).addClass("current-cat");
		return false;
	});
		// handle site guide
		$('.folionav > li:not(.current-cat)').mouseover(function() {
		var filterId=$('#all-designs').attr('class').split(' ').slice(-1)[0];
		if (filterId == 'current-cat') {
		 	$('.toggle-helper').fadeIn('slow') ;
    			return false;
			}
		});

	$('.toggle-helper a').click(function() {
			if ($('.helper').is(":visible")){
				$('.toggle-helper').fadeOut('fast');
			}
			$('.helper').toggle('fast') ;
    	return false;
	});

});


