Index: advpoll-form.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advpoll/advpoll-form.js,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 advpoll-form.js
--- advpoll-form.js	2 Sep 2007 20:31:46 -0000	1.1.2.5
+++ advpoll-form.js	2 Sep 2007 22:08:38 -0000
@@ -50,6 +50,61 @@ Drupal.advpoll.removeChoiceClick = funct
   });
 }
 
+Drupal.advpoll.dateTimePickers = function() {
+  var start = $("#edit-settings-startdate").val();
+  var end = $("#edit-settings-enddate").val();
+  var timezone = Drupal.settings.advPoll.timezone;
+  //Date.format = 'yyyy-mm-dd'; // Set date format for datePicker.
+    
+  function setDateTime() {
+    var sD = $("#advpoll-startdate").val();
+    var sT = $("#advpoll-starttime").val();
+    var eD = $("#advpoll-enddate").val();
+    var eT = $("#advpoll-endtime").val();
+    var sDT = (sD ? sD : '') + (sT ? ' ' + sT : '');
+    var eDT = ($("#advpoll-use-end").is(":checked") ? (eD ? eD : '') + (eT ? ' ' + eT : '') : '');
+    // Only add the timezone to the string if date or time is set.
+    sDT = sDT ? sDT + ' ' + timezone : '';
+    eDT = eDT ? eDT + ' ' + timezone : '';
+    
+    $("#edit-settings-startdate").val(sDT);
+    $("#edit-settings-enddate").val(eDT);
+  }
+  
+  function toggleEndfields() {
+    if($(this)[0].checked) {
+      $("#advpoll-endfields").css("display", "inline");
+    }
+    else {
+      $("#advpoll-endfields").hide();
+    }
+    setDateTime(); // Update enddate.
+  };
+  
+  var calendarSettings = {dateFormat: 'YMD-', "onSelect": setDateTime, "speed": "", "changeFirstDay": false, "showOtherMonths": true};
+  // Insert elements, attach pickers and bind events.
+  $('<input type="text" id="advpoll-startdate" />').insertBefore("#advpoll-dates").calendar(calendarSettings);
+  $('<input type="text" id="advpoll-starttime" />').insertBefore("#advpoll-dates").timePicker(null, setDateTime);
+  $('<span id="advpoll-endfields"></span>').insertBefore("#advpoll-dates");
+  $('<span> to <\/span>').appendTo("#advpoll-endfields");
+  $('<input type="text" id="advpoll-endtime" />').appendTo("#advpoll-endfields").timePicker(null, setDateTime);
+  $('<input type="text" id="advpoll-enddate" />').appendTo("#advpoll-endfields").calendar(calendarSettings);
+  var label = $('<label>Use end date</label>').insertBefore("#advpoll-dates");
+  $('<input type="checkbox" id="advpoll-use-end" class="form-checkbox" />').click(toggleEndfields).prependTo(label);
+  
+  // Set dates and time and also bind change event to support keyboard.
+  $("#advpoll-startdate").change(setDateTime).val(start.match(/\d\d\d\d-\d\d-\d\d/));
+  $("#advpoll-starttime").change(setDateTime).val(start.match(/\d\d:\d\d/));
+  $("#advpoll-enddate").change(setDateTime).val(end.match(/\d\d\d\d-\d\d-\d\d/));
+  $("#advpoll-endtime").change(setDateTime).val(end.match(/\d\d:\d\d/));
+  
+  // Check "Use end date"-checkbox if enddate is set and show endate fields.
+  if(end) {
+    $("#advpoll-use-end")[0].checked = true;
+    $("#advpoll-endfields").css("display", "inline");
+  }
+};
+
 Drupal.advpoll.nodeFormAutoAttach = function() {
   // Hide "need more choices" checkbox
   $("#morechoices").hide();
@@ -79,6 +134,8 @@ Drupal.advpoll.nodeFormAutoAttach = func
     
     return false;
   });
+  // Date and time pickers
+  Drupal.advpoll.dateTimePickers();
 }
 
 // Global Killswitch
Index: advpoll.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advpoll/advpoll.module,v
retrieving revision 1.21.2.59
diff -u -p -r1.21.2.59 advpoll.module
--- advpoll.module	2 Sep 2007 21:09:54 -0000	1.21.2.59
+++ advpoll.module	2 Sep 2007 22:11:34 -0000
@@ -128,8 +128,17 @@ function advpoll_form($node, $form_value
   // Only add javascript once, even if _form is called multiple times.
   static $add_js;
   if (!$add_js) {
+    // Get the current timezone which is passed to the JavaScript.
+    $timezone = format_date(0, 'custom', 'O');
     // Pass translatable strings
-    drupal_add_js(array('advPoll' => array('remove' => t('Remove'), 'addChoice' => t('Add choice'), 'noLimit' => t('No limit'))), 'setting');
+    drupal_add_js(array('advPoll' => array('remove' => t('Remove'), 'addChoice' => t('Add choice'), 'noLimit' => t('No limit'), 'timezone' => $timezone)), 'setting');
+    
+    drupal_add_js(drupal_get_path('module', 'advpoll') .'/pickers/jquery.dimensions.js', 'module');
+    drupal_add_js(drupal_get_path('module', 'advpoll') .'/pickers/jquery-calendar.js', 'module');
+    drupal_add_js(drupal_get_path('module', 'advpoll') .'/pickers/jquery.timePicker.js', 'module');
+    drupal_add_css(drupal_get_path('module', 'advpoll') .'/pickers/jquery-calendar.css', 'module');
+    drupal_add_css(drupal_get_path('module', 'advpoll') .'/pickers/timePicker.css', 'module');
+    
     drupal_add_js(drupal_get_path('module', 'advpoll') .'/advpoll-form.js', 'module');
     drupal_add_css(drupal_get_path('module', 'advpoll') .'/advpoll.css', 'module');
     $add_js = true;
@@ -201,7 +210,7 @@ function advpoll_form($node, $form_value
     '#type' => 'fieldset',
     '#title' => t('Poll settings'),
     '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
+    //'#collapsed' => TRUE,
     '#weight' => 2,
     '#tree' => TRUE,
   );
@@ -249,6 +258,7 @@ function advpoll_form($node, $form_value
   }
   
   $form['settings']['startdate'] = array(
+    '#prefix' => '<div id="advpoll-dates">',
     '#type' => 'textfield',
     '#title' => t('Starting date'),
     '#description' => t('The date that the poll opens. Format: %time. Leave blank if you want the poll to open now.', array('%time' => $time)),
@@ -264,6 +274,7 @@ function advpoll_form($node, $form_value
     '#size' => 25,
     '#maxlength' => 25,
     '#default_value' => $node->enddate ? format_date($node->enddate, 'custom', 'Y-m-d H:i:s O') : $default_enddate,
+    '#suffix' => '</div',
   );
   
   // Settings available for users with 'administer polls' permission.
