Index: captcha.inc
===================================================================
--- captcha.inc
+++ captcha.inc
@@ -161,23 +161,32 @@
   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['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,
+		  '#validate' => array('textimage_validate' => array()),
+		  '#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) {
-
-  $captcha_word = drupal_strtolower($captcha_word);
+function textimage_validate($form_item) {
+  $captcha_word = $form_item['#post']['captcha_response'];
   if (($_SESSION['captcha'] != '') && $captcha_word == $_SESSION['captcha']) {
     $correct = true;
   }
@@ -185,7 +194,6 @@
     $correct = false;
     form_set_error('captcha_response', t('The image verification code you entered is incorrect.'));
   }
-
 }
 
 /**
