$('.gallery-row.grid').masonry({
itemSelector: '.gallery-full',
percentPosition: true
});
$('.gallery-sortable').each(function(){
var $that=$(this);
var $filterType=$(this).find('.gallery-filter > ul > li.active > a').attr('data-type');
var $holder=$(this).find('.gallery-list .gallery-row');
var $data=$holder;
$(this).find('.gallery-filter ul li a').on('click',function(e){
$that.find('.gallery-filter ul li').removeClass('active');
var $filterType=$(this).attr('data-type');
$(this).parent().addClass('active');
var $filteredData;
if( $filterType=="uslugi" ){
$filteredData=$data.find('.gallery-full[data-type=all-dor-rab], .gallery-full[data-type=all-razmetka], .gallery-full[data-type=all-arenda], .gallery-full[data-type=all-installation]');
$('.gallery-link-menu').slideUp();
$('.gallery-link-menu').has('a[data-type=all-dor-rab]').slideDown();
$('.gallery-link-menu').has('a[data-type=all-razmetka]').slideDown().siblings().has('a[data-type=all-arenda]').slideDown().siblings().has('a[data-type=all-installation]').slideDown();
}
else if($filterType=="orders"){
$filteredData=$data.find('.only-orders');
$('.gallery-link-menu').slideUp();
$('.gallery-goods').slideDown();
}
else if($filterType=='all'){
$filteredData=$data.find('.gallery-full');
$('.gallery-link-menu').slideDown();
}
else{
$filteredData=$data.find('.gallery-full[data-type='+$filterType+']');
}
/*$holder.quicksand($filteredData,{duration:0,useScaling:true,easing:'easeInOutQuad'});*/
$holder.find(".gallery-full").hide();
$filteredData.show();
$('.gallery-row.grid').masonry({
itemSelector: '.gallery-full'
});
return false;
});
});