function fixaltezza(){
	originale=parseFloat($(this).css("height"));
	nuova=originale;
	while (nuova%6!=3){
		if (nuova%6>=0 && nuova%6<3) nuova++;
		else nuova--;
	}
	$(this).css("height",nuova+"px");
}

(function($){
  $.fn.shuffle = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shuffle(items))
        : this;
    });
  }
 
  $.shuffle = function(arr) {
    for(
      var j, x, i = arr.length; i;
      j = parseInt(Math.random() * i),
      x = arr[--i], arr[i] = arr[j], arr[j] = x
    );
    return arr;
  }
})(jQuery);

$(document).ready(function(){  
	$("#shuffables").shuffle();
});

$(window).load(function() {
	$.each($(".block"),fixaltezza);
	
	var $container = $('#container');
	$container.imagesLoaded(function(){
	  $container.masonry({
	    itemSelector : '.block',
	    columnWidth : 215,
		gutterWidth : 7,
		isAnimated: true
	  });
	});
	
	$('.cliccabile').hover(function(){$(this).stop().animate({backgroundColor: '#CCC'});}, function() {$(this).stop().animate({backgroundColor: 'white'});});
	$(".cliccabile").click(function(){window.location=$(this).find("a").attr("href");return false;});
});
