Index: /FCKeditor/branches/features/floating_dialog/_test/manual/fckdialog/test1.css
===================================================================
--- /FCKeditor/branches/features/floating_dialog/_test/manual/fckdialog/test1.css	(revision 1249)
+++ /FCKeditor/branches/features/floating_dialog/_test/manual/fckdialog/test1.css	(revision 1249)
@@ -0,0 +1,50 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * Styles used in the samples pages.
+ */
+
+body, td, input, select, textarea
+{
+	font-size: 12px;
+	font-family: Arial, Verdana, Sans-Serif;
+}
+
+h1
+{
+	font-weight: bold;
+	font-size: 180%;
+	margin-bottom: 10px;
+}
+
+form
+{
+	margin: 0px 0px 0px 0px;
+	padding: 0px 0px 0px 0px;
+}
+
+pre
+{
+	margin:0px;
+	padding:0px;
+	white-space: pre-wrap; /* css-3 */
+	white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
+	word-wrap: break-word; /* Internet Explorer 5.5+ */
+}
Index: /FCKeditor/branches/features/floating_dialog/_test/manual/fckdialog/test1.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/_test/manual/fckdialog/test1.html	(revision 1249)
+++ /FCKeditor/branches/features/floating_dialog/_test/manual/fckdialog/test1.html	(revision 1249)
@@ -0,0 +1,82 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * Sample page.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>FCKeditor - Sample</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+	<meta name="robots" content="noindex, nofollow" />
+	<link href="test1.css" rel="stylesheet" type="text/css" />
+	<script type="text/javascript" src="../../../fckeditor.js"></script>
+</head>
+<body>
+	<h1>
+		FCKDialog Memory Leak Test
+	</h1>
+	<div>
+		A dialog is opened and closed quickly in this page, see if there's any memory leak in taskmgr.
+	</div>
+	<hr />
+	<form action="sampleposteddata.asp" method="post" target="_blank">
+		<script type="text/javascript">
+<!--
+// Automatically calculates the editor base path based on the _samples directory.
+// This is usefull only for these samples. A real application should use something like this:
+// oFCKeditor.BasePath = '/fckeditor/' ;	// '/fckeditor/' is the default value.
+var sBasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('_test')) ;
+
+var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
+oFCKeditor.BasePath	= sBasePath ;
+oFCKeditor.Height	= 300 ;
+oFCKeditor.Value	= '<p>This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.<\/p>' ;
+oFCKeditor.Create() ;
+
+var OpenDialog = true ;
+var RefreshFunc = function()
+{
+	if ( OpenDialog )
+		FCKeditorAPI.GetInstance( 'FCKeditor1' ).Commands.GetCommand( 'Smiley' ).Execute() ;
+	else
+	{
+		var iframes = document.getElementsByTagName( 'iframe' ) ;
+		for ( var i = 0 ; i < iframes.length ; i++ )
+		{
+			if ( iframes[i].src.search( 'fckdialog.html' ) != -1 )
+				iframes[i].parentNode.removeChild( iframes[i] ) ;
+		}
+	}
+	OpenDialog = !OpenDialog ;
+}
+
+var FCKeditor_OnComplete = function()
+{
+	setInterval( RefreshFunc, 200 ) ;
+}
+
+//-->
+		</script>
+		<br />
+		<input type="submit" value="Submit" />
+	</form>
+</body>
+</html>
Index: /FCKeditor/branches/features/floating_dialog/_test/manual/testslist.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/_test/manual/testslist.html	(revision 1248)
+++ /FCKeditor/branches/features/floating_dialog/_test/manual/testslist.html	(revision 1249)
@@ -52,4 +52,5 @@
 						<option value="behaviors/showtableborders.html" selected="selected">Behaviors : Show table borders</option>
 						<option value="fckbrowserinfo/test1.html">fckbrowserinfo: test1</option>
+						<option value="fckdialog/test1.html">fckdialog: test1</option>
 						<option value="fckdomrange/test1.html">fckdomrange: test1</option>
 						<option value="fckdomtools/insertafternode.html">fckdomtools: insertafternode</option>
Index: /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html	(revision 1248)
+++ /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html	(revision 1249)
@@ -27,4 +27,61 @@
 		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 		<meta name="robots" content="noindex, nofollow" />
+		<script type="text/javascript">
+// Get the dialog arguments and the dialog frame from parent window
+$ = {} ;
+$.args = frameElement._DialogArguments ;
+$.editor = $.args.Editor ;
+var imports = [ 'FCK', 'FCKTools', 'FCKDomTools', 'FCKDialog', 'FCKBrowserInfo', 'FCKConfig' ];
+for ( var i = 0 ; i < imports.length ; i++ )
+	$[imports[i]] = $.editor[imports[i]] ;
+
+// Prevent memory leaks in IE.
+if ( $.FCKBrowserInfo.IsIE )
+{
+	function Window_OnBeforeUnload()
+	{
+		$ = null ;
+	}
+	window.attachEvent( "onbeforeunload", Window_OnBeforeUnload ) ;
+}
+
+// Make sure the caret does not stay in the editor iframe.
+window.focus() ;
+
+// Automatically detect the correct document.domain (#123).
+(function()
+{
+	var d = document.domain ;
+
+	while ( true )
+	{
+		// Test if we can access a parent property.
+		try
+		{
+			var parentDomain = $.args.TopWindow ? $.args.TopWindow.document.domain : $.editor.document.domain ;
+
+			if ( document.domain != parentDomain )
+				document.domain = parentDomain ;
+			break ;
+		}
+		catch( e ) {}
+
+		// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
+		d = d.replace( /.*?(?:\.|$)/, '' ) ;
+
+		if ( d.length == 0 )
+			break ;		// It was not able to detect the domain.
+
+		document.domain = d ;
+	}
+})() ;
+
+// Sets the Skin CSS
+document.write( '<link href="' + $.FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
+
+// Sets the language direction.
+document.dir = $.editor.FCKLang.Dir ;
+
+		</script>
 		<!-- script type="text/javascript">
 
@@ -280,6 +337,6 @@
 			return ;
 		
-		var dialogWidth		= dialogFrame.offsetWidth + Math.max( deltaWidth, 0 ) ;
-		var dialogHeight	= dialogFrame.offsetHeight + Math.max( deltaHeight, 0 ) ;
+		var dialogWidth		= frameElement.offsetWidth + Math.max( deltaWidth, 0 ) ;
+		var dialogHeight	= frameElement.offsetHeight + Math.max( deltaHeight, 0 ) ;
 
 		ResizeDialog( dialogWidth, dialogHeight ) ;
