// JavaScript Document
////////////////////////////
// http://adipalaz.awardspace.com/experiments/jquery/accordion2.html
///////////////////////////
(function($) {
//http://www.mail-archive.com/jquery-en@googlegroups.com/msg43851.html
$.fn.orphans = function(){
    var txt = [];
    this.each(function(){$.each(this.childNodes, function() {
        if (this.nodeType == 3 && $.trim(this.nodeValue)) txt.push(this)
    })}); 
    return $(txt);
};
//http://www.learningjquery.com/2008/02/simple-effects-plugins:
$.fn.slideFadeToggle = function(speed, easing, callback) {
    return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);  
};
})(jQuery);
////////////////////////////
$(function() {
    $('#content div.accordion .expand').orphans().wrap('<a href="#expand/collapse" title="expand/collapse"></a>');
     
    //demo 6 - div.demo:eq(5) - Queued Slide Effects - Always keep one sublist shown
    $('div.accordion:eq(0) ul').find('ul.collapse:not(:first)').hide().end().find('.expand:eq(0)').addClass('open');
    $('div.accordion:eq(0) .expand').each(function() {
          $(this).click(function() {
              var $thisCllps = $(this).find('ul');
              var $cllpsVisible = $(this).siblings('li').find('ul:visible');
              ($cllpsVisible.length) ? $(this).toggleClass('open').siblings('li').removeClass('open')
                  .find('ul:visible').slideUp(500, function() {
                  $thisCllps.slideDown();
                  }) : $(this).find('ul:hidden').slideToggle().parent().toggleClass('open');
              return false;
          });
     });
});
