(function ($) {
  
  function fixupDisclosures() {
    function doDisclosure() {
      var open_close = $(this).attr('class');
      $(this.parentNode.parentNode).children().not(':first').slideToggle();
      
      if(open_close == 'disclosure-closed-header-a'){
      	$(this).removeClass('disclosure-closed-header-a').addClass('disclosure-header-a');
      } else {
      	$(this).removeClass('disclosure-header-a').addClass('disclosure-closed-header-a');
      }      
      return false;
    }
    
  	$('.disclosure').livequery(function(){
  		// arrange for the heading to be clickable
  	  $(this).find(':header:first a').click(doDisclosure).addClass('disclosure-closed-header-a').css('display','block');
  	});
  	
  	$('.disclosure-closed').livequery(function(){
  	  // arrange for the heading to be clickable
  	  $(this).find(':header:first a').click(doDisclosure).addClass('disclosure-header-a').css('display','block');
  	    		
  		// hide the content
  	  $(this).children().not(':first').css('display', 'none');
  	});
  }

  $(fixupDisclosures);
})(jQuery);
