//This simple jQuery plugin is for collapsing and expanding sections of content.
(function() {

    jQuery.fn.collapse = function(settings) {

        var cContainers = this;     //The jquery objects that contain our collapsable items.
        
        // define defaults and override with options, if available
        // by extending the default settings, we don't modify the argument
        settings = jQuery.extend({
         header: "p",
         content: "ul"
        }, settings);

        //Loop through the jquery objects (these are the elements that contain our items to collapse).
        return cContainers.each(function(){

            //This current dom element.
            var jDomElem = this;
            var headerDomElem = jQuery(settings.header, jDomElem);
            var contentDomElem = jQuery(settings.content, jDomElem);
            

            //When the header element is clicked.
            headerDomElem.click(function() {
            
                //Show/hide the content.
                contentDomElem.toggle();
                
            });

            //Hide the content area.
            contentDomElem.hide();
            
        });
      
    };
  
})(jQuery);