diff --git a/README.txt b/README.txt
index 74bfcd6..c9bd96b 100644
--- a/README.txt
+++ b/README.txt
@@ -1,4 +1,4 @@
-$Id: README.txt,v 1.1.4.4 2009/06/04 04:53:43 yhager Exp $
+$Id: README.txt,v 1.1.4.5 2009/10/06 05:48:18 yhager Exp $
 
 = Overview =
 imagefield_crop provides a widget for cropping an image after upload.
@@ -26,11 +26,7 @@ You will need imagefield and imageapi enabled in order to use this module, along
 = Installation =
 * Install the module and enable it.
 * Set appropriate permissions at (/admin/user/permissions) under sections "content_permissions module", "node module".
-* [opt.] Patch imagefield, as described below
 * On the imagefield configuration page (admin/content/types/<content_type>/fields/<your_image_field>) choose the 'Image with cropping' widget.
-* Save your field, and edit it again. There you can see the widget settings form where you can choose the cropping box size, and other configuration options.
+* Save your field. You can set the widget settings form where you can choose the cropping box size, and other configuration options.
 * Upon uploading an image, or editing an existing node, the image cropping interface will be presented.
 
-== Patch imagefield ==
-In order to see the cropped images without a manual browser refresh, use the
-patch in http://drupal.org/node/353405#comment-1224788. 
diff --git a/imagefield_crop.info b/imagefield_crop.info
index 392eef3..9bbf0dd 100644
--- a/imagefield_crop.info
+++ b/imagefield_crop.info
@@ -7,9 +7,9 @@ dependencies[] = imageapi
 package = CCK
 
 
-; Information added by drupal.org packaging script on 2009-06-19
+; Information added by drupal.org packaging script on 2009-10-06
 version = "6.x-1.x-dev"
 core = "6.x"
 project = "imagefield_crop"
-datestamp = "1245413882"
+datestamp = "1254831407"
 
diff --git a/imagefield_crop.install b/imagefield_crop.install
index fc73540..daa9d79 100644
--- a/imagefield_crop.install
+++ b/imagefield_crop.install
@@ -1,5 +1,5 @@
 <?php
-// $Id: imagefield_crop.install,v 1.1.2.1 2009/01/29 10:12:10 yhager Exp $
+// $Id: imagefield_crop.install,v 1.1.2.2 2009/09/13 11:33:22 yhager Exp $
 
 /**
  * Upgrade to Drupal 6.
@@ -19,4 +19,26 @@ function imagefield_crop_update_6000() {
   content_clear_type_cache(TRUE);
 
   return $ret;
-}
\ No newline at end of file
+}
+
+/**
+ * Implementation of hook_requirements().
+ */
+function imagefield_crop_requirements($phase) {
+  $requirements = array();
+  $t = get_t();
+  
+  if ($phase == 'runtime') {
+    if (count(imageapi_get_available_toolkits()) == 0) {
+      $requirements['imagefield_crop_toolkits'] = array(
+        'title' => $t('Imagefield crop Toolkit'),
+        'value' => $t('No ImageAPI toolkits available'),
+        'severity' => REQUIREMENT_ERROR,
+        'description' => $t('Imagefield crop requires a Toolkit such as ImageAPI GD or ImageAPI ImageMagick to function. Go to !modules and enable one of them.', array('!modules' => l('admin/build/modules', 'admin/build/modules'))),
+      );
+    }
+  }
+
+  return $requirements;
+}
+
diff --git a/imagefield_crop.js b/imagefield_crop.js
index d95caa4..41f0034 100644
--- a/imagefield_crop.js
+++ b/imagefield_crop.js
@@ -5,57 +5,61 @@ Drupal.behaviors.imagefield_crop = function (context) {
   setTimeout(attachJcrop, 1000, context);
 
   function attachJcrop(context) {
-    if ($('#cropbox', context).length == 0) {
+    if ($('.cropbox', context).length == 0) {
       // no cropbox, probably an image upload (http://drupal.org/node/366296)
       return;
     }
-    var api = $.Jcrop($('#cropbox', context), {
-      onChange: showPreview, 
-      onSelect: setCoords,
-      aspectRatio: Drupal.settings.imagefield_crop.ratio,
-      boxWidth: Drupal.settings.imagefield_crop.box_width,
-      boxHeight: Drupal.settings.imagefield_crop.box_height
-      //    setSelect: getDimensions()
-    });   
-    var dim = getDimensions();
-    api.animateTo(dim);
-  };
-  
-  
-  function setCoords(c) {
-    setDimensions(c.x, c.y, c.w, c.h);
-  };
-  
-  function showPreview(c) {
-    
-    var rx = Drupal.settings.imagefield_crop.preview.width / c.w;
-    var ry = Drupal.settings.imagefield_crop.preview.height / c.h;
-    
-    $('.jcrop-preview', context).css({
-      width: Math.round(rx * Drupal.settings.imagefield_crop.preview.orig_width) + 'px',
-      height: Math.round(ry * Drupal.settings.imagefield_crop.preview.orig_height) + 'px',
-      marginLeft: '-' + Math.round(rx * c.x) + 'px',
-      marginTop: '-' + Math.round(ry * c.y) + 'px'
+    var api = $('.cropbox', context).each(function() {
+      var self = $(this);
+
+      // get the src attribute for multiple image support
+      var src = self.attr('src');
+      if (src.indexOf('?') > 0) {
+        src = src.substring(0, src.indexOf('?'));
+      }
+
+      // get the name attribute for imagefield name
+      var widget = self.parent().parent();
+      var field = widget.find('input[type=hidden]:first').attr('name');
+      if (field) {
+        field = field.substring(0, field.indexOf('['));
+      }
+      $(this).Jcrop({
+        onChange: function(c) {
+          var preview = widget.parent().find('.widget-preview');
+          // skip newly added blank fields
+          if (undefined == Drupal.settings.imagefield_crop.preview[src]) {
+            return;
+          }
+          var rx = Drupal.settings.imagefield_crop.preview[src].width / c.w;
+          var ry = Drupal.settings.imagefield_crop.preview[src].height / c.h;
+          $('.jcrop-preview', preview).css({
+            width: Math.round(rx * Drupal.settings.imagefield_crop.preview[src].orig_width) + 'px',
+            height: Math.round(ry * Drupal.settings.imagefield_crop.preview[src].orig_height) + 'px',
+            marginLeft: '-' + Math.round(rx * c.x) + 'px',
+            marginTop: '-' + Math.round(ry * c.y) + 'px'
+          });
+        },
+        onSelect: function(c) {
+            $(".edit-image-crop-x", widget).val(c.x);
+            $(".edit-image-crop-y", widget).val(c.y);
+            if (c.w) $(".edit-image-crop-width", widget).val(c.w);
+            if (c.h) $(".edit-image-crop-height", widget).val(c.h);
+            $(".edit-image-crop-changed", widget).val(1);
+        },
+        aspectRatio: Drupal.settings.imagefield_crop.box[field].ratio,
+        boxWidth: Drupal.settings.imagefield_crop.box[field].box_width,
+        boxHeight: Drupal.settings.imagefield_crop.box[field].box_height,
+        setSelect: [
+          parseInt($(".edit-image-crop-x", widget).val()),
+          parseInt($(".edit-image-crop-y", widget).val()),
+          parseInt($(".edit-image-crop-width", widget).val() + $(".edit-image-crop-x", widget).val()),
+          parseInt($(".edit-image-crop-height", widget).val() + $(".edit-image-crop-y", widget).val())
+        ]
+      });
     });
-    
   };
   
-  // get select box dimensions from the form
-  function getDimensions() {
-    x =  parseInt($(".edit-image-crop-x", context).val()); 
-    y =  parseInt($(".edit-image-crop-y", context).val());
-    w =  parseInt($(".edit-image-crop-width", context).val());
-    h =  parseInt($(".edit-image-crop-height", context).val());
-    return [x, y, x+w, y+h];
-  };
-  
-  function setDimensions(x, y, w, h) {
-    $(".edit-image-crop-x", context).val(x);
-    $(".edit-image-crop-y", context).val(y);
-    if (w) $(".edit-image-crop-width", context).val(w);
-    if (h) $(".edit-image-crop-height", context).val(h);
-    $(".edit-image-crop-changed", context).val(1);
-  };
 };
 
 
diff --git a/imagefield_crop_widget.inc b/imagefield_crop_widget.inc
index 374ae6e..d598922 100644
--- a/imagefield_crop_widget.inc
+++ b/imagefield_crop_widget.inc
@@ -91,7 +91,7 @@ function theme_imagefield_crop_widget(&$element) {
 }
 
 function imagefield_crop_widget_process($element, $edit, &$form_state, $form) {
-  static $added_js;
+  static $added_js = array();
 
   $module_path = drupal_get_path('module', 'imagefield_crop');
   drupal_add_js($module_path . '/Jcrop/js/jquery.Jcrop.js');
@@ -138,17 +138,6 @@ function imagefield_crop_widget_process($element, $edit, &$form_state, $form) {
     'changed' => 0,
   );
 
-  if (!$added_js) {
-    // Add settings only once (for ahah).
-    $settings = array(
-      'ratio' => $ratio,
-      'box_width' => (integer)$bwidth,
-      'box_height' => (integer)$bheight,
-    );
-    drupal_add_js(array('imagefield_crop' => $settings), 'setting');
-    $added_js = TRUE;
-  }
-
   if (!empty($file) && 
       is_file($file['filepath']) &&
       (list($width, $height, $type, $image_attributes) = @getimagesize($file['filepath']))) {
@@ -198,6 +187,22 @@ function imagefield_crop_widget_process($element, $edit, &$form_state, $form) {
       '#type' => 'markup',
       '#value' => theme('imagefield_crop_dynamic_preview', $crop_display, $field['widget']['resolution']),
     );
+  
+  if (!isset($added_js[$field['field_name']])) {
+    // Add settings only once (for ahah).
+    $settings = array(
+      'ratio' => $ratio,
+      'box_width' => (integer)$bwidth,
+      'box_height' => (integer)$bheight,
+    );
+    $settings = array( 'box' => array(
+        $field['field_name'] => $settings,
+      ),
+      'preview' => array('fields' => $field['field_name']),
+    );
+    drupal_add_js(array('imagefield_crop' => $settings), 'setting');
+    $added_js[$field['field_name']] = TRUE;
+  }
 
   return $element;
 }
@@ -231,7 +236,7 @@ function imagefield_crop_widget_validate($element) {
 
 function theme_imagefield_crop_cropbox($file = NULL, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
   // REFACTOR: consider multiple images
-  $attributes = array_merge((array)$attributes + array('id' => 'cropbox'));
+  $attributes = array_merge((array)$attributes + array('class' => 'cropbox'));
   $output = theme('imagefield_image', $file, $alt, $title, $attributes, $getsize);
   $element = array(
     '#type' => 'element',
@@ -242,6 +247,8 @@ function theme_imagefield_crop_cropbox($file = NULL, $alt = '', $title = '', $at
 
 
 function theme_imagefield_crop_dynamic_preview($file, $resolution) {
+  static $added_js = array();
+  
   $file = (array)$file;
   if (!is_file($file['filepath'])) {
     return '<!-- file not found: '. $file['filepath'] .' -->';
@@ -261,7 +268,10 @@ function theme_imagefield_crop_dynamic_preview($file, $resolution) {
     );
     // REFACTOR: Support multiple fields (i.e. add element delta to setting array)
     $output = '';
-    $output .= '<script type="text/javascript">Drupal.settings.imagefield_crop.preview = '. drupal_to_js($settings) .'</script>';
+    if (!isset($added_js[$url])) {
+      $output .= "<script type='text/javascript'>Drupal.settings.imagefield_crop.preview['$url']=".drupal_to_js($settings)."</script>";
+      $added_js[$url] = TRUE;
+    }
     $output .= '<div class="jcrop-preview-wrapper" style="width:'. $width .'px;height:'. $height .'px;overflow:hidden;"><img src="'. check_url($url) .'" alt="'.
       check_plain($alt) .'" title="'. check_plain($title) .'" class="jcrop-preview" /></div>';
     return $output;
@@ -287,4 +297,4 @@ function _imagefield_crop_resize($src, $crop = NULL, $scale = NULL, $dst = '') {
   }
 
   return $result;
-}
\ No newline at end of file
+}
