(function($){

// Shuffle function from: http://james.padolsey.com/javascript/shuffling-the-dom/
    
$.fn.shuffle = function() {

        var allElems = this.get(),
            getRandom = 1,
            
//            getRandom = function(max) {
//                return Math.floor(Math.random() * max);
//            },
            
            shuffled = $.map(allElems, function(){
                var random = getRandom(allElems.length),
                    randEl = $(allElems[random]).clone(true)[0];
                allElems.splice(random, 1);
                return randEl;
            });
        
        this.each(function(i){
            $(this).replaceWith($(shuffled[i]));
        });
        
        return $(shuffled);
    };
})(jQuery);
   
$(function(){
	       
   $("#articleslist li")
       /*.click(function(){
           location.href = $(this).attr("rel"); 
           return false;
       }) 
       
       UNCOMMENT THIS TO MAKE THE BLOCKS CLICKABLE TO THEIR REL ATTRIBUTES
       
       */;
       
   $("#allcat").click(function(){
       $("#articleslist li").slideDown();
       $("#sidemenu .subsections a").removeClass("current");
       $(this).addClass("current");
       return false;
   });
   
   $(".filter").click(function(){
        var thisFilter = $(this).attr("id");
        $("#articleslist li").slideUp();
        $("."+ thisFilter).slideDown();
        $("#sidemenu .subsections a").removeClass("current");
        $(this).addClass("current");
        return false;
   });
   
   $("#articleslist li").shuffle();

});