Bind jQuery custom accordion to url hash tag
<p>I have jQuery custom accordion function and I would like to bind it to url that every hash tag given in url would open desired element.
I added var hash in function and tried to assign it to active variable but it did not work. Any ideas how to modify it?</p>

<pre><code>jQuery.fn.extend({  
    accordion: function() {       
        return this.each(function() {   
            var $ul = jQuery(this);             
            if($ul.data('accordiated'))
                return false;                                           
            jQuery.each($ul.find('ul, li&gt;div'), function(){
                jQuery(this).data('accordiated', true);
                jQuery(this).hide();
            });

            jQuery.each($ul.find('a'), function(){
                jQuery(this).click(function(e){
                    activate(this);
                    return void(0);
                });
            });

            var hash = window.location.hash;
            var active = jQuery('.accordion .active');

            if(active){
                activate(active, 'toggle');
                jQuery(active).parents().show();
            }

            function activate(el,effect){
                Query(el).parent('li').toggleClass('active').siblings().removeClass('active').children('ul, div').slideUp('fast');
                jQuery(el).siblings('ul, div')[(effect || 'slideToggle')]((!effect)?'fast':null);
            }

        });
    } 
}); 

jQuery('.accordion ul').accordion();
</code></pre>

<p>A here is html structure:</p>

<pre><code>&lt;div class="accordion"&gt;
    &lt;ul class="accordion"&gt;
        &lt;li class="active"&gt;
            &lt;a href="#health" class="active"&gt;Health&lt;span&gt;&lt;/span&gt;&lt;/a&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href="#health-implants"&gt;Implants&lt;span&gt;&lt;/span&gt;&lt;/a&gt;
                    &lt;p&gt;Content&lt;/p&gt;
                &lt;/li&gt;
                &lt;li&gt;&lt;a href="#health-protetic"&gt;Protetic&lt;span&gt;&lt;/span&gt;&lt;/a&gt;
                    &lt;p&gt;Content&lt;/p&gt;
                &lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;a href="#estetic"&gt;Link 2&lt;span&gt;&lt;/span&gt;&lt;/a&gt;
            &lt;p&gt;Content&lt;/p&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;
</code></pre>