Index: project.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/project.inc,v
retrieving revision 1.147
diff -u -p -r1.147 project.inc
--- project.inc	25 Nov 2009 16:38:15 -0000	1.147
+++ project.inc	18 Apr 2010 20:42:21 -0000
@@ -79,15 +79,27 @@ function project_project_form($node, $fo
       '#required' => TRUE,
     );
     $select_size = max(5, 2*count($top_level));
-    foreach ($options as $tid => $values) {
-      $form['project_taxonomy']["tid_$tid"] = array(
-        '#title' => t('!type categories', array('!type' => $top_level[$tid])),
-        '#type' => 'select',
-        '#multiple' => TRUE,
-        '#options' => $values,
-        '#default_value' => $current_options,
-        '#attributes' => array('size' => min($select_size, count($values))),
-      );
+    foreach (array_keys($top_level) as $tid) {
+      if (isset($options[$tid])) {
+        $values = $options[$tid];
+        $form['project_taxonomy']["tid_$tid"] = array(
+          '#title' => t('@type categories', array('@type' => $top_level[$tid])),
+          '#type' => 'select',
+          '#multiple' => TRUE,
+          '#options' => $values,
+          '#default_value' => $current_options,
+          '#attributes' => array('size' => min($select_size, count($values))),
+        );
+      }
+      else {
+        // provide a div for all top-level terms so that outside elements
+        // (vocabularies) can be shifted into the project taxonomy fieldset
+        // in the same paradigm as the modules sub-terms
+        $form['project_taxonomy']["tid_$tid"] = array(
+          '#type' => 'form_element',
+          '#id' => 'edit-tid-' . $tid,
+        );
+      }
     }
   }
 
Index: project.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/project.js,v
retrieving revision 1.3
diff -u -p -r1.3 project.js
--- project.js	12 Jan 2009 20:07:19 -0000	1.3
+++ project.js	18 Apr 2010 20:42:21 -0000
@@ -7,6 +7,7 @@ Drupal.behaviors.projectAuto = function 
       if (this.checked) {
         tid = this.value;
       }
+      Drupal.projectMoveElement(this.value);
     })
     .click(function () {
       Drupal.projectSetTaxonomy(this.value);
@@ -14,20 +15,28 @@ Drupal.behaviors.projectAuto = function 
   Drupal.projectSetTaxonomy(tid);
 }
 
+Drupal.projectMoveElement = function(tid) {
+  // move all elements with a class linked to this tid into the
+  // project taxonomy fieldset (similar to module sub-terms)
+  $('.related-tid-' + tid).each(function() {
+    if ($(this).parent().siblings().size() == 1) {
+      $(this).parent().parent().remove();
+    }
+    $('#edit-tid-' + tid + '-wrapper').append($(this).parent().remove());
+  }); 
+}
+
 Drupal.projectSetTaxonomy = function (tid) {
   $('div.project-taxonomy-element select').each(function () {
-    // If this is the selector for the currently selected
-    // term, show it (in case it was previously hidden).
-    if (this.id == 'edit-tid-' + tid) {
+    // If this is the selector for the currently selected term or a
+    // related element, show it (in case it was previously hidden).
+    if (this.id == 'edit-tid-' + tid || $(this).hasClass('related-tid-' + tid)) {
       // Hide not the select but its containing div (which also contains
       // the label).
       $(this).parents('div.form-item').show();
     }
-    // Otherwise, empty it and hide it.
+    // Otherwise, hide it.
     else {
-      // In case terms were previously selected, unselect them.
-      // They are no longer valid.
-      this.selectedIndex = -1;
       $(this).parents('div.form-item').hide();
     }
   });
Index: project.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/project.module,v
retrieving revision 1.356
diff -u -p -r1.356 project.module
--- project.module	30 Jan 2010 02:43:23 -0000	1.356
+++ project.module	18 Apr 2010 20:42:21 -0000
@@ -333,6 +333,22 @@ function project_settings_form() {
     variable_set('project_enable_alias', FALSE);
   }
 
+  $vocabs = taxonomy_get_vocabularies('project_project');
+  $tree = taxonomy_get_tree(_project_get_vid(), 0, -1, 1);
+  $top_level = array(t('- None -'));
+  foreach ($tree as $i => $term) {
+    $top_level[$term->tid] = $term->name;
+  }
+  foreach ($vocabs as $vid => $vocab) {
+    $form['settings']['project_type_associated_tid_' . $vid] = array(
+      '#title' => t('Associated Project type taxonomy term for @vocab', array('@vocab' => $vocab->name)),
+      '#type' => 'select',
+      '#options' => $top_level,
+      '#default_value' => isset($form['vid']['#value']) ? variable_get('project_type_associated_tid_'. $form['vid']['#value'], NULL) : NULL,
+      '#description' => t('If this vocabulary is specific to a project type, set the term here to allow Project to automatically show and hide the form as necessary.'),
+    );
+  }
+
   return system_settings_form($form);
 }
 
@@ -406,8 +422,11 @@ function project_term_path($term) {
  * Implementation of hook_taxonomy().
  */
 function project_taxonomy($op, $type, $array = NULL) {
-  if ($op == 'delete' && $type == 'vocabulary' && $array['vid'] == _project_get_vid())  {
-    variable_del('project_vocabulary');
+  if ($op == 'delete' && $type == 'vocabulary') {
+    if ($array['vid'] == _project_get_vid())  {
+      variable_del('project_vocabulary');
+    }
+    variable_del('project_type_associated_tid_' . $array['vid']);
   }
 }
 
@@ -572,10 +591,21 @@ function project_form_alter(&$form, &$fo
       if (isset($form['taxonomy'][$vid])) {
         unset($form['taxonomy'][$vid]);
       }
-      // If there are no children elements, we should unset the entire
-      // thing so we don't end up with an empty fieldset.
-      if (!empty($form['taxonomy']) && (!element_children($form['taxonomy']))) {
-        unset($form['taxonomy']);
+      if (!empty($form['taxonomy'])) {
+        // If there are no children elements, we should unset the entire
+        // thing so we don't end up with an empty fieldset.
+        if (!element_children($form['taxonomy'])) {
+          unset($form['taxonomy']);
+        }
+        else {
+          foreach (array_keys($form['taxonomy']) as $vid) {
+            if (is_numeric($vid) && $tid == variable_get('project_type_associated_tid_'. $vid, NULL)) {
+              // If our vocabulary is related to a top-level project taxonomy term
+              // give it a related-tid value so we can shift it into the taxonomy fieldset
+              $form['taxonomy'][$vid]['#attributes']['class'] = 'related-tid-'. $tid;
+            }
+          }
+        }
       }
   
       // In D6, FAPI changed in such a way that completely unsetting
@@ -588,7 +618,10 @@ function project_form_alter(&$form, &$fo
       if (isset($form['buttons']['preview'])) {
         $form['buttons']['preview']['#submit'][] = 'project_project_form_preview_submit';
       }
-  
+
+      // Add a submit to clean up vocabularies associated with the project type.
+      $form['#submit'][] = 'project_project_form_submit';
+
       // If the form has an element for specifying a URL alias, we want
       // to alter it, since we're just going to automatically override
       // the specified value.
@@ -1133,6 +1166,20 @@ function project_project_form_preview_su
 }
 
 /**
+ * Remove terms from non-related vocabularies based on the current project type.
+ */
+function project_project_form_submit($form, &$form_state) {
+  if (isset($form_state['values']['taxonomy']) && isset($form_state['values']['project_type'])) {
+    foreach ($form_state['values']['taxonomy'] as $vid => $terms) {
+      $associated = variable_get('project_type_associated_tid_' . $vid, FALSE);
+      if ($associated && $associated != $form_state['values']['project_type']) {
+        unset ($form_state['values']['taxonomy'][$vid]);
+      }
+    }
+  }
+}
+
+/**
  * Present a validation error if the user tries to make the
  * Project types vocabulary a free tagging vocabulary.
  */
