Index: advpoll-form.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advpoll/advpoll-form.js,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 advpoll-form.js
--- advpoll-form.js	1 Sep 2007 22:11:45 -0000	1.1.2.4
+++ advpoll-form.js	2 Sep 2007 18:57:59 -0000
@@ -50,6 +50,60 @@ 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.
+  };
+  
+  // Insert elements, attach pickers and bind events.
+  $('<input type="text" id="advpoll-startdate" />').insertBefore("#advpoll-dates").datePicker({clickInput:true, createButton:false}).bind('dateSelected', setDateTime);
+  $('<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").datePicker({clickInput:true, createButton:false}).bind('dateSelected', setDateTime);
+  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").val(start.match(/\d\d\d\d-\d\d-\d\d/)).change(setDateTime);
+  $("#advpoll-starttime").val(start.match(/\d\d:\d\d/)).change(setDateTime);
+  $("#advpoll-enddate").val(end.match(/\d\d\d\d-\d\d-\d\d/)).change(setDateTime);
+  $("#advpoll-endtime").val(end.match(/\d\d:\d\d/)).change(setDateTime);
+  
+  // 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 +133,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.58
diff -u -p -r1.21.2.58 advpoll.module
--- advpoll.module	1 Sep 2007 22:11:45 -0000	1.21.2.58
+++ advpoll.module	2 Sep 2007 18:48:58 -0000
@@ -133,8 +133,18 @@ 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.date.js', 'module');
+    drupal_add_js(drupal_get_path('module', 'advpoll') .'/pickers/jquery.dimensions.js', 'module');
+    drupal_add_js(drupal_get_path('module', 'advpoll') .'/pickers/jquery.datePicker.js', 'module');
+    drupal_add_js(drupal_get_path('module', 'advpoll') .'/pickers/jquery.timePicker.js', 'module');
+    drupal_add_css(drupal_get_path('module', 'advpoll') .'/pickers/datePicker.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;
@@ -254,6 +264,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)),
@@ -269,6 +280,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',
   );
 
   $form['settings']['uselist'] = array(
