(function($){
$.fn.randomize = function() {

  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)); });

    }
  }));
} 
})(jQuery);

function randomRotate()
{

  	$('ul.random').randomize();
	$('ul.random').css('display', 'block');

	$('.accordion').prepend("<li class='openClose'><a class='openAll' href='#'>Open All</a> <a class='closeAll' href='#'>Close All</a></li>");

// $("#accordion").accordion({ header: "h3" });

	$('.accordion a.openAll').click(function(){
		$(this).parent().parent().children().children(".head").next().slideDown('fast');
		return false;
	});

	$('.accordion a.closeAll').click(function(){
		$(this).parent().parent().children().children(".head").next().slideUp('fast');
		return false;
	});

	$('.accordion .head').click(function() {
		$(this).next("div:visible").slideUp('fast');
		$(this).next("div:hidden").slideDown('fast');
		return false;
	}).next().hide();

	$('.accordion a.openAll').trigger('click');
}
  $(document).ready(function(){
  	randomRotate();
	
	//$('.accordion').icons ({
			//header: "ui-icon-circle-arrow-e", 
			//headerSelected: "ui-icon-circle-arrow-s"
			//});
  });

