Callbacks and re-executing a function after another function has completed

Hi there,

I have the following code:


function accordion() {

	  $('.toggle-activate').click(
	    function() {
	      var checkElement = $(this).next('.toggle');
	      if(!checkElement.is(':visible')) {
	        $('.toggle').slideUp('normal');
	        checkElement.slideDown('normal');
	    }
	      
	    });

	  $('.toggle').each(function(){
		  if($(this).is(':hidden')){
		  $(this).prev().append('open');
		  }	 
	  });	  
};

The .each() snippet is correctly being rendered on document load, however I would like it to be re-executed each time the .click() snippet is executed.

I believe what I require is for my .each() snippet to be established as a callback so that it can be referenced by my .click() snippet. Is this the correct way of thinking?

Could someone give me a rough idea of how this can be done?

Thanks for any help you can give me.