diff -uN money/money.info money.new/money.info
--- money/money.info	2007-08-09 15:39:45.000000000 +0200
+++ money.new/money.info	2008-10-27 18:53:32.000000000 +0100
@@ -1,5 +1,7 @@
 ; $Id: money.info,v 1.1 2007/08/09 13:39:45 wimleers Exp $
 name = Money
-description = Allows the user to define a currency and an amount in custom content types.
-dependencies = content currency_api
+description = Allows the user to define a currency and an amount as a custom content type.
+dependencies[] = content
+dependencies[] = currency_api
 package = CCK
+core = "6.x"
\ No newline at end of file
diff -uN money/money.install money.new/money.install
--- money/money.install	1970-01-01 01:00:00.000000000 +0100
+++ money.new/money.install	2008-10-27 19:06:05.000000000 +0100
@@ -0,0 +1,43 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Implementation of hook_install().
+ *
+ * Notify content module when this module is installed.
+ */
+function money_install() {
+  drupal_load('module', 'content');
+  content_notify('install', 'money');
+}
+
+/**
+ * Implementation of hook_uninstall().
+ *
+ * Notify content module when this module is uninstalled.
+ */
+function money_uninstall() {
+  drupal_load('module', 'content');
+  content_notify('uninstall', 'money');
+}
+
+/**
+ * Implementation of hook_enable().
+ *
+ * Notify content module when this module is enabled.
+ */
+function money_enable() {
+  drupal_load('module', 'content');
+  content_notify('enable', 'money');
+}
+
+/**
+ * Implementation of hook_disable().
+ *
+ * Notify content module when this module is disabled.
+ */
+function money_disable() {
+  drupal_load('module', 'content');
+  content_notify('disable', 'money');
+}
\ No newline at end of file
diff -uN money/money.module money.new/money.module
--- money/money.module	2007-08-09 15:39:45.000000000 +0200
+++ money.new/money.module	2008-11-07 13:07:31.000000000 +0100
@@ -5,7 +5,7 @@
  * @file
  * This module defines the "money" CCK field. It uses the Currency API, which
  * is included in the Currency module, to get a list of valid currencies.
- * 
+ *
  * Only amounts with 2 decimals can be used. Any decimal separator and any
  * digit group separator can be used, but it defaults to the comma and the dot
  * respectively, which is according to ISO 31-0. The separators can be changed
@@ -19,6 +19,7 @@
  * Implementation of hook_field_info().
  */
 function money_field_info() {
+  /// @todo: Check if needs update
   return array('money' => array('label' => t('Money')));
 }
 
@@ -29,7 +30,7 @@
   switch ($op) {
     case 'form':
       $form = array();
-      $form['currency_list'] = array(
+      $form['currency_list'] = array( /// @todo Why is this one here?
         '#value' => theme('money_field_settings_currency_list', currency_api_get_list()),
       );
       $form['allowed_currencies'] = array(
@@ -38,32 +39,29 @@
         '#title' => t('Currencies'),
         '#description' => t('Enter the 3-letter ISO codes for the currencies that you want to allow, separated by commas. Leave empty to allow all currencies.'),
         '#default_value' => (isset($field['allowed_currencies'])) ? $field['allowed_currencies'] : '',
+        '#element_validate' => array('_validate_currency_list'),
       );
       return $form;
 
-    case 'validate':
-      $valid_currencies = array_keys(currency_api_get_list());
-      $allowed_currencies = _money_parse_currencies($field['allowed_currencies']);
-      foreach ($allowed_currencies as $currency) {
-        if (!in_array($currency, $valid_currencies)) {
-          form_set_error('allowed_currencies', t('The currency %currency is not a valid currency.', array('%currency' => $currency)));
-        }
-      }
-      break;
-
     case 'save':
       return array('allowed_currencies');
 
     case 'database columns':
-      $columns['amount'] = array(
-        'type' => 'int',
-        'length' => 13,
-        'not null' => TRUE,
-        'default' => 0,
-        'unsigned' => FALSE,
+      /// @todo Change this to reflect Schema API syntax (http://api.drupal.org/api/group/schemaapi/6)
+      return array(
+        'amount' => array(
+          'type' => 'int',
+          'length' => 13,
+          'not null' => FALSE,
+          'default' => 0,
+          'unsigned' => FALSE
+        ),
+        'currency' => array(
+          'type' => 'varchar',
+          'not null' => FALSE,
+          'length' => 3
+        )
       );
-      $columns['currency'] = array('type' => 'varchar', 'length' => 3);
-      return $columns;
 
     case 'filters':
       return array(
@@ -80,6 +78,24 @@
 }
 
 /**
+ * Check that each currency is a valid string
+ */
+function _validate_currency_list($element, &$form_state) {  
+  $valid_currencies = array_keys(currency_api_get_list());
+  $allowed_currencies = _money_parse_currencies($form_state['values']['allowed_currencies']);
+  foreach ($allowed_currencies as $currency) {
+    if (!in_array($currency, $valid_currencies)) {
+      form_set_error('allowed_currencies', t('The currency %currency is not a valid currency.', array('%currency' => $currency)));
+    }
+  }
+  
+  /*$value = $form_state['values']['max'];
+  if ($value && !is_numeric($value)) {
+    form_set_error('max', t('"Maximum" must be a number.'));
+  }*/
+}
+
+/**
  * Implementation of hook_field().
  */
 function money_field($op, &$node, $field, &$items, $teaser, $page) {
@@ -142,6 +158,25 @@
 }
 
 /**
+ * Implementation of FAPI hook_elements().
+ *
+ * Any FAPI callbacks needed for individual widgets can be declared here,
+ * and the element will be passed to those callbacks for processing.
+ *
+ * Drupal will automatically theme the element using a theme with
+ * the same name as the hook_elements key.
+ */
+function money_elements() {
+  return array(
+    'money_field' => array(
+      '#input' => TRUE,
+      '#columns' => array('amount', 'currency'), '#delta' => 0,
+      '#process' => array('money_field_process'),
+    ),
+  );
+}
+
+/**
  * Implementation of hook_widget_settings().
  */
 function money_widget_settings($op, $widget) {
@@ -153,7 +188,7 @@
         '#title' => t('Decimal separator'),
         '#default_value' => _money_get_decimal_separator($widget['decimal_separator']),
         '#size' => 5,
-        '#maxlength' => 255,
+        '#maxlength' => 10,
         '#description' => t(
           'Three decimal separators are used across the planet: the dot
           (English-speaking countries), the comma (Europe) and the momayyez
@@ -166,13 +201,13 @@
         '#title' => t('Digit group separator'),
         '#default_value' => _money_get_digit_group_separator($widget['digit_group_separator']),
         '#size' => 5,
-        '#maxlength' => 255,
+        '#maxlength' => 10,
         '#description' => t(
           'Three digit group separators are used across the planet: the comma
           (English-speaking countries), the dot (Europe) and the space. ISO
           31-0 specifies only the space as valid, this is also the default.'
         ),
-      );     
+      );
       return $form;
     case 'save':
       return array('decimal_separator', 'digit_group_separator');
@@ -181,14 +216,29 @@
 
 /**
  * Implementation of hook_widget().
+ * 
+ * @param $form
+ *   the entire form array, $form['#node'] holds node information
+ * @param $form_state
+ *   the form_state, $form_state['values'] holds the form values.
+ * @param $field
+ *   the field array
+ * @param $delta
+ *   the order of this item in the array of subelements (0, 1, 2, etc)
+ *
+ * @return
+ *   the form item for a single element for this field
  */
-function money_widget($op, &$node, $field, &$items) {
+//function money_widget($op, &$node, $field, &$items) {
+function money_widget(&$form, &$form_state, $field, $items, $delta = 0) {
   if ($field['widget']['type'] == 'money_default') {
+    
+    
     switch ($op) {
       case 'prepare form values':
         $decimal_separator = _money_get_decimal_separator($field['widget']['decimal_separator']);
         $digit_group_separator = _money_get_digit_group_separator($field['widget']['digit_group_separator']);
-      
+
         if (!count($items)) {
           $items[0] = array();
         }
@@ -239,7 +289,7 @@
           $prefix .= '<span class="form-required" title="'. t('This field is required.') .'">*</span>';
         }
         $prefix .= '</label>';
-        
+
         // Actual form creation begins here.
         $form = array();
         $form[$field['field_name']]['#tree'] = TRUE;
@@ -247,7 +297,7 @@
         $form[$field['field_name']]['#type'] = ($field['multiple']) ? 'fieldset' : 'markup';
         $form[$field['field_name']]['#suffix'] = '</div>';
 
-        foreach ($items as $delta => $item) {      
+        foreach ($items as $delta => $item) {
           // These are the actual form items for each money field.
           $form[$field['field_name']][$delta]['#tree'] = TRUE;
           $form[$field['field_name']][$delta]['currency'] = array(
@@ -263,13 +313,13 @@
             '#maxlength' => 25,
             '#default_value' => isset($item['amount']) ? $item['amount'] : $amount_default,
             '#attributes' => array('class' => 'money-field money-field-amount'),
-            '#description' => ($delta == end(array_keys($items))) ? $amount_description : NULL, 
+            '#description' => ($delta == end(array_keys($items))) ? $amount_description : NULL,
             '#suffix' => '</div>',
           );
         }
 
         return $form;
-      
+
       case 'validate':
         // Generate the regular expression to validate the entered amounts.
         $decimal_separator = preg_quote(_money_get_decimal_separator($field['widget']['decimal_separator']));
@@ -279,7 +329,7 @@
         // Make sure the amount is entered using the correct format.
         foreach ($items as $delta => $item) {
           if (!empty($item['amount']) && !preg_match($regexp, $item['amount'])) {
-            form_set_error($field['field_name'] .']['. $delta .'][amount', t('The amount is formatted invalidly.')); 
+            form_set_error($field['field_name'] .']['. $delta .'][amount', t('The amount is formatted invalidly.'));
           }
         }
         break;
@@ -310,6 +360,66 @@
   }
 }
 
+/**
+ * Process our callback to define the money_field.
+ */
+function money_field_process($element, $edit, $form_state, $form) {
+  drupal_add_css(drupal_get_path('module', 'money') .'/money.css');
+  
+  $field = $form['#field_info'][$element['#field_name']];
+  
+  $decimal_separator = _money_get_decimal_separator($field['widget']['decimal_separator']);
+  $digit_group_separator = _money_get_digit_group_separator($field['widget']['digit_group_separator']);
+
+  $decimal_separator = _money_get_decimal_separator($field['widget']['decimal_separator']);
+  $allowed_currencies = _money_parse_currencies($field['allowed_currencies']);
+
+  // Variables to be used in the "currency" form item.
+  $currency_options = array_combine($allowed_currencies, $allowed_currencies);
+
+  // Variables to be used in the "amount" form item.
+  if (isset($field['widget']['default_value'][0]['amount'])) {
+    $amount_default = check_plain(number_format($field['widget']['default_value'][0]['amount']/100, 2, $decimal_separator, $digit_group_separator));
+  }
+  else {
+    $amount_default = check_plain(number_format("0{$decimal_separator}00"/100, 2, $decimal_separator, $digit_group_separator));
+  }
+  $amount_description = t(
+    'Use "@decimal_separator" as the decimal separator and (optionally)
+    "@digit_group_separator" as the digit group separator. You can
+    only enter two decimals.',
+    array(
+      '@decimal_separator' => $field['widget']['decimal_separator'],
+      '@digit_group_separator' => $field['widget']['digit_group_separator'],
+    )
+  );
+  
+  // Building the actual form  
+  $element['#tree'] = TRUE;
+  
+  $element['amount'] = array(
+    '#type' => 'textfield',
+    '#size' => 3,
+    '#maxsize' => 20,
+    '#default_value' => $amount_default,
+  );
+  
+  $element['currency'] = array(
+    '#type' => 'select',
+    // TODO
+  );
+  
+}
+
+/**
+ * Implementation of hook_is_empty($value)
+ */
+function money_content_is_empty($item, $field) {
+  if (empty($item['amount'])) { /// @todo Check if correct
+    return TRUE;
+  }
+  return FALSE;
+}
 
 //----------------------------------------------------------------------------
 // Private functions.
@@ -323,7 +433,19 @@
  *   An array of currency code.
  */
 function _money_parse_currencies($currencies_string) {
-  return explode(',', str_replace(' ', '', trim($currencies_string)));
+  return array_filter(array_map('trim', explode(',', $currencies_string)), '_money_is_filled_string');
+  //return explode(',', str_replace(' ', '', trim($currencies_string)));
+}
+
+/**
+ * Used to filter out empty strings in _money_parse_currencies().
+ * @param $str
+ *   A string.
+ * @return
+ *   TRUE if the string has a non-zero length, FALSE otherwise.
+ */
+function _money_is_filled_string($str) {
+  return (strlen($str)>0);
 }
 
 /**
@@ -357,11 +479,46 @@
 // Theming functions.
 
 /**
+ * Implementation hook_theme().
+ */
+function money_theme() {
+  return array(
+    'theme_money_field' => array(
+      'arguments' => array(
+        array('elements')
+      )
+    ),
+    'theme_money_field_settings_currency_list' => array(
+      'arguments' => array(
+        array('currencies' => array())
+      )
+    )
+  );
+}
+
+/**
  * @ingroup themeable
  * @{
  */
 
 /**
+ * Expected because money form element is defined in hook_elements().
+ */
+function theme_money_amount_textfield($element) {
+  return $element['#children']; // taken from http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/currency_cck/currency_cck.module?view=markup&pathrev=DRUPAL-6--1 
+}
+
+/**
+ * Expected because money form element is defined in hook_elements().
+ * 
+ * The code is borrowed from:
+ * http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/currency_cck/currency_cck.module?view=markup&pathrev=DRUPAL-6--1
+ */
+function theme_money_field($element) {
+  return $element['#children'];
+}
+
+/**
  * Format the list of currencies that is displayed in the money field settings
  * form.
  *
