Index: advpoll.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advpoll/advpoll.module,v
retrieving revision 1.34
diff -u -r1.34 advpoll.module
--- advpoll.module	9 Nov 2006 22:11:58 -0000	1.34
+++ advpoll.module	13 Nov 2006 21:56:30 -0000
@@ -142,29 +142,26 @@
  */
 function advpoll_form($node, $form_values = NULL) {
   $mode = _advpoll_get_mode($node);
-
-  drupal_add_js("$(document).ready(function(){
-    // Be sure not to add it more than once
-    if ($('#addChoice').length == 0) {
-      $('<input type=\'button\' id=\'addChoice\' value=\'". t('Add choice') . "'
-        + '\' />').insertAfter('#morechoices');
-    }
-
-    $('#addChoice').bind('click', function () {
-      var nextChoice = $('input.choices').length + 1;
-      $('<div class=\'form-item choiceDiv\'><label for=\'edit-choice-'
-        + nextChoice + '-label\'>' + '" 
-          // Hack for translating string before we know the specific number
-          . t('Choice %n', array('%n' => -1))
-          . ": '.replace('-1', nextChoice) + '</label>'
-        + '<input type=\'text\' maxlength=\'128\' name=\'choice[' + nextChoice
-          + '][label]\' id=\'edit-choice-' + nextChoice + '-label\' size=\'60\''
-          + ' class=\'form-text choices\' />'
-        + '</div>').insertAfter('.choices:last');
-      $('.choiceDiv:last').fadeIn(1000);
-      $('#edit-choices').each(function(){this.value = nextChoice});
+  
+  $js = '$(document).ready(function(){
+  $("#morechoices").hide();
+  $(\'<input type="button" id="addChoice" value="'. t('Add choice') .'"/>\').insertAfter("#morechoices");
+  $("#addChoice").click(function(){
+    var nextChoiceN = $("input.choices").length + 1;
+    var html = \'<div class="form-item">\' +
+      \'<label for="edit-choice-\' + nextChoiceN + \'-label">\' + \''. 
+    // Hack for translating string before we know the specific number
+    t('Choice %n', array('%n' => 'n'))
+    .':\'.replace(\'n\', nextChoiceN) + \'<\/label>\' +
+      \'<input type="text" maxlength="128" name="choice[\' + nextChoiceN + \'][label]"" id="edit-choice-\' + nextChoiceN + \'-label" size="60" class="form-text choices" />\' +
+      \'<\/div>\';
+      
+    $(html).insertBefore("#morechoices").fadeIn();
+    $("#edit-choices").val(nextChoiceN);
     });
-  });", 'inline');
+  });';
+  
+  drupal_add_js($js, 'inline');
 
   $form['title'] = array(
     '#type' => 'textfield',
