Index: modules/jstools/jscalendar/jscalendar.js
===================================================================
RCS file: /cvs/drupal/contributions/modules/jstools/jscalendar/jscalendar.js,v
retrieving revision 1.4.2.3
diff -u -r1.4.2.3 jscalendar.js
--- modules/jstools/jscalendar/jscalendar.js	30 May 2006 04:30:14 -0000	1.4.2.3
+++ modules/jstools/jscalendar/jscalendar.js	26 Aug 2006 12:49:34 -0000
@@ -14,10 +14,10 @@
         input.parentNode.insertBefore(button, input.nextSibling);
         addClass(input.parentNode, 'jscalendar');
         var settings = [];
-        settings['ifFormat'] = form.elements['edit[jscalendar_ifFormat]'] ? form.elements['edit[jscalendar_ifFormat]'].value : '%Y-%m-%d %H:%M:%S';
+        settings['ifFormat'] = $(input.id+'_jscalendar-ifFormat') ? $(input.id+'_jscalendar-ifFormat').value : '%Y-%m-%d %H:%M:%S';
         // We use eval() because the result is a boolean while our input is a string.
-        settings['showsTime'] = form.elements['edit[jscalendar_showsTime]'] ? eval(form.elements['edit[jscalendar_showsTime]'].value) : true;
-        settings['timeFormat'] = form.elements['edit[jscalendar_timeFormat]'] ? form.elements['edit[jscalendar_timeFormat]'].value : '12';
+        settings['showsTime'] = $(input.id+'_jscalendar-showsTime') ? eval($(input.id+'_jscalendar-showsTime').value) : true;
+        settings['timeFormat'] = $(input.id+'_jscalendar-timeFormat') ? $(input.id+'_jscalendar-timeFormat').value : '12';
         Calendar.setup(
           {
             inputField  : input.id,
Index: modules/jstools/jscalendar/jscalendar.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/jstools/jscalendar/jscalendar.module,v
retrieving revision 1.5.2.4
diff -u -r1.5.2.4 jscalendar.module
--- modules/jstools/jscalendar/jscalendar.module	13 Jul 2006 20:16:40 -0000	1.5.2.4
+++ modules/jstools/jscalendar/jscalendar.module	26 Aug 2006 12:54:53 -0000
@@ -33,21 +33,22 @@
  * Implementation of hook_form_alter().
  */
 function jscalendar_form_alter($form_id, &$form) {
-  if (_jscalendar_has_calendar($form)) {
-    jscalendar_load();
-    // Allow setting of jscalendar startup options.
-    // Here is the full list of available settings. We're only enabling a few for now.
-    // $settings = array('displayArea', 'eventName', 'ifFormat', 'daFormat', 'singleClick', 'disableFunc', 'dateStatusFunc', 'firstDay', 'weekNumbers', 'align', 'range', 'flat', 'flatCallback', 'onSelect', 'onClose', 'onUpdate', 'date', 'showsTime', 'timeFormat', 'electric', 'position', 'cache', 'showOthers');
-    $settings = array('ifFormat', 'showsTime', 'timeFormat');
-    foreach ($settings as $setting) {
-      if (isset($form['#jscalendar_' . $setting])) {
-        $form['jscalendar_' . $setting] = array(
-          '#type' => 'hidden',
-          '#value' => $form['#jscalendar_' . $setting]    
-        );
-        unset($form['#jscalendar_' . $setting]);
+  foreach (element_children($form) as $key) {
+    if (isset($form[$key]) && isset($form[$key]['#attributes']) && isset($form[$key]['#attributes']['class']) && !(strpos($form[$key]['#attributes']['class'], 'jscalendar') === FALSE)) {
+      jscalendar_load();
+      $settings = array('ifFormat', 'showsTime', 'timeFormat');
+      foreach ($settings as $setting) {
+        if (isset($form[$key]['#jscalendar_' . $setting])) {
+          $form[$key.'_jscalendar'][$setting] = array(
+            '#type' => 'hidden',
+            '#value' => $form[$key]['#jscalendar_' . $setting]
+          );
+          unset($form[$key]['#jscalendar_' . $setting]);
+        }
       }
     }
+    // If necessary, recurse through all children.
+    jscalendar_form_alter($form_id, $form[$key]);
   }
 }
 
@@ -83,30 +84,13 @@
 }
 
 /**
- * Test if a form has a jscalendar class set on at least one of its elements.
- */
-function _jscalendar_has_calendar($form) {
-  // Test if child elements have the 'jscalendar' class set.
-  foreach (element_children($form) as $key) {
-    if (isset($form[$key]) && isset($form[$key]['#attributes']) && isset($form[$key]['#attributes']['class']) && !(strpos($form[$key]['#attributes']['class'], 'jscalendar') === FALSE)) {
-      return TRUE;
-    }
-  }
-  // If necessary, recurse through all children.
-  foreach (element_children($form) as $key) {
-    if (isset($form[$key]) && $form[$key]) {
-      if (_jscalendar_has_calendar($form[$key])) {
-        return TRUE;
-      }
-    }
-  }
-  return FALSE;
-}
-
-/**
  * Load needed files.
  */
 function jscalendar_load($lib_locale = NULL) {
+  static $loaded;
+  if (!isset($loaded)) {
+    $loaded = true;
+  }
   global $locale;
   // If the locale library hasn't been explicitly set, we look for support for the current locale.
   if (empty($lib_locale)) {
