Index: typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php
===================================================================
--- typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php	(revision 3474)
+++ typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php	(working copy)
@@ -4,7 +4,7 @@
 *
 *  (c) 2004 Kasper Skaarhoj (kasper@typo3.com)
 *  (c) 2004 Philipp Borgmann <philipp.borgmann@gmx.de>
-*  (c) 2004-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2004-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -30,7 +30,7 @@
  * A RTE using the htmlArea editor
  *
  * @author	Philipp Borgmann <philipp.borgmann@gmx.de>
- * @author	Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+ * @author	Stanislas Rolland <typo3(arobas)sjbr.ca>
  *
  * $Id$  *
  */
@@ -112,6 +112,7 @@
 	
 		// External:
 	var $RTEdivStyle;			// Alternative style for RTE <div> tag.
+	public $httpTypo3Path;
 	var $extHttpPath;			// full Path to this extension for http (so no Server path). It ends with "/"
 	var $siteURL;				// TYPO3 site url
 	var $hostURL;				// TYPO3 host url
@@ -838,10 +839,18 @@
 		
 			// Setting the plugin flags
 		$configureRTEInJavascriptString .= '
-			RTEarea['.$RTEcounter.'].plugin = new Object();';
+			RTEarea['.$RTEcounter.'].plugin = new Object();
+			RTEarea['.$RTEcounter.'].pathToPluginDirectory = new Object();';
 		foreach ($this->pluginEnabledArray as $pluginId) {
 			$configureRTEInJavascriptString .= '
 			RTEarea['.$RTEcounter.'].plugin.'.$pluginId.' = true;';
+			if (is_object($this->registeredPlugins[$pluginId])) {
+				$pathToPluginDirectory = $this->registeredPlugins[$pluginId]->getPathToPluginDirectory();
+				if ($pathToPluginDirectory) {
+					$configureRTEInJavascriptString .= '
+			RTEarea['.$RTEcounter.'].pathToPluginDirectory.'.$pluginId.' = "' . $pathToPluginDirectory . '";';
+				}
+			}
 		}
 		
 			// Setting the buttons configuration
Index: typo3/sysext/rtehtmlarea/class.tx_rtehtmlareaapi.php
===================================================================
--- typo3/sysext/rtehtmlarea/class.tx_rtehtmlareaapi.php	(revision 3474)
+++ typo3/sysext/rtehtmlarea/class.tx_rtehtmlareaapi.php	(working copy)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2007 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2007-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *  All rights reserved
 *
 *  This script is part of the Typo3 project. The Typo3 project is
@@ -24,7 +24,7 @@
 /**
  * API for extending htmlArea RTE
  *
- * @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+ * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
  *
  * TYPO3 SVN ID: $Id$
  *
@@ -38,6 +38,7 @@
 	protected $pluginName;					// The name of the plugin registered by the extension
 	protected $relativePathToLocallangFile;			// Path to the localization file for this script, relative to the extension dir
 	protected $relativePathToSkin;				// Path to the skin (css) file that should be added to the RTE skin when the registered plugin is enabled, relative to the extension dir
+	protected $relativePathToPluginDirectory;		// Path to the directory containing the plugin, relative to the extension dir (should end with slash /)
 	protected $htmlAreaRTE;					// Reference to the invoking object
 	protected $rteExtensionKey;				// The extension key of the RTE
 	protected $thisConfig;					// Reference to RTE PageTSConfig
@@ -124,7 +125,7 @@
 			if (in_array($button, $this->toolbar)) {
 				if (!is_array( $this->thisConfig['buttons.']) || !is_array( $this->thisConfig['buttons.'][$button.'.'])) {
 					$registerRTEinJavascriptString .= '
-			RTEarea['.$RTEcounter.']["buttons"]["'. $button .'"] = new Object();';
+			RTEarea['.$RTEcounter.'].buttons.'. $button .' = new Object();';
 				}
 			}
 		}
@@ -141,6 +142,15 @@
 	}
 
 	/**
+	 * Returns the path to the plugin directory, if any
+	 *
+	 * @return	string		the full path to the plugin directory
+	 */
+	public function getPathToPluginDirectory() {
+		return ($this->relativePathToPluginDirectory ? $this->htmlAreaRTE->httpTypo3Path . t3lib_extMgm::siteRelPath($this->extensionKey) . $this->relativePathToPluginDirectory : '');
+	}
+
+	/**
 	 * Returns the list of buttons implemented by the plugin
 	 *
 	 * @return	string		the list of buttons implemented by the plugin
Index: typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js	(revision 3474)
+++ typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js	(working copy)
@@ -1470,10 +1470,14 @@
 HTMLArea.prototype.popupURL = function(file) {
 	var url = "";
 	if(file.match(/^plugin:\/\/(.*?)\/(.*)/)) {
-		var plugin = RegExp.$1;
+		var pluginId = RegExp.$1;
 		var popup = RegExp.$2;
 		if(!/\.html$/.test(popup)) popup += ".html";
-		url = _editor_url + "plugins/" + plugin + "/popups/" + popup;
+		if (this.config.pathToPluginDirectory[pluginId]) {
+			url = this.config.pathToPluginDirectory[pluginId] + "popups/" + popup;
+		} else {
+			url = _editor_url + "plugins/" + pluginId + "/popups/" + popup;
+		}
 	} else {
 		url = _typo3_host_url + _editor_url + this.config.popupURL + file;
 	}
Index: typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php
===================================================================
--- typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php	(revision 3474)
+++ typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php	(working copy)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2005-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2005-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -27,7 +27,7 @@
 /**
  * Front end RTE based on htmlArea
  *
- * @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+ * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
  *
  * $Id$  *
  */
@@ -42,6 +42,7 @@
 	var $RTEWrapStyle = '';				// Alternative style for RTE wrapper <div> tag.
 	var $RTEdivStyle = '';				// Alternative style for RTE <div> tag.
 	var $extHttpPath;				// full Path to this extension for http (so no Server path). It ends with "/"
+	public $httpTypo3Path;
 
 		// For the editor
 	var $elementId;
