Index: vertical_tabs.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vertical_tabs/vertical_tabs.js,v
retrieving revision 1.3.2.13
diff -u -p -r1.3.2.13 vertical_tabs.js
--- vertical_tabs.js	19 May 2009 23:54:09 -0000	1.3.2.13
+++ vertical_tabs.js	29 Jun 2009 04:16:48 -0000
@@ -1,3 +1,5 @@
+// $Id$
+
 Drupal.verticalTabs = Drupal.verticalTabs || {};
 
 Drupal.behaviors.verticalTabs = function() {
Index: vertical_tabs.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vertical_tabs/vertical_tabs.module,v
retrieving revision 1.1.2.19
diff -u -p -r1.1.2.19 vertical_tabs.module
--- vertical_tabs.module	19 May 2009 01:39:32 -0000	1.1.2.19
+++ vertical_tabs.module	29 Jun 2009 04:16:48 -0000
@@ -20,6 +20,81 @@ function vertical_tabs_theme() {
 }
 
 /**
+ * Add a vertical tab form element to a form.
+ *
+ * @param $form
+ *   A form array to be altered.
+ * @param $fieldsets
+ *   An array of fieldsets to use in the vertical tabs. If no array is provided,
+ *   all the fieldsets in the $form array will be used.
+ * @return
+ *   TRUE if the vertical tabs were added to the form, otherwise FALSE.
+ */
+function vertical_tabs_add_vertical_tabs(&$form, $fieldsets = NULL) {
+  // The javascript to add to the page.
+  $settings = array();
+  // Iterate through the form, finding fieldsets.
+  foreach (element_children($form) as $delta => $key) {
+    // We need to make sure that the element we have is a fieldset
+    // and the user has access to this field.
+    if ((!isset($fieldsets) || in_array($key, $fieldsets)) &&
+      (isset($form[$key]['#type']) && $form[$key]['#type'] == 'fieldset') &&
+      (!isset($form[$key]['#access']) || $form[$key]['#access'] != FALSE)) {
+      // Add the JavaScript.
+      $settings[$key] = array(
+        'name' => $form[$key]['#title'],
+        'weight' => (isset($form[$key]['#weight']) ? $form[$key]['#weight'] : 0) + (0.01 * $delta),
+        'callback' => (isset($form[$key]['#summary_callback']) ? $form[$key]['#summary_callback'] : $key),
+        'args' => (isset($form[$key]['#summary_arguments']) ? $form[$key]['#summary_arguments'] : array()),
+      );
+      // Add a class to identify the fieldset.
+      if (isset($form[$key]['#attributes']['class'])) {
+        $form[$key]['#attributes']['class'] .= ' vertical-tabs-fieldset vertical-tabs-'. $key;
+      }
+      else {
+        $form[$key]['#attributes']['class'] = 'vertical-tabs-fieldset vertical-tabs-'. $key;
+      }
+    }
+  }
+
+  // The JavaScript and CSS specific for this form.
+  if (!empty($settings)) {
+    $js = $css = array();
+
+    // Add Garland specific theming.
+    if ($GLOBALS['theme'] == 'garland') {
+      $garland_stylesheets = variable_get('color_garland_stylesheets', array());
+      if (count($garland_stylesheets) == 0 || !module_exists('color')) {
+        $css[] = drupal_get_path('module', 'vertical_tabs') .'/garland/vertical_tabs.garland.css';
+      }
+      else {
+        foreach ($garland_stylesheets as $path) {
+          if (strstr($path, 'vertical_tabs.garland.css')) {
+            $css[] = $path;
+          }
+        }
+      }
+    }
+
+    // User sort orders by the "weight" key.
+    uasort($settings, '_user_sort');
+
+    $form['vertical_tabs'] = array(
+      '#vertical_tabs_settings' => $settings,
+      '#vertical_tabs_js' => $js,
+      '#vertical_tabs_css' => $css,
+      '#form_id' => $form['form_id']['#value'],
+      '#type' => 'markup',
+      '#value' => '',
+      '#theme' => 'vertical_tabs',
+      '#attributes' => array('class' => 'vertical-tabs clear-block'),
+    );
+    
+    return TRUE;
+  }
+}
+
+/**
  * Implementation of hook_form_alter.
  */
 function vertical_tabs_form_alter(&$form, $form_state, $form_id) {
@@ -34,75 +109,9 @@ function vertical_tabs_form_alter(&$form
     // for the node form, and their JavaScript summary creators.
     $fieldsets = vertical_tabs_fieldsets($node_type);
 
-    // The javascript to add to the page.
-    $settings = array();
-    // Iterate through the form, finding fieldsets.
-    foreach (element_children($form) as $delta => $key) {
-      // We need to make sure that the element we have is a fieldset
-      // and the user has access to this field.
-      if (in_array($key, $fieldsets) &&
-        (isset($form[$key]['#type']) && $form[$key]['#type'] == 'fieldset') &&
-        (!isset($form[$key]['#access']) || $form[$key]['#access'] != FALSE)) {
-        // Add the JavaScript.
-        $settings[$key] = array(
-          'name' => $form[$key]['#title'],
-          'weight' => $form[$key]['#weight'] + (0.01 * $delta),
-        );
-        // If there's a summary callback, then add it.
-        if (isset($form[$key]['#summary_callback']) || in_array($key, $fieldsets)) {
-          $settings[$key]['callback'] = (isset($form[$key]['#summary_callback']) ? $form[$key]['#summary_callback'] : $key);
-          $settings[$key]['args'] = (isset($form[$key]['#summary_arguments']) ? $form[$key]['#summary_arguments'] : array());
-        }
-        // Add a class to identify the fieldset.
-        if (isset($form[$key]['#attributes']['class']) && !empty($form[$key]['#attributes']['class'])) {
-          $form[$key]['#attributes']['class'] .= ' vertical-tabs-fieldset vertical-tabs-'. $key;
-        }
-        else {
-          $form[$key]['#attributes']['class'] = 'vertical-tabs-fieldset vertical-tabs-'. $key;
-        }
-      }
-    }
-
-    // The JavaScript and CSS specific for this form.
-    if (!empty($settings)) {
-      $js = array(drupal_get_path('module', 'vertical_tabs') .'/vertical_tabs.node_form.js');
-      $css = array();
-
-      // Add Garland specific theming.
-      if ($GLOBALS['theme'] == 'garland') {
-        $garland_stylesheets = variable_get('color_garland_stylesheets', array());
-        if (count($garland_stylesheets) == 0 || !module_exists('color')) {
-          $css[] = drupal_get_path('module', 'vertical_tabs') .'/garland/vertical_tabs.garland.css';
-        }
-        else {
-          foreach ($garland_stylesheets as $path) {
-            if (strstr($path, 'vertical_tabs.garland.css')) {
-              $css[] = $path;
-            }
-          }
-        }
-      }
-
-      // User sort orders by the "weight" key.
-      uasort($settings, '_user_sort');
-
-      // Build necessary classes on the DIV.
-      $classes = array('vertical-tabs', 'clear-block');
-
-      // Extra classes for configuration?
-      // $classes[] = 'some-option';
-
-      $form['vertical_tabs'] = array(
-        '#vertical_tabs_settings' => $settings,
-        '#vertical_tabs_js' => $js,
-        '#vertical_tabs_css' => $css,
-        '#form_id' => $form_id,
-        '#type' => 'markup',
-        '#value' => '',
-        '#weight' => 100,
-        '#theme' => 'vertical_tabs',
-        '#attributes' => array('class' => implode(' ', $classes)),
-      );
+    if (vertical_tabs_add_vertical_tabs($form, $fieldsets)) {
+      drupal_add_js(drupal_get_path('module', 'vertical_tabs') .'/vertical_tabs.node_form.js');
+      $form['vertical_tabs']['#weight'] = 100;
     }
   }
 
@@ -271,4 +280,4 @@ function theme_vertical_tabs_js_css($js,
     }
     $js_added[$form_id] = TRUE;
   }
-}
\ No newline at end of file
+}
Index: vertical_tabs.node_form.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vertical_tabs/Attic/vertical_tabs.node_form.js,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 vertical_tabs.node_form.js
--- vertical_tabs.node_form.js	6 Jan 2009 02:47:47 -0000	1.1.2.5
+++ vertical_tabs.node_form.js	29 Jun 2009 04:16:48 -0000
@@ -1,3 +1,6 @@
+// $Id$
+
+Drupal.verticalTabs = Drupal.verticalTabs || {};
 
 Drupal.verticalTabs.book = function() {
   var text = $('#edit-book-bid option[selected]').text();
@@ -136,4 +139,4 @@ Drupal.verticalTabs.taxonomy = function(
   else {
     return Drupal.t('No terms');
   }
-}
\ No newline at end of file
+}
