Index: content_taxonomy.module
===================================================================
--- content_taxonomy.module	(revision 1077)
+++ content_taxonomy.module	(working copy)
@@ -84,6 +84,13 @@
         '#options' => $options_voc,
         '#description' => t('Terms of the selected vocabulary get exposed to the field'),
       );
+      $form['vids'] = array(
+        '#title' => t('Vocabularies'),
+        '#type' => 'checkboxes',
+        '#default_value' => count($field['vids']) > 0 ? $field['vids'] : array(),
+        '#options' => $options_voc,
+        '#description' => t('Terms of the selected vocabularies get exposed to the field'),
+      );
       
       $form['hierarchical_vocabulary'] = array(
         '#type' => 'fieldset',
@@ -123,7 +130,7 @@
       return $form;   
     
     case 'save':
-      return array('save_term_node', 'vid', 'parent', 'parent_php_code', 'depth');
+      return array('save_term_node', 'vid', 'vids', 'parent', 'parent_php_code', 'depth');
     
     case 'database columns':
       return array(
Index: content_taxonomy_autocomplete.module
===================================================================
--- content_taxonomy_autocomplete.module	(revision 1077)
+++ content_taxonomy_autocomplete.module	(working copy)
@@ -139,6 +139,7 @@
     '#default_value' => isset($items) ? $items : NULL,
     '#value_callback' => 'content_taxonomy_autocomplete_value',
     '#vid' => $field['vid'],
+    '#vids' => $field['vids'],
   );
   return $element;
 }
@@ -156,7 +157,7 @@
       $terms[] = taxonomy_get_term($entry[$field_key]);
     }
   }
-  $value = content_taxonomy_autocomplete_merge_tags($terms, $element['#vid']);
+  $value = content_taxonomy_autocomplete_merge_tags($terms, $element['#vids']);
   $value = !empty($value) ? $value : NULL;
   return array($field_key => $value);
 }
@@ -219,7 +220,7 @@
   
   $value = $element['#value'];
  
-  $extracted_ids = content_taxonomy_autocomplete_tags_get_tids($value, $field['vid'], content_taxonomy_field_get_parent($field), $field['widget']['extra_parent']);
+  $extracted_ids = content_taxonomy_autocomplete_tags_get_tids($value, $field['vid'], $field['vids'], content_taxonomy_field_get_parent($field), $field['widget']['extra_parent']);
 
   if (!$field['multiple'] && count(content_taxonomy_autocomplete_split_tags($value, $field['vid'])) > 1) {
     form_set_error($field['field_name'] .'][value', t('You can provide only one value'));
@@ -273,6 +274,7 @@
   // this, "somecmpany, llc", "and ""this"" w,o.rks", foo bar
   $content_type_info = _content_type_info();
   $vid = $content_type_info['fields'][$field_name]['vid'];
+  $vids = $content_type_info['fields'][$field_name]['vids'];
   $tid = content_taxonomy_field_get_parent($content_type_info['fields'][$field_name]);
   
   // If the menu system has splitted the search text because of slashes, glue it back.
@@ -299,9 +301,9 @@
     else {
       $result = db_query_range(db_rewrite_sql("SELECT t.name FROM {term_data} t 
         LEFT JOIN {term_synonym} s ON t.tid = s.tid
-        WHERE t.vid = %d 
+        WHERE t.vid IN (%s) 
         AND (LOWER(t.name) LIKE LOWER('%%%s%%') OR LOWER(s.name) LIKE LOWER('%%%s%%'))", 't', 'tid'),
-        $vid, $last_string, $last_string, 0, 10);
+	implode(',', $vids), $last_string, $last_string, 0, 10);
     }
     $prefix = count($array) ? '"'. implode('", "', $array) .'", ' : '';
 
@@ -323,8 +325,10 @@
  *  Free tagging vocabularies do not send their tids in the form,
  *  so we'll detect them here and process them independently.
  * @param $typed_input A string containing all comma separated tags. As the user typed it.
+ * @param $vid primary vocabulary id (where to write to)
+ * @param $vids secondary vocabulary ids (where to search for tags)
  */
-function content_taxonomy_autocomplete_tags_get_tids($typed_input, $vid, $parent = 0, $extra_parent = 0) {
+function content_taxonomy_autocomplete_tags_get_tids($typed_input, $vid, $vids, $parent = 0, $extra_parent = 0) {
   // This regexp allows the following types of user input:
   // this, "somecmpany, llc", "and ""this"" w,o.rks", foo bar
   $typed_terms = content_taxonomy_autocomplete_split_tags($typed_input);
@@ -336,13 +340,13 @@
     $typed_term = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $typed_term)));
     if ($typed_term == "") { continue; }
     
-    // See if the term exists in the chosen vocabulary
+    // See if the term exists in the chosen vocabularies
     // and return the tid, otherwise, add a new record.
     $possibilities = taxonomy_get_term_by_name($typed_term);
 
     $typed_term_tid = NULL; // tid match if any.
     foreach ($possibilities as $possibility) {
-      if ($possibility->vid == $vid) {
+      if (in_array($possibility->vid, $vids)) {
         if ($parent) {
           $parents = array();
           $parents = taxonomy_get_parents($possibility->tid);
@@ -370,7 +374,7 @@
 }
 
 /**
- * Insert new tags
+ * Insert new tags. Note that terms are inserted into the primary vocabulary.
  *
  * @param $nid the node id
  * @param $terms an array of all <strong>nonexisting</strong> terms.
@@ -398,12 +402,12 @@
 /**
  * Helper function to merge the tags, to prefill the fields when editing a node.
  */
-function content_taxonomy_autocomplete_merge_tags($terms, $vid) {
+function content_taxonomy_autocomplete_merge_tags($terms, $vids) {
   $typed_terms = array();
   if (!empty($terms)) {
     foreach ($terms as $term) {
-      // Extract terms belonging to the vocabulary in question.
-      if ($term->vid == $vid) {
+      // Extract terms belonging to the vocabularies in question.
+      if (in_array($term->vid, $vids)) {
         //if ($tid && in_array($term->tid,drupal_map_assoc(array_keys((taxonomy_get_children($tid,$vid)))))) {
           // Commas and quotes in terms are special cases, so encode 'em.
           $name = $term->name;
