/**
* jQuery Accordion Menu, by Weblink Internaional Inc.
* Modeled after jQuery Tools' "tabs" featuer with the added capability to close the open tab.
* This is not very customizable with initialization options yet. A future todo perhaps.
* (c) 2011
*/
$.fn.extend({
    accordion : function() {
        this.each(function(i, accordion_root) {
            $('.accordion-handle', accordion_root).live('click', function() {
                $('.accordion-handle.accordion-open', accordion_root).removeClass('accordion-open');
                
                $('.accordion-pane.accordion-open', accordion_root).animate({'height' : 'hide'}, {complete:function(){$(this).removeClass('accordion-open')}});

                if (!$(this).next('.accordion-pane').hasClass('accordion-open'))
                    $(this).addClass('accordion-open').next('.accordion-pane').animate({'height' : 'show'}, {complete:function(){$(this).addClass('accordion-open');}});
            });
        })
    }
});
