jQuery.fn.extend({
  mzaccordion: function(params){
    var jQ = jQuery;
    var params = jQ.extend({
      speed: 1000,
      width: (jQ("img", this).width())
    },params);
    return this.children().children().each(function(){
      //log.debug(this)
      jQ(this).bind("click", function(){
        if (jQ(this).siblings(".active") > 0) {
          jQ(this).siblings(".active").animate({
            width: "40px"
          }, params.speed);
          jQ(this).siblings(".active").removeClass('active')
        }
        
        else {
          jQ(this).siblings('*').each(function() {
            jQ(this).animate({
            width: "40px"
          }, params.speed);
          })
        }
        
        jQ(this).animate({
          width: params.width
        }, params.speed);
        jQ(this).addClass("active");
      });
    });
  }
});


$.fn.reorder = function() {
 
  // random array sort from
  // http://javascript.about.com/library/blsort2.htm
  function randOrd() { return(Math.round(Math.random())-0.5); }
 
  return($(this).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; }
      indices = indices.sort(randOrd);
      $.each(indices,function(j,k) { $this.append($children.eq(k)); });
 
    }
  }));
}
