--- D:/Users/Sina/Developing/Projects/Drupal/Drupal6/sites/all/modules/imagecrop/imagecrop.module	Fri Jul 30 18:35:08 2010
+++ D:/Users/Sina/Developing/Projects/Drupal/Drupal6/sites/all/modules/imagecrop/imagecrop_2.module	Sat Aug 07 22:15:27 2010
@@ -119,6 +119,10 @@
     $popups['thickbox'] = t('Thickbox');
   }
 
+  if (module_exists('modalframe')) {
+    $popups['modalframe'] = t('Modal Frame API');
+  }  
+
   $form['imagecrop_popup'] = array(
     '#type' => 'radios',
     '#title' => t('Popup window type'),
@@ -398,7 +402,11 @@
       $form['imagecrop'] = array('#type' => 'hidden', '#value' => '1');
     }
   }
-
+  
+  if ($popup == 'modalframe' && module_exists('modalframe')) {
+    // Send the Modal Frame javascript for parent windows to the page.
+	modalframe_parent_js();
+  }
 }
 
 /**
@@ -431,6 +439,13 @@
 
   if ($popup == 'thickbox' && module_exists('thickbox')) {
     return '[<a class="thickbox" href="'. $url .'?KeepThis=true&TB_iframe=true&height='. $height .'&width='. $width .'">'. t('Crop this image') .'</a>]';
+  } else
+  if ($popup == 'modalframe' && module_exists('modalframe')) {
+    // Send the Modal Frame javascript for parent windows to the page.
+	modalframe_parent_js();
+	
+	$modalFrame="Drupal.modalFrame.open({url:'$url',width:'$width',height:'$height'});";
+    return '[<a href="javascript:;" onclick="'.$modalFrame.'">'. t('Crop this image') .'</a>]';
   }
   else {
     return '[<a href="javascript:;" onclick="window.open(\''. $url .'\',\'imagecrop\',\'menubar=0,scrollbars=1,resizable=1,width='. $width .',height='. $height .'\');">'. t('Crop this image') .'</a>]';
