--- cck_address.module	2007-05-07 14:58:45.000000000 -0700
+++ cck_address.module.new	2007-05-07 15:00:07.000000000 -0700
@@ -88,11 +88,11 @@ function cck_address_field_settings($op,
   switch ($op) {
     case 'form':
       $form = array();
-      $form['state_abbrv'] = array(
-      	'#type' => 'checkbox',
-      	'#title' => t('Use abbreviations for display of States/Provinces?'),
-      	'#default_value' => isset($field['state_abbrv']) ? $field['state_abbrv'] : 0,
-      	'#return_value' => 1,
+      $form['state_display'] = array(
+      	'#type' => 'select',
+      	'#title' => t('Display States/Provinces as'),
+      	'#default_value' => isset($field['state_display']) ? $field['state_display'] : 0,
+      	'#options' => array('Select with full names', 'Select with abbreviations', 'Free-text entry'),
       	);
       $form['country_abbrv'] = array(
       	'#type' => 'checkbox',
@@ -181,7 +181,7 @@ function cck_address_field_settings($op,
       break;
       
     case 'save':
-      return array('state_abbrv', 'country_abbrv', 'clist', 'max_length_street1', 'max_length_street2', 'max_length_city', 'max_length_other');
+      return array('state_display', 'country_abbrv', 'clist', 'max_length_street1', 'max_length_street2', 'max_length_city', 'max_length_other');
 
     case 'database columns':
       $columns = array(
@@ -321,13 +321,15 @@ function cck_address_field($op, &$node, 
             form_set_error($error_field_country, t('Illegal value for %name\'s Country field. You must select a Country from the dropdown list.', array('%name' => t($field['widget']['label']))));
           }
           
-          $state_options = cck_address_get_states($selected_country);
+          /*
+	  $state_options = cck_address_get_states($selected_country);
           if (array_key_exists($item['state'], $state_options)) {
             $selected_state[$item['state']] = $item['state'];
           }
           else {
             form_set_error($error_field_state, t('Illegal value for %name\'s State field. You must select a State from the dropdown list.', array('%name' => t($field['widget']['label']))));
           }
+	  */
         }
       }
       if ($field['max_lengths']['max_length_street1'] > 0) {
@@ -419,7 +421,12 @@ function cck_address_format($field, $ite
         $allowed_countries[$code] = $all_countries[$code];
       }
       $country[$item['country']] = $all_countries[$item['country']];
-      $states = cck_address_get_states($country);
+      
+      if ($field['state_display'] == 2) {
+	      $cck_address_state = strip_tags($item['state']);
+      } else {
+	      $states = cck_address_get_states($country);
+      }
       
       //check the values
       $cck_address_street1 = strip_tags($item['street1']);
@@ -432,7 +439,7 @@ function cck_address_format($field, $ite
       $cck_address_other = strip_tags($item['other']);
       
       //are we using state abbreviations for display?
-      if ($field['state_abbrv'] == 0) {
+      if ($field['state_display'] == 0) {
         $cck_address_state = $states[$cck_address_state];
       }
       
@@ -651,20 +658,6 @@ function cck_address_widget($op, &$node,
       );
       $form[$field['field_name']][0]['city']['#attributes'] = $field['max_length_city'] ? array('style' => 'width:' .$field["max_length_city"]*0.85. 'em') : array();
 
-      $state = isset($_POST[$field['field_name']][0]['state']) ? $_POST[$field['field_name']][0]['state'] : $items[0]['state'];
-      
-      $form[$field['field_name']][0]['state'] = array(
-        '#type' => 'select',
-        '#title' => t('State'),
-        '#default_value' => $state,
-        '#multiple' => FALSE,
-        '#required' => $field['required'],
-        '#options' => array(),
-        '#prefix' => '<div class="cck-address-state">',
-        '#suffix' => '</div>',
-        '#DANGEROUS_SKIP_CHECK' => TRUE,
-      );
-
       $form[$field['field_name']][0]['zip'] = array(
         '#type' => 'textfield',
         '#title' => t('ZIP'),
@@ -690,14 +683,44 @@ function cck_address_widget($op, &$node,
         '#suffix' => '</div>',
       );
       
-      if ($activeselect) {
-        $form[$field['field_name']][0]['country']['#type'] = 'activeselect';
-        $form[$field['field_name']][0]['country']['#activeselect_path'] = 'cck_address/activeselect';
-        $form[$field['field_name']][0]['country']['#activeselect_targets'] = str_replace('_', '-', $field['field_name']). '-0-state';
-        $form[$field['field_name']][0]['country']['#activeselect_extra'] = $state;
+      $state = isset($_POST[$field['field_name']][0]['state']) ? $_POST[$field['field_name']][0]['state'] : $items[0]['state'];
+      
+      if ($field['state_display'] == 2) {
+
+	      $form[$field['field_name']][0]['state'] = array(
+		'#type' => 'textfield',
+		'#title' => t('State'),
+		'#default_value' => $state,
+		'#required' => $field['required'],
+		'#size' => $field['max_length_other'] ? $field['max_length_other'] : NULL,
+		'#maxlength' => $field['max_length_other'] ? $field['max_length_other'] : NULL,
+		'#prefix' => '<div class="cck-address-state">',
+		'#suffix' => '</div>',
+	      );
+	      $form[$field['field_name']][0]['state']['#attributes'] = $field['max_length_other'] ? array('style' => 'width:' .$field["max_length_other"]*0.85. 'em') : array();
       }
       else {
-        $form[$field['field_name']][0]['state']['#options'] = $state_options;
+	      $form[$field['field_name']][0]['state'] = array(
+		'#type' => 'select',
+		'#title' => t('State'),
+		'#default_value' => $state,
+		'#multiple' => FALSE,
+		'#required' => $field['required'],
+		'#options' => array(),
+		'#prefix' => '<div class="cck-address-state">',
+		'#suffix' => '</div>',
+		'#DANGEROUS_SKIP_CHECK' => TRUE,
+	      );
+	      
+	      if ($activeselect) {
+		$form[$field['field_name']][0]['country']['#type'] = 'activeselect';
+		$form[$field['field_name']][0]['country']['#activeselect_path'] = 'cck_address/activeselect';
+		$form[$field['field_name']][0]['country']['#activeselect_targets'] = str_replace('_', '-', $field['field_name']). '-0-state';
+		$form[$field['field_name']][0]['country']['#activeselect_extra'] = $state;
+	      }
+	      else {
+		      $form[$field['field_name']][0]['state']['#options'] = $state_options;
+	      }
       }
       
       $form[$field['field_name']][0]['other'] = array(
@@ -780,7 +803,7 @@ function cck_address_activeselect($sourc
  * 	The data to be rendered.
  * @return string An HTML string ready for display.
  */
-function theme_cck_address_display($form) {
-  
+function theme_cck_address_display($form) {  
+
   return drupal_render($form);
 } //function theme_cck_address_display()
\ No newline at end of file
