jQuery(function(){
  $.fn.extend({
    groupMenu: function(opts){
      var wrapper  = this;
      var defaults = {}; 
      defaults.onChange = function(e){
        // ...
      };
      
      opts = $.extend({}, defaults, opts);
      
      if(this == null || this.length == 0) return false;
      
      // hide all category wrappers
      jQuery(".contentWrapper:not(.current)", wrapper).hide();
      
      /* adds event handlers */
      jQuery(".titleWrapper").click(function(e){
		var menu = $(this).next(".contentWrapper");

		if(menu.css('display') == 'none'){
			menu.slideDown(300);
		} else{
			menu.slideUp(300);
		} 
        
        opts.onChange(e);
      });  
    }
  });
});

