diff -urpN imce_old/imce.module imce_new/imce.module
--- imce_old/imce.module	2008-08-15 23:46:08.000000000 +0700
+++ imce_new/imce.module	2008-09-09 12:01:05.468750000 +0700
@@ -7,14 +7,21 @@
 function imce_footer() {
   if (user_access('access imce')) {
     $header = drupal_get_js();
+    
     //set imce if tinymce is in action
-    if (!imce_integrate('tinymce', 'check') && module_exists('tinymce') && variable_get('imce_settings_tinymce', 1) && strpos($header, 'tiny_mce')) {
+    if (!variable_get("openwysiwyg_imce", '1') && !imce_integrate('tinymce', 'check') && module_exists('tinymce') && variable_get('imce_settings_tinymce', 1) && strpos($header, 'tiny_mce')) {
       $output .= '<script type="text/javascript" src="'. base_path() . drupal_get_path('module', 'imce') .'/imce_set_tinymce.js' .'"></script>';
     }
     //set imce if fckeditor is in action
     if (!imce_integrate('fck', 'check') && module_exists('fckeditor') && variable_get('imce_settings_fck', 0) && strpos($header, 'fckeditor.js')) {
       $output .= '<script type="text/javascript" src="'. base_path() . drupal_get_path('module', 'imce') .'/imce_set_fck.js' .'"></script>';
     }
+    
+    // set imce if openwysiwyg is in action
+    if (variable_get("openwysiwyg_imce", '1')) {
+      $output .= '<script type="text/javascript" src="'. base_path() . drupal_get_path('module', 'imce') .'/imce_set_openwysiwyg.js' .'"></script>';
+    }
+    
     if ($output) {
       return '<script type="text/javascript"> var imceBrowserURL = "'.url('imce/browse').'"; </script>'. $output;
     }
@@ -765,8 +772,13 @@ function imce_elements() {
  */
 function imce_process_textarea($element, $edit=NULL, $ids=array()) {
   if (in_array($element['#id'], $ids)) {
-  drupal_add_js(drupal_get_path('module', 'imce').'/imce_set_inline.js');
-  $element['#description'] .= '<div style="display:none">'. t('Insert !image or !link.', array('!image' => l(t('image'), 'imce/browse', array('name' => $element['#id'].'-IMCE-image', 'class' => 'imce-insert-inline')), '!link' => l(t('link'), 'imce/browse', array('name' => $element['#id'].'-IMCE-link', 'class' => 'imce-insert-inline')))) .'</div>';
+    if (variable_get("openwysiwyg_imce", '1')) {
+      drupal_add_js(drupal_get_path('module', 'imce').'/imce_set_openwysiwyg.js');
+    }
+    else {
+      drupal_add_js(drupal_get_path('module', 'imce').'/imce_set_inline.js');
+    }
+    $element['#description'] .= '<div style="display:none">'. t('Insert !image or !link.', array('!image' => l(t('image'), 'imce/browse', array('name' => $element['#id'].'-IMCE-image', 'class' => 'imce-insert-inline')), '!link' => l(t('link'), 'imce/browse', array('name' => $element['#id'].'-IMCE-link', 'class' => 'imce-insert-inline')))) .'</div>';
   }
   return $element;
 }
@@ -882,6 +894,7 @@ function imce_get_subfolders($dir, $expr
  * integrate with editors.
  */
 function imce_integrate($e, $check=NULL) {
+
   static $state = array();
   if ($check) {
     return $state[$e];
diff -urpN imce_old/imce_set_openwysiwyg.js imce_new/imce_set_openwysiwyg.js
--- imce_old/imce_set_openwysiwyg.js	1970-01-01 07:00:00.000000000 +0700
+++ imce_new/imce_set_openwysiwyg.js	2008-09-09 12:43:52.642592700 +0700
@@ -0,0 +1,55 @@
+// $Id$
+
+var imceActiveTextarea, imceActiveType;
+function imceInitiateOpenWYSIWYG() {
+  $('a.imce-insert-inline').each( function () {
+    $(this.parentNode).css('display', 'block');
+    $(this).unbind('click').click(function() {
+      imceActiveTextarea = $('#'+this.name.split('-IMCE-')[0]).get(0);
+      imceActiveType = this.name.split('-IMCE-')[1];
+      window.open(this.href, '_imce_', 'width=640, height=480, resizable=1');
+      return false;
+    });
+  });
+}
+
+//custom callback. hook:ImceFinish
+function _imce_ImceFinish(path, w, h, s, imceWin) {
+  var basename = path.substr(path.lastIndexOf('/')+1);
+  var type = imceActiveType=='link' ? 'link' : (w&&h ? 'image' : 'link');
+  var html = type =='image' ? ('<img src="'+ path +'" width="'+ w +'" height="'+ h +'" alt="'+ basename +'" />') : ('<a href="'+ path +'">'+ basename +' ('+ s +')</a>');
+
+  if (!$.browser.safari) {
+    WYSIWYG.insertHTML(html, imceActiveTextarea.id);
+  }
+  else {
+    imceInsertAtCursor(imceActiveTextarea, html, type);
+  }
+  imceWin.close();
+  imceActiveType = null;
+}
+
+//insert html at cursor position
+function imceInsertAtCursor(field, txt, type) {
+  field.focus();
+  if ('undefined' != typeof(field.selectionStart)) {
+    if (type == 'link' && (field.selectionEnd-field.selectionStart)) {
+      txt = txt.split('">')[0] +'">'+ field.value.substring(field.selectionStart, field.selectionEnd) +'</a>';
+    }
+    field.value = field.value.substring(0, field.selectionStart) + txt + field.value.substring(field.selectionEnd, field.value.length);
+  }
+  else if (document.selection) {
+    if (type == 'link' && document.selection.createRange().text.length) {
+      txt = txt.split('">')[0] +'">'+ document.selection.createRange().text +'</a>';
+    }
+    document.selection.createRange().text = txt;
+  }
+  else {
+    field.value += txt;
+  }
+}
+
+if (Drupal.jsEnabled) {
+  // initalize the editor when the DOM is loaded
+  $(document).ready(imceInitiateOpenWYSIWYG);
+}
\ No newline at end of file
