Cufon.set('fontFamily', 'cafeta').replace('h2')('h3');

$(document).ready(function() {
	$("#content .panel div:gt(0)").hide();
	
	bindPortfolio();
	
	$(".topLink a").click( function() {
		$("html, body").animate({ "scrollTop": 0 }, "slow");
	});
	
	$(".filters a").click( function() {
		$(".filters a.current").removeClass("current");
		$(this).addClass("current");
		var filter = $(this).attr("id");
		
		$("ul.sort").empty();
		
		$("ul.source li").each( function() {
			if ( $(this).children("a").children("img").hasClass(filter) )
			{
				$(this).clone().appendTo("ul.sort");
			}
		});
		
		$("ul.portfolio").quicksand( $("ul.sort li"), function() {
			bindPortfolio();
		});
	});
});


function bindPortfolio()
{
	$("#content .portfolio li a").click( function() {
		var filter = $(this).parent().attr('class');
		if (!$("#" + filter).hasClass('current')) {
			$("#content .panel .current").fadeOut().removeClass("current");
			$("#content .panel #" + filter).fadeIn().addClass("current");
			$("html, body").animate({ "scrollTop": 100 }, "slow");
		}
	});
}