////////////////////////////
// http://adipalaz.awardspace.com/experiments/jquery/expand.html
// * When using this script, please keep the above url intact.
///////////////////////////
(function($) {
$.fn.expandAll = function(options) {
    var defaults = {
         trigger1 : '[Expand All]',
         trigger2 : '[Collapse All]',
         cllps : 'div.collapse',
         exp : 'h4.expand',
         container : '#' + this.attr("id") + ' ',
         ref : 'div',
         showMethod : 'show',
         hideMethod : 'hide',
         speed : ''
    };
    var o = $.extend({}, defaults, options);   
    return this.each(function() {
        $(o.container + o.ref + ':first').before('<p id="switch"><a href="#">' + o.trigger1 + '</a></p>');     
        $(this).find('#switch a').click(function() {
        var $cllps = $(this).closest(o.container).find(o.cllps),
            $exp = $(this).closest(o.container).find(o.exp);
        if ($(this).text() == o.trigger1) {
          $(this).text(o.trigger2);
          $exp.addClass('open');
          $cllps[o.showMethod](o.speed);
        } else {
          $(this).text(o.trigger1);
          $exp.removeClass('open');
          $cllps[o.hideMethod](o.speed);
        }
        return false;
    });
});};
//http://www.learningjquery.com/2008/02/simple-effects-plugins:
$.fn.fadeToggle = function(speed, easing, callback) {
    return this.animate({opacity: 'toggle'}, speed, easing, callback);
};
$.fn.slideFadeToggle = function(speed, easing, callback) {
    return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
};
})(jQuery);
////////////////////////////
$(function() {
    $('#outer').expandAll().find('div.collapse').end()
    .find('h4.expand').wrapInner('<a style="display:block" href="#" title="Expand/Collapse" />');
    // 1. div.demo:eq(0):
    $('#outer div.outerbox:eq(1) h4.expand').click(function() {
        $(this).toggleClass('open')
        .next('div.collapse.normal').toggle().end()
        .next('div.collapse.slow').toggle('slow');
        return false;
    });
    // 2. div.demo:eq(1):
    $('#outer div.outerbox:eq(0) h4.expand').click(function() {
        $(this).toggleClass('open')
        .next('div.collapse.normal').slideToggle().end()
        .next('div.collapse.slow').slideToggle('slow','linear');
        return false;
    });
    // 3. div.demo:eq(2):
    $('#outer div.outerbox:eq(2) h4.expand').click(function() {
        $(this).toggleClass('open')
        .next('div.collapse.normal').fadeToggle('slow','linear').end()
        .next('div.collapse.slow').slideFadeToggle('slow','linear');
        return false;
    });
});

