Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.1.2.42
diff -u -F '^f' -r1.1.2.42 mollom.module
--- mollom.module	14 Sep 2009 11:10:41 -0000	1.1.2.42
+++ mollom.module	31 Jul 2010 20:33:48 -0000
@@ -846,12 +846,28 @@ function mollom_captcha_prerender($form_
         '#size' => 10,
         '#value' => $form['#post']['captcha'],
         '#description' => t("Type the characters shown in the picture above; if you can't read them, submit the form and a new image will be generated."),
-        '#weight' => min($form['submit']['#weight'], $form['preview']['#weight']) + 1,
       );
 
-      // Move the preview and/or submit button below the captcha:
-      $form['preview']['#weight'] += 2;
-      $form['submit']['#weight'] += 2;
+      // Position the CAPTCHA immediately before preview and/or submit buttons
+      if (is_int($form['preview']['#weight'])) {
+        if (is_int($form['submit']['#weight'])) {
+          $form['captcha-solution']['#weight'] = min($form['submit']['#weight'], $form['preview']['#weight']) + 1;
+          $form['submit']['#weight'] += 2;
+        }
+        else {
+          $form['captcha-solution']['#weight'] = $form['preview']['#weight'] + 1;
+        }
+        $form['preview']['#weight'] += 2;
+      }
+      else {
+        if (is_int($form['submit']['#weight'])) {
+          $form['captcha-solution']['#weight'] = $form['submit']['#weight'] + 1;
+          $form['submit']['#weight'] += 2;
+        }
+        else {
+          $form['captcha-solution']['#weight'] = 1;
+        }
+      }
 
       // The weights changed so we re-sort the array:
       uasort($form, "_element_sort");
