$(document).ready(function() {
						   
		var $preferences;
		jQuery("#content").each(function(){
									$preferences = {
												duration: 1000,
												easing: 'easeInOutQuad',
												attribute: function(v) {return $(v).attr('data-id')},
												enhancement: function() {
													if (!jQuery.browser.msie){
														Cufon.replace('h3', {
															fontFamily: 'PT Sans'
														});
													}
												
												}
									};
		});
		
	  var $applications = $('.portfolio_items');
	// clone applications to get a second collection
	  var $data = $applications.clone();
	
	  // attempt to call Quicksand on every form change
	  jQuery('.source a',this).click(function(e){

					var clicked = $(this);
					
					$(".source li").removeClass("active")
					$(clicked).parent().addClass("active")
	
					var $sorted_data
					e.preventDefault();
					if(jQuery(this).attr('data-value') == 'all'){
								$sorted_data = $data.find('.portfolio');
					}else{
								$sorted_data = $data.find('.portfolio[data-value*='+jQuery(this).attr('data-value')+']');	
					}

					// finally, call quicksand
					$applications.quicksand($sorted_data,$preferences, function() {
														
														$("a[rel^='prettyPhoto']").prettyPhoto({show_title: false});
														
														
														
														$(".portfolio_img_wrap").hover(function() {
															var e = this;
															$(e).find("a").stop().animate({ top: "-18px" }, 250, function() {
																$(e).find("a").animate({ top: "-10px" }, 250);
															});
															$(e).find("img.shadow_portfolio").stop().animate({ width: "80%", height: "20px", marginLeft: "25px", opacity: 0.25 }, 250);
														},function(){
															var e = this;
															$(e).find("a").stop().animate({ top: "30px" }, 250, function() {
																$(e).find("a").animate({ top: "24px" }, 250);
															});
															$(e).find("img.shadow_portfolio").stop().animate({ width: "100%", height: "40px", marginLeft: "0px", opacity: 1 }, 250);
														});
														
														
														
									
														//Fix for IE Duplicated Text
														if (jQuery.browser.msie){
															//Disable Cufon
															$(".portfolio_info h3").each(function(index) {
																var text = $(this).text();
																$(this).text('');
																$(this).text(text);
																
															});
															//Reable Cufon
															Cufon.replace('h3', {
																fontFamily: 'PT Sans'
															});

														}
												
														
					});

		});
	
	
	
	$(function(){
		$("#content").preloader();
	});
	
	$(".portfolio_img_wrap").hover(function() {
			var e = this;
			$(e).find("a").stop().animate({ top: "-18px" }, 250, function() {
				$(e).find("a").animate({ top: "-10px" }, 250);
			});
			$(e).find("img.shadow_portfolio").stop().animate({ width: "80%", height: "20px", marginLeft: "25px", opacity: 0.25 }, 250);
		},function(){
			var e = this;
			$(e).find("a").stop().animate({ top: "30px" }, 250, function() {
				$(e).find("a").animate({ top: "24px" }, 250);
			});
			$(e).find("img.shadow_portfolio").stop().animate({ width: "100%", height: "40px", marginLeft: "0px", opacity: 1 }, 250);
		});
	
	

		

});
