diff -urp tableofcontents/tableofcontents.js tableofcontents2/tableofcontents.js
--- tableofcontents/tableofcontents.js	2007-11-26 01:53:21.000000000 +0100
+++ tableofcontents2/tableofcontents.js	2007-11-26 01:41:07.000000000 +0100
@@ -1,14 +1,14 @@
+// Global Killswitch
 if (Drupal.jsEnabled) {
   $(document).ready( function () {
-    $('a.toc-toggle').click(function() {
-      $('.toc-list').slideToggle();
-	  var text = $('a.toc-toggle').text();
-	  if (text == 'hide') {
-		  $('a.toc-toggle').text('show');
-      } else {
-		  $('a.toc-toggle').text('hide');
-      }
-	  return false;
-	});
+    // Turn toc-title's into clickable links
+    $('.toc .toc-title').each(function() {
+      var text = this.innerHTML;
+    
+      $(this).empty().append($('<a href="#">'+ text +'</a>').click(function() {
+        $('.toc-list').slideToggle();
+        return false;
+      }));
+    });
   });
 }
\ No newline at end of file
diff -urp tableofcontents/tableofcontents.module tableofcontents2/tableofcontents.module
--- tableofcontents/tableofcontents.module	2007-11-26 01:53:21.000000000 +0100
+++ tableofcontents2/tableofcontents.module	2007-11-26 01:53:00.000000000 +0100
@@ -72,10 +72,6 @@ function tableofcontents_filter($op, $de
       // to optimize performance enclose preparation in conditional that tests for presence of ToC marker
       if ($options_str[0][0] != "") {
 
-        // include required jquery and css
-        drupal_add_js(drupal_get_path('module', 'tableofcontents') . '/tableofcontents.js');
-        drupal_add_css(drupal_get_path('module', 'tableofcontents') . '/tableofcontents.css');
-
         // set defaults
         $toc_options = array();
         $toc_options["title"] = "Table of Contents";
@@ -171,39 +167,8 @@ function tableofcontents_filter($op, $de
             'anchor' => $anchor)
           );
         }
-        // Build HTML for the Table of Contents
-        $toc_html = "<div class=\"toc\">\n<div class=\"toc-title\">" .
-        $toc_options["title"] . " [<a href=\"#\" class=\"toc-toggle\">hide</a>]</div>\n<div class=\"toc-list\">\n<" .
-        $toc_options["list"] . ">\n";
-
-        $depth = $toc_options["minlevel"];
-        foreach ($toc as $title) {
-
-          // process nested lists
-          $curdepth = $title['level'];
-          if ($curdepth <= $toc_options["maxlevel"]) {
-            // Be sure to deal with skipping between non-adjacent h levels
-            while ($curdepth != $depth) {
-              if ($curdepth > $depth) {
-                $toc_html .= "<" . $toc_options["list"] . ">\n";
-                $depth++;
-              }
-              else if ($curdepth < $depth) {
-                $toc_html .= "</" . $toc_options["list"] . ">\n";
-                $depth--;
-              }
-            }
-
-            // insert the li element
-            $toc_html .= "<li><a href=\"#".$title['anchor']."\">".$title['heading']."</a></li>\n";
-          }
-        }
-        // Did we recurse back out? If not, close open lists.
-        while ($depth > $toc_options["minlevel"]) {
-          $toc_html .= "</" . $toc_options["list"] . ">\n";
-          $depth = $depth -1;
-        }
-        $toc_html .= "</".$toc_options["list"].">\n</div>\n</div>";
+        
+        $toc_html = theme("tableofcontents_toc", $toc, $toc_options);
 
         // replace all tableofcontents markers with generated ToC html
         return preg_replace('!<\!-- ?tableofcontents(.*)-->!', $toc_html, $text);
@@ -212,4 +177,49 @@ function tableofcontents_filter($op, $de
         return $text;
       }
   }
-}
\ No newline at end of file
+}
+
+/**
+ * How the tableofcontents's HTML should be themed
+ *
+ * @ingroup themeable
+ */
+function theme_tableofcontents_toc($toc, $options) {
+  // include required jquery and css
+  drupal_add_js(drupal_get_path('module', 'tableofcontents') . '/tableofcontents.js');
+  drupal_add_css(drupal_get_path('module', 'tableofcontents') . '/tableofcontents.css');
+
+  // Build HTML for the Table of Contents
+  $html = "<div class=\"toc\">\n<div class=\"toc-title\">" . $options["title"] . "</div>\n";
+  $html .= "<" . $options["list"] . " class=\"toc-list\">\n";
+
+  $depth = $options["minlevel"];
+  foreach ($toc as $title) {
+
+    // process nested lists
+    $curdepth = $title['level'];
+    if ($curdepth <= $options["maxlevel"]) {
+      // Be sure to deal with skipping between non-adjacent h levels
+      while ($curdepth != $depth) {
+        if ($curdepth > $depth) {
+          $html .= "<" . $options["list"] . ">\n";
+          $depth++;
+        }
+        else if ($curdepth < $depth) {
+          $html .= "</" . $options["list"] . ">\n";
+          $depth--;
+        }
+      }
+
+      // insert the li element
+      $html .= "<li><a href=\"#".$title['anchor']."\">".$title['heading']."</a></li>\n";
+    }
+  }
+  // Did we recurse back out? If not, close open lists.
+  while ($depth > $options["minlevel"]) {
+    $html .= "</" . $options["list"] . ">\n";
+    $depth = $depth -1;
+  }
+  $html .= "</".$options["list"].">\n</div>";
+  return $html;
+}
