--- tax.module	2007-03-11 13:32:06.000000000 +0100
+++ tax_new.module	2007-03-20 19:43:29.000000000 +0100
@@ -120,6 +120,18 @@ function tax_checkoutapi(&$txn, $op, $ar
               }
             }
             break;
+          default:
+            if (strstr($rule->realm, 'ec_region')) {
+              $regid = end(explode('_', $rule->realm));
+              $region_configuration = ec_region_get_configuration($realm = NULL, $geo_type = NULL, $regid, $geo_code = NULL);
+              foreach ($region_configuration as $region) {
+                if (drupal_strtoupper($billing->country) == drupal_strtoupper($region->geo_code)  && tax_rule_product_match($txn, $rule)) {
+                  if ($tax = tax_calculate($taxable_amount, $rule->operand, $rule->operator)) {
+                    $total_tax += $tax;
+                  }
+                }
+              }
+            }
         }
       }
       if ($total_tax) {
@@ -304,6 +316,15 @@ function tax_form_screen1($edit = array(
     'country' => t('Country'), 
     'city' => t('City')
   );
+  if (module_exists('ec_region')) {
+    $regions = ec_region_get_regions('', 'ec_region');
+    if (is_array($regions)) {
+      foreach($regions as $regid => $region) {
+        $reg[$region['region_realm'] .'_'. $regid] = $region['region_name'];
+      }
+      $locations = array_merge($locations, $reg);
+    }
+  }
   $form['realm'] = array(
     '#type' => 'select',
     '#title' => t('Type of Location to define the new tax rule for'),
@@ -350,6 +371,17 @@ function tax_form_screen2($edit = array(
       '#description' => t('This value will be checked against the customer\'s shipping address.'), 
     );
   }
+  elseif (strstr($edit['realm'], 'ec_region')) {
+    $regid = end(explode('_', $edit['realm']));
+    $region = ec_region_get_regions($regid, 'ec_region');
+    $form['realm_value'] = array(
+      '#type' => 'textfield',
+      '#disabled' => TRUE,
+      '#value' => $region[$regid]['region_name'], 
+      '#title' => t('Region to check against to'),
+      '#description' => t('This is the name of the region to check against to. You can set this region !url', array('!url' => l(t('here'), 'admin/ecsettings/regions/ec_region'))), 
+    );
+  }
   else {
     #$form = tax_invoke_taxapi($edit, 'admin form');
     #$output .= $form[0];
