Index: hierarchical_select.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hierarchical_select/hierarchical_select.module,v
retrieving revision 1.9
diff -u -r1.9 hierarchical_select.module
--- hierarchical_select.module	26 Dec 2007 14:11:07 -0000	1.9
+++ hierarchical_select.module	28 Dec 2007 17:18:16 -0000
@@ -391,6 +391,57 @@
       }
     }
     $output .= '</select>';
+
+    $max_depth = sizeof($hierarchy->lineage)-1;
+    if ($max_depth == $depth) {
+      if ($hierarchy->levels[$depth-1][$hierarchy->lineage[$depth-1]]) { 
+        $term_parent = $hierarchy->levels[$depth-1][$hierarchy->lineage[$depth-1]];
+        $tid = $hierarchy->lineage[$depth-1];
+        $vocab = db_result(db_query("SELECT vid FROM {term_data} WHERE tid = $tid")); // TODO: there hs to be a better way to get the the vid!
+      }
+      else {
+        $term_parent = $hierarchy->levels[$depth]['label_0'];
+        $tid = $hierarchy->lineage[$depth-1];
+        $vocab = 1; // TODO: there hs to be a way to get the the vid!
+      }
+
+      $output .= '
+        <style type="text/css">
+           #hs_add_form {
+             display:none;
+           }
+           
+           .hs_add_text {
+             font-size:9px;
+           }
+        </style>
+        <script type="text/javascript">
+
+           $("a#hs_add_child").click(function(){
+             $(this).hide();
+             $("#hs_add_form").show();
+             return false;
+           });
+
+           $("a#hs_add_cancel").click(function(){
+             $("a#hs_add_child").show();
+             $("#hs_add_form").hide();
+             return false;
+           });
+
+        </script>';
+
+      $output .= '<a id="hs_add_child" class="hs_add_text" href="#"> add term</a>';
+      
+      // Example. TODO: find out how to do it with Form API.
+      $output .= '<span id="hs_add_form">';
+      $output .= '<input type="text">';
+      $output .= '<a id="hs_add_cancel" class="hs_add_text" href="#"> Cancel</a>';
+      $output .= '<span class="hs_add_text"> | </span>';
+      $output .= '<a class="hs_add_text" href="/hierarchical_select_add/'. $vocab . '/' . $hierarchy->lineage[$depth-1] .'">add '.$hierarchy->levels[$depth]['label_'.$depth].' to ' . $term_parent . '.</a>';
+      $output .= '</span>';
+      
+    }
   }
 
   return $output;
