////////////////////////////
// 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 : '',
         trigger2 : '',
         container : '#' + this.attr("id") + ' ',
         ref : 'div:first',
         showMethod : 'show',
         hideMethod : 'hide',
         speed : ''
    };
    var options = $.extend({}, defaults, options);   
    return this.each(function() {
        $('<p id="switch">' + options.trigger1 + '</p>').insertBefore(options.container + options.ref);
        $(this).find('#switch a').click(function() {
        var $cllps = $(this).closest('div').find('.collapse'),
            $exp = $(this).closest('div').find('h5.expand');
        if ($(this).text() == options.trigger1) {
          $(this).text(options.trigger2);
          $exp.addClass('open');
          $cllps[options.showMethod](options.speed);
        } else {
          $(this).text(options.trigger1);
          $exp.removeClass('open');
          $cllps[options.hideMethod](options.speed);
        }
    });
});};

//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').hide().end()
    .find('h5.expand').css('cursor','pointer').wrapInner('<a style="display:block" href="#expand/collapse" title="Hier klicken um Frage ein- bzw. auszublenden."></div>');
    
    // 1. div.demo:eq(0):
    $('#outer div.demo:eq(0) h5.expand').click(function() {
        $(this).toggleClass('open')
        .next('div.normal').toggle().end()
        .next('div.slow').toggle('slow');
    });
    // 2. div.demo:eq(1):
    		 $('#outer div.demo:eq(1) h5.expand').click(function() {
        $(this).toggleClass('open')
        .next('div.normal').slideToggle().end()
        .next('div.slow').slideToggle('slow','linear');
    });
    // 3. div.demo:eq(2):
    $('#outer div.demo:eq(2) h5.expand').click(function() {
        $(this).toggleClass('open')
        .next('div.normal').fadeToggle('slow','linear').end()
        .next('div.slow').slideFadeToggle('slow','linear');
    });
});

