var collapsible = {

    toggleDetails: function(target) {
	   new Effect[Element.visible(target) ? 'BlindUp' : 'BlindDown'](target,
        { duration:.2, fps:50, queue:'end' })
    },

    get_items: function(container) {
        return $A(document.getElementsByClassName('collapsible', container));
    },

    show_all: function(container) {
        Element.show.apply(null, collapsible.get_items());
    },

    hide_all: function(container) {
        Element.hide.apply(null, collapsible.get_items());
    },

    rules: {
        '.collapsible' : function(details) {
            var trigger = document.getElementsByClassName('trigger', $(details.parentNode))[0];
            trigger.onclick = function() {
                Element.toggle(details);
                return false;
            }
        }
    }

}

Behaviour.register(collapsible.rules);