var shuffle = function(v){
    for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);
    return v;
   };

$(document).ready(function(){
    $('ul.rand').each(function() {
      var $this = $(this);
      var $children = $this.children();
      var childCount = $children.length;
   
      if (childCount > 1) {
        $children.remove();
   
        var indices = new Array();
        for (i=0;i<childCount;i++) { indices[indices.length] = i; }
        shuffle(indices);
        $.each(indices,function(j,k) { $this.append($children.eq(k)); });
   
      } 
      if (childCount < 1) { $this.parent().remove(); }
  });
});