Index: modules/jstools/tabs/tabs.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jstools/tabs/tabs.module,v
retrieving revision 1.11
diff -u -r1.11 tabs.module
--- modules/jstools/tabs/tabs.module	9 Feb 2007 03:15:20 -0000	1.11
+++ modules/jstools/tabs/tabs.module	9 Feb 2007 03:44:50 -0000
@@ -6,26 +6,34 @@
  */
 
 function theme_tabs_tabset($tabs) {
+  static $names = array();
+  // Ensure name is unique.
+  $i = 0;
+  $name = $tabs['#name'];
+  // In case we have duplicate names...
+  while (in_array($tabs['#name'], $names)) {
+    $tabs['#name'] = $name . $i;
+    $i++;
+  }
+  $names[] = $tabs['#name'];
   tabs_load();
-  $index = 1;
   $output .= '<div class="drupal-tabs">';
   $output .= '<ul class="anchors">';
-  foreach ($tabs as $tab) {
-    $output .= '<li><a href="#section-'. $index .'" tabindex="'. $index .'">'. $tab['#title'] .'</a></li>';
-    $index++;
+  foreach (element_children($tabs) as $key) {
+    $index = $key + 1;
+    $output .= '<li><a href="#'. $tabs['#name'] .'-'. $index .'" tabindex="'. $index .'">'. $tabs[$key]['#title'] .'</a></li>';
   }
   $output .= '</ul>';
-  $index = 1;
-  foreach ($tabs as $tab) {
-    $output .= theme('tabs_page', $index, $tab);
-    $index++;
+  foreach (element_children($tabs) as $key) {
+    $index = $key + 1;
+    $output .= theme('tabs_page', $tabs['#name'], $index, $tabs[$key]);
   }
   $output .= '</div>';
   return $output;
 }
 
-function theme_tabs_page($index, $tab) {
-  $output .='<div id="section-'. $index .'" class="fragment">';
+function theme_tabs_page($name, $index, $tab) {
+  $output .='<div id="'. $name .'-'. $index .'" class="fragment">';
   $output .= '<h2 class="drupal-tabs-title">'. $tab['#title'] .'</h2>';
   $output .= $tab['#content'];
   $output .='</div>';
@@ -54,7 +62,10 @@
  * Example of tabs construction.
  */
 function tabs_example() {
-  $tabs = array();
+  // The name is the identifier of this tabset.
+  $tabs = array(
+    '#name' => 'example1',
+  );
   $tabs[] = array(
     '#title' => t('One'),
     '#content' => t('First tab content.'),
@@ -68,7 +79,10 @@
     '#content' => t('Third tab content.'),
   );
   
-  return theme('tabs_tabset', $tabs);
+  $output = theme('tabs_tabset', $tabs);
+  // Second set has the same #name, but will be renamed to avoid conflicts.
+  $output .= theme('tabs_tabset', $tabs);
+  return $output;
 }
 
 /**
