(function($) {
$.fn.orphans = function(){
    var txt = [];
    this.each(function(){$.each(this.childNodes, function() {
        if (this.nodeType == 3 && $.trim(this.nodeValue)) txt.push(this)
    })}); 
    return $(txt);
};
$.fn.addTrigger = function(options) {
    var defaults = {
         expand : '<i>[-]</i>',
         collapse : '<b>[+]</b>',
         a : '<p id="switch"><a onclick="javascript: return false; emos_userEvent1(\'marker\',\'FAQ/global\');" href="#expand-all/collapse-all"><span>',
         b : '</span><span class="hidden">',
         c : '</span></a></p>',
         ref : 'div:first',
         el : '#' + this.attr("id") + ' '
    };
    var options = $.extend(defaults, options);   
    return this.each(function() {
        $(options.a + options.expand + options.b + options.collapse + options.c).insertBefore(options.el + options.ref);
});};

$.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() {
    $('#faq').addTrigger().find('div.collapse').hide().end().find('.expand').css('cursor','pointer').orphans().wrap('<a style="display:block" href="#expand/collapse" title="expand/collapse"></a>');

/* ---  * If you want to have your DIVs initially expanded:
            remove: $('.collapse').hide();
            --- * The first DIV initially expanded:
            $('#outer').addTrigger().find('div.collapse:gt(0)').hide().end()
            .find('h4.expand:eq(0)').addClass('open').end() ...  --- */

    /// Expand All/Collapse All ///        
    $('#switch').click(function () {
        $(this).find('span').toggleClass('hidden');
        var $cllps = $(this).closest('div').find('div.collapse'),
            $exp = $(this).closest('div').find('h3.expand'),
            $sp = $(this).closest('div').find('span:first');
        ($sp.hasClass('hidden')) ? $exp.addClass('open') : $exp.removeClass('open');
        ($sp.hasClass('hidden')) ? $cllps.show() : $cllps.hide();
    });

    $('#faq .expand').click(function() {
        $(this).toggleClass('open')
        .next('div').slideToggle().end()
		/* vorher stand: div.normal */
        .next('div.slow').slideToggle('slow','linear');
    });


});






