(function($){
$.extend(
	$.fn
	,{
		'accordion':function(option)
		{
			var self	= this;
			var moving	= false;
            var headerHeight        = 0;
            var contentMaxHeight    = 0;
            var offset  = 0;
            if ( $.browser.msie && (7 > $.browser.version) ) {
                offset  = self[0].offsetHeight - self.height();
            }

            self.css('overflow', 'hidden');
			$(option.header, this).each(function()
			{
                headerHeight    += $(this).height();
				var $content	= $('+', this);
                var contentHeight   = $content.height();
                if ( contentHeight > contentMaxHeight ) contentMaxHeight = contentHeight;
				$content.attr('originalHeight', $content.height()).css('overflow', 'hidden');
				if ( 0 <= option.active.lastIndexOf($('> a', this).attr('href')) ) {
					$content.attr('accordion-active', '1');
				} else {
					$content.attr('accordion-active', '0');
					$content.css('display', 'none').css('height', '1px');
				}
			}).mouseover(function()
			{
				if ( moving ) return false;
                $(option.header, self).attr('accordion-active', '0');
				$(this).attr('accordion-active', '1');
				moving	= true;
                $toHide = $(option.header + '[accordion-active=0] + :visible', self);
				$toShow	= $(option.header + '[accordion-active=1] + :hidden', self);
				if ( $toShow.size() ) {
                    $toShow.css('height', 1).css('display', 'block');
                    $toHide.height($toHide.height() - 1);
                    syncAnimation($toHide, $toShow, 10, 20)();
                } else {
                    moving	= false;
                }
			});

            function syncAnimation($hide, $show, px, msec)
            {
                return function()
                {
                    var nextHideHeight  = $hide.height() - px;
                    var nextShowHeight  = $show.height() + px;
                    var originalHeight  = $show.attr('originalHeight');
                    var hideFlag    = (1 > nextHideHeight);
                    var showFlag    = (nextShowHeight > originalHeight);

                    if ( hideFlag && showFlag  ) {
                        $show.height(originalHeight - 1).attr('accordion-active', '1');
                        $hide.height(1).attr('accordion-active', '0');
                        $show.height(originalHeight);
                        $hide.css('display', 'none');
                        self.height(headerHeight + contentMaxHeight + offset);
                        moving  = false;
                        return false;
                    }

                    if (!hideFlag) $hide.height(nextHideHeight);
                    if (!showFlag) $show.height(nextShowHeight);

                    setTimeout(syncAnimation($hide, $show, px, msec));
                }
            }

		}
	});
})(jQuery);