--- taxonomyblocks.module.ori	2009-01-13 19:01:36.000000000 +0100
+++ taxonomyblocks.module	2009-01-30 16:39:06.000000000 +0100
@@ -726,8 +726,49 @@ function taxonomy_recursive_array_builde
     }
   }
   
+  //patch
+  //if node is shown, add attribute to tids that are linked to the node
+  taxonomyblocks_highlight_active_terms($tree);
+  //end patch  
+  
   return $tree;
 }
+
+//patch
+function taxonomyblocks_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+  switch ($op) {
+    case 'view':
+      _taxonomyblocks_node_terms('set', $node);
+      break;
+  }
+}
+
+function _taxonomyblocks_node_terms($action = 'get', $node = NULL ) {
+  static $terms = array();
+  
+  switch ($action) {
+    case 'get':
+      return $terms;
+    case 'set':
+      $node_terms = array_keys(taxonomy_node_get_terms($node));
+      $terms = array_merge($terms, $node_terms);
+      break;
+  }
+}
+
+function taxonomyblocks_highlight_active_terms(&$tree) {
+  $terms = _taxonomyblocks_node_terms();
+  if (count($terms)) {
+    foreach ( $tree as $key => $values ) {
+      $tid = $values['link']['tid'];
+      if (in_array($tid, $terms)) {
+        $tree[$key]['link']['options']['attributes']['class'] = 'active_term';
+      }
+    }
+  }
+}
+//end patch
+
 function jq_taxonomy_tree_creator($vid, $pathpattern = NULL, $nodecounter = 'all', $titlepattern = NULL, $omit = NULL) {
   $tree = array();
   $toplevel = taxonomy_get_toplevel($vid);
