--- taxonomy_vtn/taxonomy_vtn.pages.inc.orig	2008-12-07 22:15:50.000000000 -0800
+++ taxonomy_vtn/taxonomy_vtn.pages.inc	2008-12-07 23:26:03.000000000 -0800
@@ -174,7 +174,7 @@
     else {
       drupal_set_title(t('Bad vocabulary id'));
       $output  = '<p class="no-data-info">';
-      $output .= t('No data to display. Probably you not have a vocabulary with vid = !voc_id', array('!voc_id' => $own_vid));
+      $output .= t('No data to display. You probably have no vocabulary with vid = !voc_id', array('!voc_id' => $own_vid));
       $output .= '</p>';
       $terms_navigation = '';
       if (variable_get('taxonomy_vtn_terms_show_back_to_voc', 1) == 1) {
@@ -206,14 +206,14 @@
 
     // vocabulary vid is ok, lets do it
 
-    $show_empty_terms = variable_get('taxonomy_vtn_terms_show_empty_terms', 1);
-    $show_count_nodes = variable_get('taxonomy_vtn_terms_show_count_nodes', 1);
-    $show_term_desc = variable_get('taxonomy_vtn_terms_show_term_desc', 1);
-    $show_synonyms = variable_get('taxonomy_vtn_terms_show_synonyms', 1);
-    $count_group_terms =  variable_get('taxonomy_vtn_terms_count_group_terms', 1);
-    $count_column_terms =  variable_get('taxonomy_vtn_terms_count_column_terms', 2);
-    $term_goto = variable_get('taxonomy_vtn_terms_goto', 'nodes');
-    $show_back_to_voc = variable_get('taxonomy_vtn_terms_show_back_to_voc', 1);
+    $show_empty_terms = variable_get("taxonomy_vtn_terms_show_empty_terms$own_vid", 1);
+    $show_count_nodes = variable_get("taxonomy_vtn_terms_show_count_nodes$own_vid", 1);
+    $show_term_desc = variable_get("taxonomy_vtn_terms_show_term_desc$own_vid", 1);
+    $show_synonyms = variable_get("taxonomy_vtn_terms_show_synonyms$own_vid", 1);
+    $count_group_terms =  variable_get("taxonomy_vtn_terms_count_group_terms$own_vid", 1);
+    $count_column_terms =  variable_get("taxonomy_vtn_terms_count_column_terms$own_vid", 2);
+    $term_goto = variable_get("taxonomy_vtn_terms_goto$own_vid", 'nodes');
+    $show_back_to_voc = variable_get("taxonomy_vtn_terms_show_back_to_voc$own_vid", 1);
 
     // TODO: for depth use:  if ( $terms = taxonomy_get_tree($own_vid,0,-1,3) ) {
     if ( $terms = taxonomy_get_tree($own_vid) ) {
@@ -224,7 +224,9 @@
       $is_desc = false;
 
       // exclude some terms_id
-      $omit_terms = explode(', ', variable_get('taxonomy_vtn_terms_omit', ''));
+      $omit_str = variable_get("taxonomy_vtn_terms_omit$own_vid", '')
+                . variable_get('taxonomy_vtn_terms_omit', '');  // include the global variables too
+      $omit_terms = explode(', ', $omit_str);
 
        /// prepare own full structure with terms and synonyms and link to them
       foreach ($terms as $term) {
@@ -421,7 +424,7 @@
  */
 function taxonomy_vtn_show_nodes($arg = '') {
 
-  // check for excluded voc_id
+  // check for globally excluded voc_id
   $omit_terms = explode(', ', variable_get('taxonomy_vtn_terms_omit', ''));
 
   if (!empty($omit_terms)) {
@@ -472,14 +475,14 @@
   }
   else {
 
-    $show_count_comments = variable_get('taxonomy_vtn_nodes_show_count_comments', 1);
-    $count_column_nodes = variable_get('taxonomy_vtn_nodes_count_column_nodes', 2);
-    $show_empty_count_comments = variable_get('taxonomy_vtn_nodes_show_empty_count_comments', 0);
-    $show_nodes_index = variable_get('taxonomy_vtn_nodes_show_nodes_index', 0);
-    $show_back_to_terms = variable_get('taxonomy_vtn_nodes_show_back_to_terms', 1);
+    $show_count_comments = variable_get("taxonomy_vtn_nodes_show_count_comments$own_tid", 1);
+    $count_column_nodes = variable_get("taxonomy_vtn_nodes_count_column_nodes$own_tid", 2);
+    $show_empty_count_comments = variable_get("taxonomy_vtn_nodes_show_empty_count_comments$own_tid", 0);
+    $show_nodes_index = variable_get("taxonomy_vtn_nodes_show_nodes_index$own_tid", 0);
+    $show_back_to_terms = variable_get("taxonomy_vtn_nodes_show_back_to_terms$own_tid", 1);
     
-    if ($use_pager = (bool)variable_get('taxonomy_vtn_nodes_use_pager', FALSE) === TRUE) {
-      $links_per_page = variable_get('taxonomy_vtn_nodes_links_per_page', 10);
+    if ($use_pager = (bool)variable_get("taxonomy_vtn_nodes_use_pager$own_tid", FALSE) === TRUE) {
+      $links_per_page = variable_get("taxonomy_vtn_nodes_links_per_page$own_tid", 10);
     } 
     else {
       $links_per_page = 0;
--- taxonomy_vtn/taxonomy_vtn.module.orig	2008-12-07 23:53:37.000000000 -0800
+++ taxonomy_vtn/taxonomy_vtn.module	2008-12-07 23:51:27.000000000 -0800
@@ -316,134 +316,203 @@
   );
   $form['terms']['taxonomy_vtn_terms_show_back_to_voc'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Show') .' "<strong>'. t('back to vocabularies') .'</strong>"',
+    '#title' => t('Show') .' "<strong>'. t('back to vocabularies') .'</strong>" on errors.',
     '#default_value' => variable_get('taxonomy_vtn_terms_show_back_to_voc', 1),
   );
-  $form['terms']['taxonomy_vtn_terms_show_term_desc'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Show descriptions'),
-    '#default_value' => variable_get('taxonomy_vtn_terms_show_term_desc', 1)
-  );
-  $form['terms']['taxonomy_vtn_terms_show_count_nodes'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Show count of nodes'),
-    '#default_value'  => variable_get('taxonomy_vtn_terms_show_count_nodes', 1)
-  );
-  $form['terms']['taxonomy_vtn_terms_show_empty_terms'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Show empty'),
-    '#default_value' => variable_get('taxonomy_vtn_terms_show_empty_terms', 1)
-  );
-  $form['terms']['taxonomy_vtn_terms_show_synonyms'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Show synonyms'),
-    '#default_value' => variable_get('taxonomy_vtn_terms_show_synonyms', 1)
+  $form['terms']['taxonomy_vtn_terms_omit'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Exclude terms id from all tables'),
+    '#description' => t('Example: 1, 3, 11, 5'),
+    '#default_value' =>  variable_get('taxonomy_vtn_terms_omit', '')
   );
 
-  $options = array(
-    '1' => t('One'),
-    '2' => t('Two'),
-    '3' => t('Three')
-  );
-  $form['terms']['taxonomy_vtn_terms_count_group_terms'] = array(
-    '#type' => 'select',
-    '#title' => t('Letters to group'),
-    '#description' => t('This settings make index grouped like, Example:') .' <em>A B C</em> '. t('or') .' <em>AB CD CE</em>',
-    '#default_value' => variable_get('taxonomy_vtn_terms_count_group_terms', 1),
-    '#options' => $options
-  );
 
-  $options = array(
-    '1' => t('One'),
-    '2' => t('Two'),
-    '3' => t('Three')
-  );
-  $form['terms']['taxonomy_vtn_terms_count_column_terms'] = array(
-    '#type' => 'select',
-    '#title' => t('Number of columns'),
-    '#default_value' => variable_get('taxonomy_vtn_terms_count_column_terms', 2),
-    '#options' => $options,
-  );
+  return system_settings_form($form);
+}
 
-  $options = array(
-    'nodes' => t('List of nodes'),
-    'taxonomy_term' => 'taxonomy/term/xxx',
-    'taxonomy_term_all' => 'taxonomy/term/xxx/all',
-  );
-  $form['terms']['taxonomy_vtn_terms_goto'] = array(
-    '#type' => 'select',
-    '#title' => t('Where we go on click a term'),
-    '#default_value' => variable_get('taxonomy_vtn_terms_goto', 'nodes'),
-    '#options' => $options,
-  );
 
+/**
+ * Implementation of hook_form_alter()
+ */
+function taxonomy_vtn_form_alter(&$form, $form_state, $form_id) {
+  if (!$form_state['submitted']) {
+    switch ($form_id) {
+    case 'taxonomy_form_vocabulary':
 
-  $form['terms']['taxonomy_vtn_terms_omit'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Exclude terms id'),
-    '#description' => t('Example: 1, 3, 11, 5'),
-    '#default_value' =>  variable_get('taxonomy_vtn_terms_omit', '')
-  );
+//echo "<pre>FORM ID = $form_id</pre>\n";
+//echo "<pre>FORM----\n";
+//var_dump($form);
+//echo "\n</pre>\n";
+//echo "<pre>FORM_STATE----\n";
+//var_dump($form_state);
+//echo "\n</pre>\n";
 
+      $vid = $form['vid']['#value'];
 
+      // terms
+      $form['terms'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('VTN Terms'),
+        '#description' => t('Set how show the terms index'),
+        '#collapsible' => TRUE,
+        '#collapsed' => FALSE
+      );
+      $form['terms']["taxonomy_vtn_terms_show_back_to_voc$vid"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Show') .' "<strong>'. t('back to vocabularies') .'</strong>"',
+        '#default_value' => variable_get("taxonomy_vtn_terms_show_back_to_voc$vid", 1),
+      );
+      $form['terms']["taxonomy_vtn_terms_show_term_desc$vid"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Show descriptions'),
+        '#default_value' => variable_get("taxonomy_vtn_terms_show_term_desc$vid", 1)
+      );
+      $form['terms']["taxonomy_vtn_terms_show_count_nodes$vid"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Show count of nodes'),
+        '#default_value'  => variable_get("taxonomy_vtn_terms_show_count_nodes$vid", 1)
+      );
+      $form['terms']["taxonomy_vtn_terms_show_empty_terms$vid"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Show empty'),
+        '#default_value' => variable_get("taxonomy_vtn_terms_show_empty_terms$vid", 1)
+      );
+      $form['terms']["taxonomy_vtn_terms_show_synonyms$vid"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Show synonyms'),
+        '#default_value' => variable_get("taxonomy_vtn_terms_show_synonyms$vid", 1)
+      );
 
-  // nodes
-  $form['nodes'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Nodes'),
-    '#description' => t('Set how show the nodes index'),
-    '#collapsible' => TRUE,
-    '#collapsed' => FALSE,
-  );
-  $form['nodes']['taxonomy_vtn_nodes_show_back_to_terms'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Show') .' "<strong>'. t('back to terms') .'</strong>"',
-    '#default_value' => variable_get('taxonomy_vtn_nodes_show_back_to_terms', 1),
-  );
-  $form['nodes']['taxonomy_vtn_nodes_show_count_comments'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Show count of comments'),
-    '#default_value' => variable_get('taxonomy_vtn_nodes_show_count_comments', 1),
-  );
-  $form['nodes']['taxonomy_vtn_nodes_show_empty_count_comments'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Show count for nodes with no comments'),
-    '#default_value' => variable_get('taxonomy_vtn_nodes_show_empty_count_comments', 0),
-  );
+      $options = array(
+        '1' => t('One'),
+        '2' => t('Two'),
+        '3' => t('Three')
+      );
+      $form['terms']["taxonomy_vtn_terms_count_group_terms$vid"] = array(
+        '#type' => 'select',
+        '#title' => t('Letters to group'),
+        '#description' => t('This settings make index grouped like, Example:') .' <em>A B C</em> '. t('or') .' <em>AB CD CE</em>',
+        '#default_value' => variable_get("taxonomy_vtn_terms_count_group_terms$vid", 1),
+        '#options' => $options
+      );
 
-  $options = array(
-    '1' => t('One'),
-    '2' => t('Two'),
-  );
-  $form['nodes']['taxonomy_vtn_nodes_count_column_nodes'] = array(
-    '#type' => 'select',
-    '#title' => t('Number of columns'),
-    '#default_value' => variable_get('taxonomy_vtn_nodes_count_column_nodes', 2),
-    '#options' => $options,
-  );
-  $form['nodes']['taxonomy_vtn_nodes_show_nodes_index'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Show index if number of columns are set to one column'),
-    '#default_value' => variable_get('taxonomy_vtn_nodes_show_nodes_index', 0),
-  );
-  
-  $form['nodes']['taxonomy_vtn_nodes_use_pager'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Use pager for nodes'),
-    '#default_value' => variable_get('taxonomy_vtn_nodes_use_pager', FALSE),
-  );
-  $form['nodes']['taxonomy_vtn_nodes_links_per_page'] = array(
-    '#type' => 'select',
-    '#options' => drupal_map_assoc(array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)),
-    '#title' => t('Links per page'),
-    '#description' => t('How many links should be displayed per page'),
-    '#default_value' => variable_get('taxonomy_vtn_nodes_links_per_page', 10),
-  );
+      $options = array(
+        '1' => t('One'),
+        '2' => t('Two'),
+        '3' => t('Three')
+      );
+      $form['terms']["taxonomy_vtn_terms_count_column_terms$vid"] = array(
+        '#type' => 'select',
+        '#title' => t('Number of columns'),
+        '#default_value' => variable_get("taxonomy_vtn_terms_count_column_terms$vid", 2),
+        '#options' => $options,
+      );
 
+      $options = array(
+        'nodes' => t('List of nodes'),
+        'taxonomy_term' => 'taxonomy/term/xxx',
+        'taxonomy_term_all' => 'taxonomy/term/xxx/all',
+      );
+      $form['terms']["taxonomy_vtn_terms_goto$vid"] = array(
+        '#type' => 'select',
+        '#title' => t('Where we go on click a term'),
+        '#default_value' => variable_get("taxonomy_vtn_terms_goto$vid", 'nodes'),
+        '#options' => $options,
+      );
 
-  return system_settings_form($form);
+      $form['terms']["taxonomy_vtn_terms_omit$vid"] = array(
+        '#type' => 'textfield',
+        '#title' => t('Exclude terms id from the terms table of this vocabulary'),
+        '#description' => t('Example: 1, 3, 11, 5'),
+        '#default_value' =>  variable_get("taxonomy_vtn_terms_omit$vid", '')
+      );
+
+
+
+
+      // nodes
+      $form['nodes'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('VTN Nodes'),
+        '#description' => t('Set how show the nodes index'),
+        '#collapsible' => TRUE,
+        '#collapsed' => FALSE,
+      );
+      $form['nodes']["taxonomy_vtn_nodes_show_back_to_terms$vid"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Show') .' "<strong>'. t('back to terms') .'</strong>"',
+        '#default_value' => variable_get("taxonomy_vtn_nodes_show_back_to_terms$vid", 1),
+      );
+      $form['nodes']["taxonomy_vtn_nodes_show_count_comments$vid"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Show count of comments'),
+        '#default_value' => variable_get("taxonomy_vtn_nodes_show_count_comments$vid", 1),
+      );
+      $form['nodes']["taxonomy_vtn_nodes_show_empty_count_comments$vid"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Show count for nodes with no comments'),
+        '#default_value' => variable_get("taxonomy_vtn_nodes_show_empty_count_comments$vid", 0),
+      );
+
+      $options = array(
+        '1' => t('One'),
+        '2' => t('Two'),
+      );
+      $form['nodes']["taxonomy_vtn_nodes_count_column_nodes$vid"] = array(
+        '#type' => 'select',
+        '#title' => t('Number of columns'),
+        '#default_value' => variable_get("taxonomy_vtn_nodes_count_column_nodes$vid", 2),
+        '#options' => $options,
+      );
+      $form['nodes']["taxonomy_vtn_nodes_show_nodes_index$vid"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Show index if number of columns are set to one column'),
+        '#default_value' => variable_get("taxonomy_vtn_nodes_show_nodes_index$vid", 0),
+      );
+      
+      $form['nodes']["taxonomy_vtn_nodes_use_pager$vid"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Use pager for nodes'),
+        '#default_value' => variable_get("taxonomy_vtn_nodes_use_pager$vid", FALSE),
+      );
+      $form['nodes']["taxonomy_vtn_nodes_links_per_page$vid"] = array(
+        '#type' => 'select',
+        '#options' => drupal_map_assoc(array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)),
+        '#title' => t('Links per page'),
+        '#description' => t('How many links should be displayed per page'),
+        '#default_value' => variable_get("taxonomy_vtn_nodes_links_per_page$vid", 10),
+      );
+
+      $form['#submit'][] = '_taxonomy_vtn_form_vocabulary_submit';
+      break;
+
+    }
+  }
 }
 
+/**
+ * Implementation of the submit function for the hook_alter_form()
+ */
+function _taxonomy_vtn_form_vocabulary_submit($form, &$form_state) {
+  $vid = $form_state['values']['vid'];
+
+  variable_set("taxonomy_vtn_terms_show_back_to_voc$vid", $form_state['values']["taxonomy_vtn_terms_show_back_to_voc$vid"]);
+  variable_set("taxonomy_vtn_terms_show_term_desc$vid", $form_state['values']["taxonomy_vtn_terms_show_term_desc$vid"]);
+  variable_set("taxonomy_vtn_terms_show_count_nodes$vid", $form_state['values']["taxonomy_vtn_terms_show_count_nodes$vid"]);
+  variable_set("taxonomy_vtn_terms_show_empty_terms$vid", $form_state['values']["taxonomy_vtn_terms_show_empty_terms$vid"]);
+  variable_set("taxonomy_vtn_terms_show_synonyms$vid", $form_state['values']["taxonomy_vtn_terms_show_synonyms$vid"]);
+  variable_set("taxonomy_vtn_terms_count_group_terms$vid", $form_state['values']["taxonomy_vtn_terms_count_group_terms$vid"]);
+  variable_set("taxonomy_vtn_terms_count_column_terms$vid", $form_state['values']["taxonomy_vtn_terms_count_column_terms$vid"]);
+  variable_set("taxonomy_vtn_terms_goto$vid", $form_state['values']["taxonomy_vtn_terms_goto$vid"]);
+  variable_set("taxonomy_vtn_terms_omit$vid", $form_state['values']["taxonomy_vtn_terms_omit$vid"]);
+  variable_set("taxonomy_vtn_nodes_show_back_to_terms$vid", $form_state['values']["taxonomy_vtn_nodes_show_back_to_terms$vid"]);
+  variable_set("taxonomy_vtn_nodes_show_count_comments$vid", $form_state['values']["taxonomy_vtn_nodes_show_count_comments$vid"]);
+  variable_set("taxonomy_vtn_nodes_show_empty_count_comments$vid", $form_state['values']["taxonomy_vtn_nodes_show_empty_count_comments$vid"]);
+  variable_set("taxonomy_vtn_nodes_count_column_nodes$vid", $form_state['values']["taxonomy_vtn_nodes_count_column_nodes$vid"]);
+  variable_set("taxonomy_vtn_nodes_show_nodes_index$vid", $form_state['values']["taxonomy_vtn_nodes_show_nodes_index$vid"]);
+  variable_set("taxonomy_vtn_nodes_use_pager$vid", $form_state['values']["taxonomy_vtn_nodes_use_pager$vid"]);
+  variable_set("taxonomy_vtn_nodes_links_per_page$vid", $form_state['values']["taxonomy_vtn_nodes_links_per_page$vid"]);
+}
 
 /**
  * Implementation of hook_taxonomy($op, $type, $array = NULL)
