(function($){ 
     $.fn.extend({  
         accordion: function() {       
            return this.each(function() {
				if($(this).data('accordiated'))
					return false;									
				$.each($(this).find('ul:not(.show), li>div'), function(){
					$(this).data('accordiated', true);
					$(this).hide();
				});
				$.each($(this).find('a:not(.foo)'), function(){
					$(this).click(function(e){
						activate(e.target);
						return void(0);
					});
				});
//				$.each($(this).find('ul.show, li>div'), function(){
//					
//					$(this).addClass("show");
//				});
//				
				var active = false;
				if(location.hash)
					active = $(this).find('a[href=' + location.hash + ']')[0];
				else if($(this).find('li.current'))
					active = $(this).find('li.current a')[0]; 
				
				
				
				if(active){
					activate(active, 'toggle','parents');
					$(active).parents().show();
				}
				
				function activate(el,effect,parents){
//					alert ($(el)[(parents || 'parent')]('li').html());
					$(el)[(parents || 'parent')]('li').toggleClass('active');
					//$(el)[(parents || 'parent')]('li').siblings().removeClass('active');
				
					jQuery(el)[(parents || 'parent')]('li').siblings().children('div').hide();
					$(el).siblings('ul, div')[(effect || 'slideToggle')]((!effect)?'normal':null);
				}

				
            });
        } 
    }); 
})(jQuery);