That is absolutely brilliant!!!
I was so intrigued, I tried it out and it works like a dream, thank you.
So, please find attached replacement files for the Moodle 2 version to test. I have included a YUI Compressed version of 'lib.js' -> 'lib_min.js' to save altering the top of 'format.php' to use the human readable form. To install, make sure you have a backup copy, then replace with the files. If you have a custom css file, then instead of replacing collapsed_topics.css, copy the 'collapsed_topic' class definition at the bottom and add it to your own.
There is also 'lib.js' for reference using a new browser version technique I found on the web.
If all is good, I will put into the full version and credit you in the Readme :D.
Developer of Collapsed Topics.