$('document').ready(function(){
 //create a clone of the full list of elements and extract 'li' elements
 //in order to use it as the 'second' list for quicksand
 var cache_list =$('ul.works_list').clone();

 //Add on click event handler to the 'ALL' button
$('ul.category_filter_list li[data-value=all]').click(function(e) {
 //Call quicksand on the original works_list list(the one visible to the user)
 //pass to it all the 'li' elements from the cached clone
 //since we want to display them all
   $('.category_filter_list li').removeClass('current');
 $('.category_filter_list .all').addClass('current');
 $('.category_filter_list .all').addClass('current');
 $('.works_list').quicksand( cache_list.find('li'), {
 duration: 500},
	function() {

		jQuery("a[rel=Brian Whitmire Fine Art Portflio]").fancybox({
		'transitionIn'          : 'elastic',
		'transitionOut'         : 'elastic',
		'titlePosition'         : 'over',
		'titleFormat'           : function(title, currentArray, currentIndex,
currentOpts) {
                                        return '<span id="fancybox-title-over">' + (currentIndex + 1) +
' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '')
+ '</span>';
                                }
                                }) 
 });
 e.preventDefault();
 });
 //Add on click event handler to the 'WEB' button
 $('ul.category_filter_list li[data-value=sketch-theatre]').click(function(e) {
 //Call quicksand on the original works_list list(the one visible to the user)
 //pass to it the 'li' elements from the cached clone with the class '.web'
 //since we want to display only the 'web' items
  $('.category_filter_list li').removeClass('current');
 $('.category_filter_list .sketch-theatre').addClass('current');
 $('.works_list').quicksand( cache_list.find('li.sketch-theatre'), {
 duration: 500},
	function() {

		jQuery("a[rel=Brian Whitmire Fine Art Portflio]").fancybox({
		'transitionIn'          : 'elastic',
		'transitionOut'         : 'elastic',
		'titlePosition'         : 'over',
		'titleFormat'           : function(title, currentArray, currentIndex,
currentOpts) {
                                        return '<span id="fancybox-title-over">' + (currentIndex + 1) +
' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '')
+ '</span>';
                                }
                                }) 
 });
 e.preventDefault();
 });
 $('ul.category_filter_list li[data-value=mixed-media-paintings]').click(function(e) {
	  $('.category_filter_list li').removeClass('current');
 $('.category_filter_list .mixed-media-paintings').addClass('current');
 $('.works_list').quicksand( cache_list.find('li.mixed-media-paintings'), {
 duration: 500},
	function() {

		jQuery("a[rel=Brian Whitmire Fine Art Portflio]").fancybox({
		'transitionIn'          : 'elastic',
		'transitionOut'         : 'elastic',
		'titlePosition'         : 'over',
		'titleFormat'           : function(title, currentArray, currentIndex,
currentOpts) {
                                        return '<span id="fancybox-title-over">' + (currentIndex + 1) +
' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '')
+ '</span>';
                                }
                                }) 
 });
 e.preventDefault();
 });
 $('ul.category_filter_list li[data-value=pencil-and-ink]').click(function(e) {
	 $('.category_filter_list li').removeClass('current');
 $('.category_filter_list .pencil-and-ink').addClass('current');
 $('.works_list').quicksand( cache_list.find('li.pencil-and-ink'), {
 duration: 500},
	function() {

		jQuery("a[rel=Brian Whitmire Fine Art Portflio]").fancybox({
		'transitionIn'          : 'elastic',
		'transitionOut'         : 'elastic',
		'titlePosition'         : 'over',
		'titleFormat'           : function(title, currentArray, currentIndex,
currentOpts) {
                                        return '<span id="fancybox-title-over">' + (currentIndex + 1) +
' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '')
+ '</span>';
                                }
                                }) 
 });
  e.preventDefault();
 });
 $('ul.category_filter_list li[data-value=pottery-sculpture]').click(function(e) {
	 $('.category_filter_list li').removeClass('current');
 $('.category_filter_list .pottery-sculpture').addClass('current');
 $('.works_list').quicksand( cache_list.find('li.pottery-sculpture'), {
 duration: 500},
	function() {

		jQuery("a[rel=Brian Whitmire Fine Art Portflio]").fancybox({
		'transitionIn'          : 'elastic',
		'transitionOut'         : 'elastic',
		'titlePosition'         : 'over',
		'titleFormat'           : function(title, currentArray, currentIndex,
currentOpts) {
                                        return '<span id="fancybox-title-over">' + (currentIndex + 1) +
' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '')
+ '</span>';
                                }
                                }) 
 });
 e.preventDefault();
 });
 }); 
