Index: captcha.inc
===================================================================
--- captcha.inc
+++ captcha.inc
@@ -161,18 +161,28 @@
   textimage_settings_form_validate($form_id, $form_values);
 }
 
-function textimage_captchachallenge(&$form) {
-  $form['captcha_response'] = array (
-    '#type' => 'textfield',
-    '#title' => t('Captcha Validation'),
-    '#default_value' => '',
-    '#required' => TRUE,
-    '#validate' => array('_captcha_validate' => array()),
-    '#description' => t('Please type in the letters/numbers that are shown in the image above.'),
-    '#prefix' => '<div class="textimage-challenge"><img src="' . url('_textimage/image/'.time()) . '" '.$imageSize[3].'  alt="'.t('Captcha Image: you will need to recognize the text in it.').'"/></div>',
-  );
-
-  return $form;
+function textimage_captcha() {
+  $args = func_get_args();
+  $op = array_shift($args); 
+  switch($op) {
+    case 'list':
+      return array("textimage");
+    case 'generate':
+      $captcha_type = array_shift($args);
+      $result = array();
+      if($captcha_type == "textimage") {
+        $result['value'] = array('_captcha_validate' => array());
+        $result['form']['captcha_response'] = array (
+          '#type' => 'textfield',
+          '#title' => t('Captcha Validation'),
+          '#description' => t('Please type in the letters/numbers that are shown in the image above.'),
+          '#weight' => 1,
+          '#required' => TRUE,
+		  '#prefix' => '<div class="textimage-challenge"><img src="' . url('_textimage/image/'.time()) . '" '.$imageSize[3].'  alt="'.t('Captcha Image: you will need to recognize the text in it.').'"/></div>',
+        );
+      }
+      return $result;
+  }
 }
 
 function textimage_captchavalidate(&$captcha_word, &$correct) {
