$(document).ready(function() {
	if ($('#about')) {
		/* -- quicksand -- */
		// bind links
		var $filterType = $('#about a');

		// get the first collection
		var $portfolio = $('#portfolio');

		// clone portfolio to get a second collection
		var $data = $portfolio.clone();

		// call Quicksand on every click
		$filterType.click(function() {
			$filterType.removeClass('active');
			$(this).addClass('active');
			var ref = $(this).attr('href').split('#')[1];

			if (ref == 'all') {
				var $filteredData = $data.find('.thumbnail');
			}
			else {
				// http://www.bennadel.com/blog/1003-Cool-jQuery-Predicate-Selectors.htm
				var $filteredData = $data.find('.thumbnail[data-type*=' + ref + ']');
			}
			// console.log($filteredData);

			// finally, call quicksand
			$portfolio.quicksand($filteredData, {
	      	    duration: 800,
	      	    easing: 'easeInOutQuad',
				adjustHeight: false
			});
		});

		/* -- on load bindings -- */
		var anchor = window.location.href.split('#')[1];
		var activelink = $('#about a[href=#' + anchor + ']');
		if (activelink.length && anchor != 'all') {
			activelink.addClass('active');
			var $filteredData = $('#portfolio').find('.thumbnail[data-type*=' + anchor + ']');
			$portfolio.quicksand($filteredData, {
	       	    duration: 800,
	       	    easing: 'easeInOutQuad',
				adjustHeight: true
			});
		}
		else {
			$('#about a[href=#all]').addClass('active');
		}
	}
	
/*	$('contact-link').click(function() {
		
		return false;
	});
	
	$(function(){
		$('#contact').contactable({
			subject: 'A Feeback Message'
		});
	});*/

});
