--- sites\all\modules\nat\nat.module	Sat Jun 30 06:58:46 2007
+++ sites\all\modules\nat\natNew.module	Thu Jul 03 11:41:23 2008
@@ -95,7 +95,7 @@ function nat_nodeapi(&$node, $op, $tease
       $terms = _nat_add_terms($nat_config['types'][$node->type], $node->title, $body, $node->taxonomy, $node->nat['related'], $node->nat['synonyms']);
 
       // Save node-term association in the NAT table.
-      _nat_save_association($node->nid, $terms);
+      _nat_save_association($node->nid, $terms, $node->type);
       break;
     case 'update':
       $body = $node->body;
@@ -238,6 +238,12 @@ function nat_settings_form() {
       '#default_value' => isset($nat_config['node_links'][$type]) ? $nat_config['node_links'][$type] : 0,
       '#parents' => array('node_links', $type)
     );
+    $form['nat_'. $type]['node_term_'. $type] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Associate an automatically created NAT term with %type parent node?', array('%type' => $type)),
+      '#default_value' => isset($nat_config['node_term'][$type]) ? $nat_config['node_term'][$type] : 0,
+      '#parents' => array('node_term', $type)
+    );
   }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
 
@@ -254,6 +260,7 @@ function nat_settings_form_submit($form_
   $form_values['delete'] = array_filter($form_values['delete']);
   $form_values['node_links'] = array_filter($form_values['node_links']);
   $form_values['related'] = array_filter($form_values['related']);
+  $form_values['node_term'] = array_filter($form_values['node_term']);
 
   variable_set('nat_config', $form_values);
 
@@ -587,19 +594,43 @@ function _nat_delete_terms($nid) {
 }
 
 /**
- * Save node-term associations in the NAT table.
+ * Save node-term associations in the NAT table.  Optionally, associate the terms with a given node in the
+ * node_term table if the option is set for a given type in NAT's settings.
  *
  * @param $nid
  *   Node ID of the node.
  * @param $terms
  *   NAT-terms of the above node.
+ * @param $node_type
+ *   The type of the node.
  */
-function _nat_save_association($nid, $terms) {
+function _nat_save_association($nid, $terms, $node_type) {
+  $nat_config = variable_get('nat_config', array());
   foreach ($terms as $term) {
     db_query("INSERT INTO {nat} (nid, tid, vid) VALUES (%d, %d, %d)", $nid, $term['tid'], $term['vid']);
+	
+    if (isset($nat_config['node_term']["$node_type"])) {
+      db_query("INSERT INTO {term_node} (nid, tid) VALUES  (%d, %d)", $nid, $term['tid']);
+    }
+  }
+}
+/*
+function _nat_term_node_association($nid, $terms, $node_type) {
+
+  $nat_config = variable_get('nat_config', array());
+  
+  if (isset($nat_config['node_term']["$node_type"])) {
+    foreach ($terms as $term) {
+      db_query("INSERT INTO {term_node} (nid, tid) VALUES  (%d, %d)", $nid, $term['tid']);
+	}
   }
 }
 
+  if (isset($nat_config['node_term']["$node_type"])) {
+    db_query("INSERT INTO {term_node} (nid, tid) VALUES  (%d, %d)", $nid, $term['tid']);
+  }
+*/
+
 /**
  * Delete node-term associations from the NAT table.
  *
@@ -633,7 +664,7 @@ function _nat_sync_associations($associa
       $terms = _nat_add_terms(array($association[1]), $node['title'], $body);
 
       // Save node-term association in the NAT table.
-      _nat_save_association($node['nid'], $terms);
+      _nat_save_association($node['nid'], $terms, $node['type']);
 
       $counter++;
     }
