
$(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
	
	  // get the first collection
	  var $items = $('#items');
//	  $items.find('a').live('click',function(e){
//			e.preventDefault();
//			$.prettyPhoto.open(this.href,this.firstChild.alt,this.title);
//
//	  });
	  // clone applications to get a second collection
	  var $data = $items.clone();
	
	$('#filter a').live('click', function(e){
	  	if($.browser.msie){
			$('#items').addClass('hide-cufon');
			
		  }
		 
		var $sel = $(e.target);
		 
		e.preventDefault();
		if($sel.parent('li').hasClass('selected')){
			return;	
		}
		$('#filter li.selected').removeClass('selected');
		$sel.parent('li').addClass('selected');
		//get the right one
		var $type = $sel.attr('rel');
		if($type == 'all'){
			var $filter = $data.find('li');			
		}else{
			var $filter = $data.find('li.'+$type);			
		}
		 // finally, call quicksand
		
		$items.quicksand($filter, {
		  duration: 800,
		  attribute: 'id',
		  easing: 'easeInOutQuad',
		  enhancement: function() { 
		    Cufon.refresh('h1,h2,h3,h4',{fontFamily:'Aller',fontWeight :'700'});
			
		  }        
		});
		if($.browser.msie){
			setTimeout(function(){
			 $('#items').removeClass('hide-cufon');},800);
		}
  });
});

