Accordian menu - how do you save it's state?

Accordian menu - how do you save it's state?

I've been using the accordian tutorial but was wanting to save it's state after I click the link

http://jquery.com/files/demo/dl-done.html

for instance if I open the accordian to heading two and click link 4 it would be great for it to stay like it on when link4 page loads (so the users know where they are)
eg:

Heading1
Heading2
-link4
-link4
-link6
Heading3

But instead it defaults back to

Heading1
-link1
-link2
-link3
Heading2
Heading3

Any help appreciated..

I have found this script that changes the class based on the page selected here.. but can't figure out how to implement it in the accordian menu

     $(function(){
   var path = location.pathname.substring(1);
   if ( path )
     $('#sidebar_content a[href$="' + path + '"]').attr('class', 'selected');
        });
       
       
        //When page loads...
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function() {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });
});