Index: /FCKeditor/trunk/_test/manual/fckdialog/test1.css
===================================================================
--- /FCKeditor/trunk/_test/manual/fckdialog/test1.css	(revision 1398)
+++ /FCKeditor/trunk/_test/manual/fckdialog/test1.css	(revision 1398)
@@ -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/trunk/_test/manual/fckdialog/test1.html
===================================================================
--- /FCKeditor/trunk/_test/manual/fckdialog/test1.html	(revision 1398)
+++ /FCKeditor/trunk/_test/manual/fckdialog/test1.html	(revision 1398)
@@ -0,0 +1,104 @@
+<!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">
+<!--
+Methodology: Open the FCKDialog leak test for at least 3 minutes in IE6, see if the memory usage plataus or increases.
+
+Tests done during floating dialog development:
+1. Disabled all JavaScript from fckdialog.html/No noticeable increase.
+2. Added domain relaxation script without local references/No noticeable increase or very very slight increase after 10 minutes.
+3. Turn Args() and Editor() into functions, add FCK* references/No noticeable increase or very very slight increase after 10 minutes.
+4. Added window.focus(), fck_dialog.css, and language direction/No noticeable increase after 10 minutes.
+5. Added fck_dialog_ie6.js/Steadily increasing memory usage
+6. Added Init(), Throbber(), ResizeContainerSize()/No noticeable increase after 10 minutes. 
+7. Added all resize logic, LoadInnerDialog() and InnerDialogLoaded(), created the Sizer and Main modules/No noticeable increase after 10 minutes.
+8. Added drag and drop handlers/No noticeable increase (But I swear I saw it increasing eariler, with the same code!?!!)
+9. Added logic for closing dialogs, cover blocks, disabling and enabling dialogs, and selection handler/No noticeable increase.
+10. Added logic for handling tabs/No noticeable increase.
+11. Added context menu blocker and Enter and Esc hotkeys/No noticeable increase.
+-->
+<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. If you see
+		a JavaScript error popping up from IE, reopen the IE window and do the test again.
+	</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( 'About' ).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].contentWindow && iframes[i].contentWindow.CloseDialog )
+				iframes[i].contentWindow.CloseDialog() ;
+		}
+	}
+	OpenDialog = !OpenDialog ;
+}
+
+var StartTest = function()
+{
+	setInterval( RefreshFunc, 200 ) ;
+}
+
+var FCKeditor_OnComplete = function()
+{
+	setTimeout( StartTest, 3000 );
+}
+
+//-->
+		</script>
+		<br />
+		<input type="submit" value="Submit" />
+	</form>
+</body>
+</html>
Index: /FCKeditor/trunk/_test/manual/fckdialog/test2.html
===================================================================
--- /FCKeditor/trunk/_test/manual/fckdialog/test2.html	(revision 1398)
+++ /FCKeditor/trunk/_test/manual/fckdialog/test2.html	(revision 1398)
@@ -0,0 +1,85 @@
+﻿<!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 Flash Z-Order Test
+	</h1>
+	<div>
+		Open a dialog, and drag it over the Flash objects. The Flash objects under the submit
+		button should be under the floating dialog window.
+	</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() ;
+//-->
+		</script>
+		<br />
+		<input type="submit" value="Submit" />
+	</form>
+	<hr />
+	<table>
+		<tr>
+			<td>
+				wmode="transparent"<br />
+				<embed width="200" height="100" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
+					src="flash.swf" play="true" loop="true" menu="true" wmode="transparent"></embed></td>
+			</td>
+			<td>
+				wmode="opaque"<br />
+				<embed width="200" height="100" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
+					src="flash.swf" play="true" loop="true" menu="true" wmode="opaque"></embed>
+			</td>
+			<td>
+				wmode="window"<br />
+				<embed width="200" height="100" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
+					src="flash.swf" play="true" loop="true" menu="true" wmode="window"></embed>
+			</td>
+			<td>
+				no wmode<br />
+				<embed width="200" height="100" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
+					src="flash.swf" play="true" loop="true" menu="true"></embed>
+			</td>
+		</tr>
+	</table>
+</body>
+</html>
Index: /FCKeditor/trunk/_test/manual/testslist.html
===================================================================
--- /FCKeditor/trunk/_test/manual/testslist.html	(revision 1397)
+++ /FCKeditor/trunk/_test/manual/testslist.html	(revision 1398)
@@ -52,4 +52,6 @@
 						<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: Memory leak test</option>
+						<option value="fckdialog/test2.html">fckdialog: Dialog/Flash z-placement test</option>
 						<option value="fckdomrange/test1.html">fckdomrange: test1</option>
 						<option value="fckdomtools/insertafternode.html">fckdomtools: insertafternode</option>
Index: /FCKeditor/trunk/editor/_source/classes/fckstyle.js
===================================================================
--- /FCKeditor/trunk/editor/_source/classes/fckstyle.js	(revision 1397)
+++ /FCKeditor/trunk/editor/_source/classes/fckstyle.js	(revision 1398)
@@ -95,5 +95,5 @@
 	 * Apply the style to a FCKDomRange.
 	 */
-	ApplyToRange : function( range, selectIt )
+	ApplyToRange : function( range, selectIt, updateRange )
 	{
 		// ApplyToRange is not valid for FCK_STYLE_OBJECT types.
@@ -112,5 +112,5 @@
 		}
 
-		this.ApplyToRange( range, selectIt ) ;
+		this.ApplyToRange( range, selectIt, updateRange ) ;
 	},
 
@@ -142,5 +142,5 @@
 	 * effect.
 	 */
-	RemoveFromRange : function( range, selectIt )
+	RemoveFromRange : function( range, selectIt, updateRange )
 	{
 		var bookmark ;
@@ -277,5 +277,6 @@
 				range.SelectBookmark( bookmark ) ;
 
-			return ;
+			if ( updateRange )
+				range.MoveToBookmark( bookmark ) ;
 		}
 
@@ -402,4 +403,7 @@
 		if ( selectIt )
 			range.SelectBookmark( bookmark ) ;
+
+		if ( updateRange )
+			range.MoveToBookmark( bookmark ) ;
 	},
 
@@ -750,5 +754,5 @@
 	 *	- Properly handle block containers like <div> and <blockquote>.
 	 */
-	_ApplyBlockStyle : function( range, selectIt )
+	_ApplyBlockStyle : function( range, selectIt, updateRange )
 	{
 		// Bookmark the range so we can re-select it after processing.
@@ -769,4 +773,43 @@
 			// Move everything from the current node to the new one.
 			FCKDomTools.MoveChildren( block, newBlock ) ;
+
+			// If we're in a non-IE browser, and the newBlock is <pre>, and the old block is not <pre>,
+			// then we need to clear linebreaks and compress ANSI whitespaces so that we don't get disrupted
+			// output in <pre> mode. (Bug #1355)
+			if ( !FCKBrowserInfo.IsIE && newBlock.nodeName.IEquals( 'pre' ) && !block.nodeName.IEquals( 'pre' ) )
+			{
+				// If the newBlock's first child is a text node, left-trim it since any ANSI whitespace 
+				// after a non-pre block is meaningless.
+				if ( newBlock.firstChild && newBlock.firstChild.nodeType == 3 )
+					newBlock.firstChild.nodeValue = newBlock.firstChild.nodeValue.LTrim() ;
+
+				// Ditto for the last child.
+				if ( newBlock.lastChild && newBlock.lastChild.nodeType == 3 )
+					newBlock.lastChild.nodeValue = newBlock.lastChild.nodeValue.RTrim() ;
+
+				// DFS walk the newBlock to compress ANSI whitespaces and delete excessive linebreaks.
+				var currentNode = newBlock ;
+				while ( currentNode )
+				{
+					currentNode = FCKDomTools.GetNextSourceNode( currentNode, false, 3, newBlock.parentNode ) ;
+					if ( currentNode )
+					{
+						// If the text node ends with a line break, and its next sibling is a <BR>,
+						// then right-trim the text node.
+						if ( currentNode.nodeValue.charAt( currentNode.nodeValue.length - 1 ) == '\n'
+								&& currentNode.nextSibling 
+								&& currentNode.nextSibling.nodeName.IEquals( 'br' ) )
+							currentNode.nodeValue = currentNode.nodeValue.RTrim() ;
+						// If the text node begins with a line break, and its next sibling is a <BR>,
+						// then left-trim the text node.
+						if ( currentNode.nodeValue.charAt( 0 ) == '\n'
+								&& currentNode.previousSibling 
+								&& currentNode.previousSibling.nodeName.IEquals( 'br' ) )
+							currentNode.nodeValue = currentNode.nodeValue.LTrim() ;
+						// Compress any ANSI whitespaces left.
+						currentNode.nodeValue = currentNode.nodeValue.replace( /[\r\n\t ]+/g, ' ' ) ;
+					}
+				}
+			}
 
 			// Delete the current node.
@@ -777,4 +820,7 @@
 		if ( selectIt )
 			range.SelectBookmark( bookmark ) ;
+
+		if ( updateRange )
+			range.MoveToBookmark( range ) ;
 	},
 
@@ -789,5 +835,5 @@
 	 *        <span style="color: #ff0000;"><span style="background-color: #ffffff">XYZ</span></span>
 	 */
-	_ApplyInlineStyle : function( range, selectIt )
+	_ApplyInlineStyle : function( range, selectIt, updateRange )
 	{
 		var doc = range.Window.document ;
@@ -970,4 +1016,7 @@
 		if ( selectIt )
 			range.SelectBookmark( bookmark ) ;
+
+		if ( updateRange )
+			range.MoveToBookmark( bookmark ) ;
 	},
 
Index: /FCKeditor/trunk/editor/_source/commandclasses/fck_othercommands.js
===================================================================
--- /FCKeditor/trunk/editor/_source/commandclasses/fck_othercommands.js	(revision 1397)
+++ /FCKeditor/trunk/editor/_source/commandclasses/fck_othercommands.js	(revision 1398)
@@ -24,5 +24,5 @@
 
 // ### General Dialog Box Commands.
-var FCKDialogCommand = function( name, title, url, width, height, getStateFunction, getStateParam )
+var FCKDialogCommand = function( name, title, url, width, height, getStateFunction, getStateParam, customValue )
 {
 	this.Name	= name ;
@@ -31,4 +31,5 @@
 	this.Width	= width ;
 	this.Height	= height ;
+	this.CustomValue = customValue ;
 
 	this.GetStateFunction	= getStateFunction ;
@@ -40,5 +41,5 @@
 FCKDialogCommand.prototype.Execute = function()
 {
-	FCKDialog.OpenDialog( 'FCKDialog_' + this.Name , this.Title, this.Url, this.Width, this.Height, null, null, this.Resizable ) ;
+	FCKDialog.OpenDialog( 'FCKDialog_' + this.Name , this.Title, this.Url, this.Width, this.Height, this.CustomValue, null, this.Resizable ) ;
 }
 
Index: /FCKeditor/trunk/editor/_source/commandclasses/fcktextcolorcommand.js
===================================================================
--- /FCKeditor/trunk/editor/_source/commandclasses/fcktextcolorcommand.js	(revision 1397)
+++ /FCKeditor/trunk/editor/_source/commandclasses/fcktextcolorcommand.js	(revision 1398)
@@ -109,5 +109,6 @@
 	this.className = 'ColorDeselected' ;
 	command._Panel.Hide() ;
-	FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, FCKTools.Hitch(command, 'SetColor') ) ;
+	FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, 
+			FCKTools.Bind( command, command.SetColor ) ) ;
 }
 
Index: /FCKeditor/trunk/editor/_source/internals/fck.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fck.js	(revision 1397)
+++ /FCKeditor/trunk/editor/_source/internals/fck.js	(revision 1398)
@@ -957,7 +957,4 @@
 		return ;
 
-	if ( FCKConfig.Debug )
-		FCKDebug._GetWindow() ;
-
 	FCK.SetStatus( FCK_STATUS_ACTIVE ) ;
 }
Index: /FCKeditor/trunk/editor/_source/internals/fckbrowserinfo.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckbrowserinfo.js	(revision 1397)
+++ /FCKeditor/trunk/editor/_source/internals/fckbrowserinfo.js	(revision 1398)
@@ -28,4 +28,5 @@
 	IsIE		: /*@cc_on!@*/false,
 	IsIE7		: /*@cc_on!@*/false && ( parseFloat( s.match( /msie ([\d|\.]+)/ )[1] ) >= 7 ),
+	IsIE6		: /*@cc_on!@*/false && ( parseFloat( s.match( /msie ([\d|\.]+)/ )[1] ) >= 6 ),
 	IsGecko		: s.Contains('gecko/'),
 	IsSafari	: s.Contains(' applewebkit/'),		// Read "IsWebKit"
Index: /FCKeditor/trunk/editor/_source/internals/fckcommands.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckcommands.js	(revision 1397)
+++ /FCKeditor/trunk/editor/_source/internals/fckcommands.js	(revision 1398)
@@ -48,24 +48,23 @@
 		case 'RemoveFormat'	: oCommand = new FCKRemoveFormatCommand() ; break ;
 
-		case 'DocProps'		: oCommand = new FCKDialogCommand( 'DocProps'	, FCKLang.DocProps				, 'dialog/fck_docprops.html'	, 400, 390, FCKCommands.GetFullPageState ) ; break ;
+		case 'DocProps'		: oCommand = new FCKDialogCommand( 'DocProps'	, FCKLang.DocProps				, 'dialog/fck_docprops.html'	, 400, 380, FCKCommands.GetFullPageState ) ; break ;
 		case 'Templates'	: oCommand = new FCKDialogCommand( 'Templates'	, FCKLang.DlgTemplatesTitle		, 'dialog/fck_template.html'	, 380, 450 ) ; break ;
-		case 'Link'			: oCommand = new FCKDialogCommand( 'Link'		, FCKLang.DlgLnkWindowTitle		, 'dialog/fck_link.html'		, 400, 330 ) ; break ;
+		case 'Link'			: oCommand = new FCKDialogCommand( 'Link'		, FCKLang.DlgLnkWindowTitle		, 'dialog/fck_link.html'		, 400, 300 ) ; break ;
 		case 'Unlink'		: oCommand = new FCKUnlinkCommand() ; break ;
-		case 'Anchor'		: oCommand = new FCKDialogCommand( 'Anchor'		, FCKLang.DlgAnchorTitle		, 'dialog/fck_anchor.html'		, 370, 170 ) ; break ;
+		case 'Anchor'		: oCommand = new FCKDialogCommand( 'Anchor'		, FCKLang.DlgAnchorTitle		, 'dialog/fck_anchor.html'		, 370, 160 ) ; break ;
 		case 'AnchorDelete'	: oCommand = new FCKAnchorDeleteCommand() ; break ;
-		case 'BulletedList'	: oCommand = new FCKDialogCommand( 'BulletedList', FCKLang.BulletedListProp		, 'dialog/fck_listprop.html?UL'	, 370, 170 ) ; break ;
-		case 'NumberedList'	: oCommand = new FCKDialogCommand( 'NumberedList', FCKLang.NumberedListProp		, 'dialog/fck_listprop.html?OL'	, 370, 170 ) ; break ;
-		case 'About'		: oCommand = new FCKDialogCommand( 'About'		, FCKLang.About					, 'dialog/fck_about.html'		, 400, 330, function(){ return FCK_TRISTATE_OFF ; } ) ; break ;
+		case 'BulletedList'	: oCommand = new FCKDialogCommand( 'BulletedList', FCKLang.BulletedListProp		, 'dialog/fck_listprop.html?UL'	, 370, 160 ) ; break ;
+		case 'NumberedList'	: oCommand = new FCKDialogCommand( 'NumberedList', FCKLang.NumberedListProp		, 'dialog/fck_listprop.html?OL'	, 370, 160 ) ; break ;
+		case 'About'		: oCommand = new FCKDialogCommand( 'About'		, FCKLang.About					, 'dialog/fck_about.html'		, 400, 310, function(){ return FCK_TRISTATE_OFF ; } ) ; break ;
+		case 'Find'			: oCommand = new FCKDialogCommand( 'Find'		, FCKLang.DlgFindAndReplaceTitle, 'dialog/fck_replace.html'		, 340, 230, null, null, 'Find' ) ; break ;
+		case 'Replace'		: oCommand = new FCKDialogCommand( 'Replace'	, FCKLang.DlgFindAndReplaceTitle, 'dialog/fck_replace.html'		, 340, 230, null, null, 'Replace' ) ; break ;
 
-		case 'Find'			: oCommand = new FCKDialogCommand( 'Find'		, FCKLang.DlgFindAndReplaceTitle			, 'dialog/fck_replace.html'		, 340, 250 ) ; break ;
-		case 'Replace'		: oCommand = new FCKDialogCommand( 'Replace'	, FCKLang.DlgFindAndReplaceTitle		, 'dialog/fck_replace.html'		, 340, 250 ) ; break ;
-
-		case 'Image'		: oCommand = new FCKDialogCommand( 'Image'		, FCKLang.DlgImgTitle			, 'dialog/fck_image.html'		, 450, 400 ) ; break ;
-		case 'Flash'		: oCommand = new FCKDialogCommand( 'Flash'		, FCKLang.DlgFlashTitle			, 'dialog/fck_flash.html'		, 450, 400 ) ; break ;
-		case 'SpecialChar'	: oCommand = new FCKDialogCommand( 'SpecialChar', FCKLang.DlgSpecialCharTitle	, 'dialog/fck_specialchar.html'	, 400, 320 ) ; break ;
+		case 'Image'		: oCommand = new FCKDialogCommand( 'Image'		, FCKLang.DlgImgTitle			, 'dialog/fck_image.html'		, 450, 390 ) ; break ;
+		case 'Flash'		: oCommand = new FCKDialogCommand( 'Flash'		, FCKLang.DlgFlashTitle			, 'dialog/fck_flash.html'		, 450, 390 ) ; break ;
+		case 'SpecialChar'	: oCommand = new FCKDialogCommand( 'SpecialChar', FCKLang.DlgSpecialCharTitle	, 'dialog/fck_specialchar.html'	, 400, 290 ) ; break ;
 		case 'Smiley'		: oCommand = new FCKDialogCommand( 'Smiley'		, FCKLang.DlgSmileyTitle		, 'dialog/fck_smiley.html'		, FCKConfig.SmileyWindowWidth, FCKConfig.SmileyWindowHeight ) ; break ;
 		case 'Table'		: oCommand = new FCKDialogCommand( 'Table'		, FCKLang.DlgTableTitle			, 'dialog/fck_table.html'		, 480, 250 ) ; break ;
 		case 'TableProp'	: oCommand = new FCKDialogCommand( 'Table'		, FCKLang.DlgTableTitle			, 'dialog/fck_table.html?Parent', 480, 250 ) ; break ;
-		case 'TableCellProp': oCommand = new FCKDialogCommand( 'TableCell'	, FCKLang.DlgCellTitle			, 'dialog/fck_tablecell.html'	, 550, 250 ) ; break ;
+		case 'TableCellProp': oCommand = new FCKDialogCommand( 'TableCell'	, FCKLang.DlgCellTitle			, 'dialog/fck_tablecell.html'	, 550, 240 ) ; break ;
 
 		case 'Style'		: oCommand = new FCKStyleCommand() ; break ;
@@ -113,13 +112,13 @@
 		case 'TableDelete'				: oCommand = new FCKTableCommand('TableDelete') ; break ;
 
-		case 'Form'			: oCommand = new FCKDialogCommand( 'Form'		, FCKLang.Form			, 'dialog/fck_form.html'		, 380, 230 ) ; break ;
-		case 'Checkbox'		: oCommand = new FCKDialogCommand( 'Checkbox'	, FCKLang.Checkbox		, 'dialog/fck_checkbox.html'	, 380, 230 ) ; break ;
-		case 'Radio'		: oCommand = new FCKDialogCommand( 'Radio'		, FCKLang.RadioButton	, 'dialog/fck_radiobutton.html'	, 380, 230 ) ; break ;
-		case 'TextField'	: oCommand = new FCKDialogCommand( 'TextField'	, FCKLang.TextField		, 'dialog/fck_textfield.html'	, 380, 230 ) ; break ;
-		case 'Textarea'		: oCommand = new FCKDialogCommand( 'Textarea'	, FCKLang.Textarea		, 'dialog/fck_textarea.html'	, 380, 230 ) ; break ;
-		case 'HiddenField'	: oCommand = new FCKDialogCommand( 'HiddenField', FCKLang.HiddenField	, 'dialog/fck_hiddenfield.html'	, 380, 230 ) ; break ;
-		case 'Button'		: oCommand = new FCKDialogCommand( 'Button'		, FCKLang.Button		, 'dialog/fck_button.html'		, 380, 230 ) ; break ;
-		case 'Select'		: oCommand = new FCKDialogCommand( 'Select'		, FCKLang.SelectionField, 'dialog/fck_select.html'		, 400, 380 ) ; break ;
-		case 'ImageButton'	: oCommand = new FCKDialogCommand( 'ImageButton', FCKLang.ImageButton	, 'dialog/fck_image.html?ImageButton', 450, 400 ) ; break ;
+		case 'Form'			: oCommand = new FCKDialogCommand( 'Form'		, FCKLang.Form			, 'dialog/fck_form.html'		, 380, 210 ) ; break ;
+		case 'Checkbox'		: oCommand = new FCKDialogCommand( 'Checkbox'	, FCKLang.Checkbox		, 'dialog/fck_checkbox.html'	, 380, 200 ) ; break ;
+		case 'Radio'		: oCommand = new FCKDialogCommand( 'Radio'		, FCKLang.RadioButton	, 'dialog/fck_radiobutton.html'	, 380, 200 ) ; break ;
+		case 'TextField'	: oCommand = new FCKDialogCommand( 'TextField'	, FCKLang.TextField		, 'dialog/fck_textfield.html'	, 380, 210 ) ; break ;
+		case 'Textarea'		: oCommand = new FCKDialogCommand( 'Textarea'	, FCKLang.Textarea		, 'dialog/fck_textarea.html'	, 380, 210 ) ; break ;
+		case 'HiddenField'	: oCommand = new FCKDialogCommand( 'HiddenField', FCKLang.HiddenField	, 'dialog/fck_hiddenfield.html'	, 380, 190 ) ; break ;
+		case 'Button'		: oCommand = new FCKDialogCommand( 'Button'		, FCKLang.Button		, 'dialog/fck_button.html'		, 380, 210 ) ; break ;
+		case 'Select'		: oCommand = new FCKDialogCommand( 'Select'		, FCKLang.SelectionField, 'dialog/fck_select.html'		, 400, 340 ) ; break ;
+		case 'ImageButton'	: oCommand = new FCKDialogCommand( 'ImageButton', FCKLang.ImageButton	, 'dialog/fck_image.html?ImageButton', 450, 390 ) ; break ;
 
 		case 'SpellCheck'	: oCommand = new FCKSpellCheckCommand() ; break ;
Index: /FCKeditor/trunk/editor/_source/internals/fckdialog.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckdialog.js	(revision 1397)
+++ /FCKeditor/trunk/editor/_source/internals/fckdialog.js	(revision 1398)
@@ -22,17 +22,227 @@
  */
 
-var FCKDialog = new Object() ;
-
-// This method opens a dialog window using the standard dialog template.
-FCKDialog.OpenDialog = function( dialogName, dialogTitle, dialogPage, width, height, customValue, parentWindow, resizable )
+var FCKDialog = ( function()
 {
-	// Setup the dialog info.
-	var oDialogInfo = new Object() ;
-	oDialogInfo.Title = dialogTitle ;
-	oDialogInfo.Page = dialogPage ;
-	oDialogInfo.Editor = window ;
-	oDialogInfo.CustomValue = customValue ;		// Optional
-
-	var sUrl = FCKConfig.BasePath + 'fckdialog.html' ;
-	this.Show( oDialogInfo, dialogName, sUrl, width, height, parentWindow, resizable ) ;
-}
+	var topDialog ;
+	var baseZIndex ;
+	var cover ;
+	
+	// The document that holds the dialog.
+	var topWindow = window.parent ;
+
+	while ( topWindow.parent && topWindow.parent != topWindow )
+	{
+		try
+		{
+			if ( topWindow.parent.document.domain != document.domain )
+				break ;
+			if ( topWindow.parent.document.getElementsByTagName( 'frameset' ).length > 0 )
+				break ;
+		}
+		catch ( e )
+		{
+			break ;
+		}
+		topWindow = topWindow.parent ;
+	}
+
+	var topDocument = topWindow.document ;
+
+	var getZIndex = function()
+	{
+		if ( !baseZIndex )
+			baseZIndex = FCKConfig.FloatingPanelsZIndex + 999 ;
+		return ++baseZIndex ;
+	}
+
+	// TODO : This logic is not actually working when reducing the window, only
+	// when enlarging it.
+	var resizeHandler = function()
+	{
+		if ( !cover )
+			return ;
+		
+		var documentElement = topDocument.documentElement ;
+			
+		FCKDomTools.SetElementStyles( cover,
+			{
+				'width' : Math.max( documentElement.scrollWidth,
+					documentElement.clientWidth,
+					topDocument.scrollWidth || 0 ) - 1 + 'px',
+				'height' : Math.max( documentElement.scrollHeight,
+					documentElement.clientHeight,
+					topDocument.scrollHeight || 0 ) - 1 + 'px'
+			} ) ;
+	}
+
+	return {
+		SelectionData : null,
+
+		/**
+		 * Opens a dialog window using the standard dialog template.
+		 */
+		OpenDialog : function( dialogName, dialogTitle, dialogPage, width, height, customValue, parentWindow, resizable )
+		{
+			if ( !topDialog )
+				this.DisplayMainCover() ;
+
+			// Setup the dialog info to be passed to the dialog.
+			var dialogInfo =
+			{
+				Title : dialogTitle,
+				Page : dialogPage,
+				Editor : window,
+				CustomValue : customValue,		// Optional
+				SelectionData : null,
+				TopWindow : topWindow
+			}
+
+			var currentInstance = FCK.ToolbarSet.CurrentInstance ;
+
+			// IE doens't support multiple selections, even if in different
+			// IFRAMEs, like the dialog, so the current selection must be saved to
+			// be restored in the dialog code.
+			if ( FCKBrowserInfo.IsIE && !topDialog )
+			{
+				var editorDocument = currentInstance.EditorDocument ;
+				var selection = editorDocument.selection ;
+				var range ;
+
+				if ( selection )
+				{
+					range = selection.createRange() ;
+
+					// Ensure that the range comes from the editor document.
+					if ( range )
+					{
+						if ( range.parentElement && FCKTools.GetElementDocument( range.parentElement() ) != editorDocument )
+							range = null ;
+						else if ( range.item && FCKTools.GetElementDocument( range.item(0) )!= editorDocument )
+							range = null ;
+					}
+				}
+
+				this.SelectionData = range ;
+			}
+
+			// Calculate the dialog position, centering it on the screen.
+			var viewSize = FCKTools.GetViewPaneSize( topWindow ) ;
+			var scrollPosition = FCKTools.GetScrollPosition( topWindow ) ;
+			var iTop  = Math.max( scrollPosition.Y + ( viewSize.Height - height - 20 ) / 2, 0 ) ;
+			var iLeft = Math.max( scrollPosition.X + ( viewSize.Width - width - 20 )  / 2, 0 ) ;
+
+			// Setup the IFRAME that will hold the dialog.
+			var dialog = topDocument.createElement( 'iframe' ) ;
+			dialog.src = FCKConfig.BasePath + 'fckdialog.html' ;
+
+			// Dummy URL for testing whether the code in fckdialog.js alone leaks memory.
+			// dialog.src = 'about:blank';
+
+			dialog.frameBorder = 0 ;
+			dialog.allowTransparency = true ;
+			FCKDomTools.SetElementStyles( dialog,
+					{
+						'position'	: 'absolute',
+						'top'		: iTop + 'px',
+						'left'		: iLeft + 'px',
+						'width'		: width + 'px',
+						'height'	: height + 'px',
+						'zIndex'	: getZIndex()
+					} ) ;
+
+			// Save the dialog info to be used by the dialog page once loaded.
+			dialog._DialogArguments = dialogInfo ;
+
+			// Append the IFRAME to the target document.
+			topDocument.body.appendChild( dialog ) ;
+
+			// Keep record of the dialog's parent/child relationships.
+			dialog._ParentDialog = topDialog ;
+			topDialog = dialog ;
+		},
+
+		/**
+		 * (For internal use)
+		 * Called when the top dialog is closed.
+		 */
+		OnDialogClose : function( dialogWindow )
+		{
+			var dialog = dialogWindow.frameElement ;
+			FCKDomTools.RemoveNode( dialog ) ;
+
+			if ( dialog._ParentDialog )		// Nested Dialog.
+			{
+				topDialog = dialog._ParentDialog ;
+				dialog._ParentDialog.contentWindow.SetEnabled( true ) ;
+			}
+			else							// First Dialog.
+			{
+				// Set the Focus in the browser, so the "OnBlur" event is not
+				// fired. In IE, there is no need to d othat because the dialog
+				// already moved the selection to the editing area before
+				// closing (EnsureSelection). Also, the Focus() call here
+				// causes memory leak on IE7 (weird).
+				if ( !FCKBrowserInfo.IsIE )
+					FCK.Focus() ;
+
+				this.HideMainCover() ;
+				topDialog = null ;
+				this.SelectionData = null ;
+			}
+		},
+
+		DisplayMainCover : function()
+		{
+			// Setup the DIV that will be used to cover.
+			cover = topDocument.createElement( 'div' ) ;
+			FCKDomTools.SetElementStyles( cover,
+				{
+					'position' : 'absolute',
+					'zIndex' : getZIndex(),
+					'top' : '0px',
+					'left' : '0px',
+					'backgroundColor' : FCKConfig.BackgroundBlockerColor
+				} ) ;
+			FCKDomTools.SetOpacity( cover, FCKConfig.BackgroundBlockerOpacity ) ;
+			
+			// For IE6-, we need to fill the cover with a transparent IFRAME,
+			// to properly block <select> fields.
+			if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
+			{
+				var iframe = topDocument.createElement( 'iframe' ) ;
+				iframe.hideFocus = true ;
+				iframe.frameBorder = 0 ;
+				iframe.src = FCKTools.GetVoidUrl() ;
+				FCKDomTools.SetElementStyles( iframe, 
+					{
+						'width' : '100%',
+						'height' : '100%',
+						'position' : 'absolute',
+						'left' : '0px',
+						'top' : '0px',
+						'filter' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)'
+					} ) ;
+				cover.appendChild( iframe ) ;
+			}
+
+			// We need to manually adjust the cover size on resize.
+			FCKTools.AddEventListener( topWindow, 'resize', resizeHandler ) ;
+			resizeHandler() ;
+
+			topDocument.body.appendChild( cover ) ;
+
+			FCKFocusManager.Lock() ;
+		},
+		
+		HideMainCover : function()
+		{
+			FCKDomTools.RemoveNode( cover ) ;
+			FCKFocusManager.Unlock() ;
+		},
+		
+		GetCover : function()
+		{
+			return cover ;
+		}
+	} ;
+} )() ;
Index: Keditor/trunk/editor/_source/internals/fckdialog_gecko.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckdialog_gecko.js	(revision 1397)
+++ 	(revision )
@@ -1,103 +1,0 @@
-﻿/*
- * 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 ==
- *
- * Dialog windows operations. (Gecko specific implementations)
- */
-
-FCKDialog.Show = function( dialogInfo, dialogName, pageUrl, dialogWidth, dialogHeight, parentWindow, resizable )
-{
-	var iTop  = (FCKConfig.ScreenHeight - dialogHeight) / 2 ;
-	var iLeft = (FCKConfig.ScreenWidth  - dialogWidth)  / 2 ;
-
-	var sOption  = "location=no,menubar=no,toolbar=no,dependent=yes,dialog=yes,minimizable=no,alwaysRaised=yes" +
-		",resizable="  + ( resizable ? 'yes' : 'no' ) +
-		",width="  + dialogWidth +
-		",height=" + dialogHeight +
-		",top="  + iTop +
-		",left=" + iLeft ;
-
-	if ( !parentWindow )
-		parentWindow = window ;
-
-	FCKFocusManager.Lock() ;
-
-	var oWindow = parentWindow.open( '', 'FCKeditorDialog_' + dialogName, sOption, true ) ;
-
-	if ( !oWindow )
-	{
-		alert( FCKLang.DialogBlocked ) ;
-		FCKFocusManager.Unlock() ;
-		return ;
-	}
-
-	oWindow.moveTo( iLeft, iTop ) ;
-	oWindow.resizeTo( dialogWidth, dialogHeight ) ;
-	oWindow.focus() ;
-	oWindow.location.href = pageUrl ;
-
-	oWindow.dialogArguments = dialogInfo ;
-
-	// On some Gecko browsers (probably over slow connections) the
-	// "dialogArguments" are not set to the target window so we must
-	// put it in the opener window so it can be used by the target one.
-	parentWindow.FCKLastDialogInfo = dialogInfo ;
-
-	this.Window = oWindow ;
-
-	// Try/Catch must be used to avoid an error when using a frameset
-	// on a different domain:
-	// "Permission denied to get property Window.releaseEvents".
-	try
-	{
-		window.top.parent.addEventListener( 'mousedown', this.CheckFocus, true ) ;
-		window.top.parent.addEventListener( 'mouseup', this.CheckFocus, true ) ;
-		window.top.parent.addEventListener( 'click', this.CheckFocus, true ) ;
-		window.top.parent.addEventListener( 'focus', this.CheckFocus, true ) ;
-	}
-	catch (e)
-	{}
-}
-
-FCKDialog.CheckFocus = function()
-{
-	// It is strange, but we have to check the FCKDialog existence to avoid a
-	// random error: "FCKDialog is not defined".
-	if ( typeof( FCKDialog ) != "object" )
-		return false ;
-
-	if ( FCKDialog.Window && !FCKDialog.Window.closed )
-		FCKDialog.Window.focus() ;
-	else
-	{
-		// Try/Catch must be used to avoid an error when using a frameset
-		// on a different domain:
-		// "Permission denied to get property Window.releaseEvents".
-		try
-		{
-			window.top.parent.removeEventListener( 'onmousedown', FCKDialog.CheckFocus, true ) ;
-			window.top.parent.removeEventListener( 'mouseup', FCKDialog.CheckFocus, true ) ;
-			window.top.parent.removeEventListener( 'click', FCKDialog.CheckFocus, true ) ;
-			window.top.parent.removeEventListener( 'onfocus', FCKDialog.CheckFocus, true ) ;
-		}
-		catch (e)
-		{}
-	}
-	return false ;
-}
Index: Keditor/trunk/editor/_source/internals/fckdialog_ie.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckdialog_ie.js	(revision 1397)
+++ 	(revision )
@@ -1,49 +1,0 @@
-﻿/*
- * 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 ==
- *
- * Dialog windows operations. (IE specific implementations)
- */
-
-FCKDialog.Show = function( dialogInfo, dialogName, pageUrl, dialogWidth, dialogHeight, parentWindow, resizable )
-{
-	if ( !parentWindow )
-		parentWindow = window ;
-
-	var sOptions = 'help:no;scroll:no;status:no' +
-		';resizable:'  + ( resizable ? 'yes' : 'no' ) +
-		';dialogWidth:' + dialogWidth + 'px' +
-		';dialogHeight:' + dialogHeight + 'px' ;
-
-	FCKFocusManager.Lock() ;
-
-	var oReturn = 'B' ;
-
-	try
-	{
-		dialogInfo.DialogName = dialogName ;
-		oReturn = parentWindow.showModalDialog( pageUrl, dialogInfo, sOptions ) ;
-	}
-	catch( e ) {}
-
-	if ( 'B' === oReturn )
-		alert( FCKLang.DialogBlocked ) ;
-
-	FCKFocusManager.Unlock() ;
-}
Index: /FCKeditor/trunk/editor/_source/internals/fckdomtools.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckdomtools.js	(revision 1397)
+++ /FCKeditor/trunk/editor/_source/internals/fckdomtools.js	(revision 1398)
@@ -925,4 +925,15 @@
 	},
 
+	SetOpacity : function( element, opacity )
+	{
+		if ( FCKBrowserInfo.IsIE )
+		{
+			opacity = Math.round( opacity * 100 ) ;
+			element.style.filter = ( opacity > 100 ? '' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')' ) ;
+		}
+		else
+			element.style.opacity = opacity ;
+	},
+
 	GetCurrentElementStyle : function( element, propertyName )
 	{
@@ -936,10 +947,17 @@
 	{
 		var currentElement = element ;
+
 		while ( currentElement != FCKTools.GetElementDocument( currentElement ).documentElement )
 		{
 			if ( this.GetCurrentElementStyle( currentElement, 'position' ) != 'static' )
 				return currentElement ;
-			currentElement = currentElement.parentNode ;
-		}
+
+			if ( currentElement == FCKTools.GetElementDocument( currentElement ).documentElement
+					&& currentWindow != w )
+				currentElement = currentWindow.frameElement ;
+			else
+				currentElement = currentElement.parentNode ;
+		}
+
 		return null ;
 	},
Index: /FCKeditor/trunk/editor/_source/internals/fcktools.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fcktools.js	(revision 1397)
+++ /FCKeditor/trunk/editor/_source/internals/fcktools.js	(revision 1398)
@@ -367,6 +367,6 @@
 {
 	// There is no compatMode in Safari, but it seams that it always behave as
-	// CSS1Compat, so let's assume it as the default.
-	return ( 'CSS1Compat' == ( document.compatMode || 'CSS1Compat' ) ) ;
+	// CSS1Compat, so let's assume it as the default for that browser.
+	return ( 'CSS1Compat' == ( document.compatMode || ( FCKBrowserInfo.IsSafari ? 'CSS1Compat' : null ) ) ) ;
 }
 
@@ -452,5 +452,5 @@
 				prevNode = null ;
 				if ( curNode )
-					curWindow = FCKTools.GetElementWindow( curNode ) ;
+					curWindow = curNode.contentWindow.parent ;
 			}
 			else
@@ -612,10 +612,35 @@
 
 /**
- * Utility function to wrap a call to an object's method,
- * so it can be passed for example to an event handler,
- * and then it will be executed with 'this' being the object.
- */
-FCKTools.Hitch = function( obj, methodName )
-{
-  return function() { obj[methodName].apply(obj, arguments); } ;
-}
+ * Binding the "this" reference to an object for a function.
+ */
+FCKTools.Bind = function( subject, func )
+{
+  return function(){ return func.apply( subject, arguments ) ; } ;
+}
+
+/**
+ * Retrieve the correct "empty iframe" URL for the current browser, which
+ * causes the minimum fuzz (e.g. security warnings in HTTPS, DNS error in
+ * IE5.5, etc.) for that browser, making the iframe ready to DOM use whithout
+ * having to loading an external file.
+ */
+FCKTools.GetVoidUrl = function()
+{
+	if ( FCK_IS_CUSTOM_DOMAIN )
+		return "javascript: void( function(){" +
+			"document.open();" +
+			"document.write('<html><head><title></title></head><body></body></html>');" +
+			"document.domain = '" + FCK_RUNTIME_DOMAIN + "';" +
+			"document.close();" +
+			"}() ) ;";
+
+	if ( FCKBrowserInfo.IsIE )
+	{
+		if ( FCKBrowserInfo.IsIE7 || !FCKBrowserInfo.IsIE6 )
+			return "" ;					// IE7+ / IE5.5
+		else
+			return "javascript: '';" ;	// IE6+
+	}
+
+	return "javascript: void(0);" ;		// All other browsers.
+}
Index: /FCKeditor/trunk/editor/_source/internals/fcktools_gecko.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fcktools_gecko.js	(revision 1397)
+++ /FCKeditor/trunk/editor/_source/internals/fcktools_gecko.js	(revision 1398)
@@ -31,7 +31,9 @@
 {
 	if ( FCKBrowserInfo.IsGecko )
-		element.style.MozUserSelect	= 'none' ;	// Gecko only.
+		element.style.MozUserSelect		= 'none' ;	// Gecko only.
+	else if ( FCKBrowserInfo.IsSafari )
+		element.style.KhtmlUserSelect	= 'none' ;	// WebKit only.
 	else
-		element.style.userSelect	= 'none' ;	// CSS3 (not supported yet).
+		element.style.userSelect		= 'none' ;	// CSS3 (not supported yet).
 }
 
@@ -224,5 +226,5 @@
 	targetWindow.$ = function( id )
 	{
-		return this.document.getElementById( id ) ;
+		return targetWindow.document.getElementById( id ) ;
 	} ;
 }
Index: /FCKeditor/trunk/editor/dialog/common/fck_dialog_common.js
===================================================================
--- /FCKeditor/trunk/editor/dialog/common/fck_dialog_common.js	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/common/fck_dialog_common.js	(revision 1398)
@@ -91,32 +91,42 @@
 }
 
-var KeyIdentifierMap = 
-{
-	End		: 35,
-	Home	: 36,
-	Left	: 37,
-	Right	: 39,
-	'U+00007F' : 46		// Delete
-} 
+function SelectField( elementId )
+{
+	var element = GetE( elementId ) ;
+	element.focus() ;
+	element.select() ;
+}
 
 // Functions used by text fields to accept numbers only.
-function IsDigit( e )
-{
-	if ( !e )
-		e = event ;
-
-	var iCode = ( e.keyCode || e.charCode ) ;
-	
-	if ( !iCode && e.keyIdentifier && ( e.keyIdentifier in KeyIdentifierMap ) ) 
-			iCode = KeyIdentifierMap[ e.keyIdentifier ] ;
-
-	return (
-			( iCode >= 48 && iCode <= 57 )		// Numbers
-			|| (iCode >= 35 && iCode <= 40)		// Arrows, Home, End
-			|| iCode == 8						// Backspace
-			|| iCode == 46						// Delete
-			|| iCode == 9						// Tab
-	) ;
-}
+var IsDigit = ( function()
+	{
+		var KeyIdentifierMap = 
+		{
+			End			: 35,
+			Home		: 36,
+			Left		: 37,
+			Right		: 39,
+			'U+00007F'	: 46		// Delete
+		} ;
+
+		return function ( e )
+			{
+				if ( !e )
+					e = event ;
+
+				var iCode = ( e.keyCode || e.charCode ) ;
+				
+				if ( !iCode && e.keyIdentifier && ( e.keyIdentifier in KeyIdentifierMap ) ) 
+						iCode = KeyIdentifierMap[ e.keyIdentifier ] ;
+
+				return (
+						( iCode >= 48 && iCode <= 57 )		// Numbers
+						|| (iCode >= 35 && iCode <= 40)		// Arrows, Home, End
+						|| iCode == 8						// Backspace
+						|| iCode == 46						// Delete
+						|| iCode == 9						// Tab
+				) ;
+			}
+	} )() ;
 
 String.prototype.Trim = function()
Index: /FCKeditor/trunk/editor/dialog/fck_anchor.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_anchor.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_anchor.html	(revision 1398)
@@ -30,14 +30,16 @@
 		<script type="text/javascript">
 
-var oEditor	= window.parent.InnerDialogLoaded() ;
-var FCK		= oEditor.FCK ;
-var FCKBrowserInfo = oEditor.FCKBrowserInfo ;
-var FCKTools = oEditor.FCKTools ;
-var FCKRegexLib = oEditor.FCKRegexLib ;
-
-// Gets the document DOM
-var oDOM = oEditor.FCK.EditorDocument ;
-
-var oFakeImage = FCK.Selection.GetSelectedElement() ;
+var dialog			= window.parent ;
+var oEditor			= dialog.InnerDialogLoaded() ;
+
+var FCK				= oEditor.FCK ;
+var FCKBrowserInfo	= oEditor.FCKBrowserInfo ;
+var FCKTools		= oEditor.FCKTools ;
+var FCKRegexLib		= oEditor.FCKRegexLib ;
+
+var oDOM			= FCK.EditorDocument ;
+
+var oFakeImage = dialog.Selection.GetSelectedElement() ;
+
 var oAnchor ;
 
@@ -70,4 +72,6 @@
 	window.parent.SetOkButton( true ) ;
 	window.parent.SetAutoSize( true ) ;
+
+	SelectField( 'txtName' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_button.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_button.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_button.html	(revision 1398)
@@ -30,10 +30,11 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor	= dialog.InnerDialogLoaded() ;
 
 // Gets the document DOM
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 window.onload = function()
@@ -53,6 +54,7 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
+	SelectField( 'txtName' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_checkbox.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_checkbox.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_checkbox.html	(revision 1398)
@@ -30,10 +30,11 @@
 		<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor	= dialog.InnerDialogLoaded() ;
 
 // Gets the document DOM
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 window.onload = function()
@@ -51,6 +52,7 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
+	SelectField( 'txtName' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_colorselector.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_colorselector.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_colorselector.html	(revision 1398)
@@ -137,6 +137,6 @@
 function Ok()
 {
-	if ( typeof(window.parent.args.CustomValue) == 'function' )
-		window.parent.args.CustomValue( document.getElementById('selcolor').value ) ;
+	if ( typeof(window.parent.Args().CustomValue) == 'function' )
+		window.parent.Args().CustomValue( document.getElementById('selcolor').value ) ;
 
 	return true ;
Index: /FCKeditor/trunk/editor/dialog/fck_docprops.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_docprops.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_docprops.html	(revision 1398)
@@ -375,9 +375,9 @@
 	switch ( wich )
 	{
-		case 'Back'			: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectBackColor, window ) ; return ;
-		case 'ColorText'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectColorText, window ) ; return ;
-		case 'ColorLink'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectColorLink, window ) ; return ;
-		case 'ColorVisited'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectColorVisited, window ) ; return ;
-		case 'ColorActive'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectColorActive, window ) ; return ;
+		case 'Back'			: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, SelectBackColor, window ) ; return ;
+		case 'ColorText'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, SelectColorText, window ) ; return ;
+		case 'ColorLink'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, SelectColorLink, window ) ; return ;
+		case 'ColorVisited'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, SelectColorVisited, window ) ; return ;
+		case 'ColorActive'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, SelectColorActive, window ) ; return ;
 	}
 }
Index: /FCKeditor/trunk/editor/dialog/fck_flash/fck_flash.js
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_flash/fck_flash.js	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_flash/fck_flash.js	(revision 1398)
@@ -22,5 +22,6 @@
  */
 
-var oEditor		= window.parent.InnerDialogLoaded() ;
+var dialog		= window.parent ;
+var oEditor		= dialog.InnerDialogLoaded() ;
 var FCK			= oEditor.FCK ;
 var FCKLang		= oEditor.FCKLang ;
@@ -30,11 +31,11 @@
 
 // Set the dialog tabs.
-window.parent.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ;
+dialog.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ;
 
 if ( FCKConfig.FlashUpload )
-	window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
+	dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
 
 if ( !FCKConfig.FlashDlgHideAdvanced )
-	window.parent.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ;
+	dialog.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ;
 
 // Function called when a dialog tag is selected.
@@ -47,5 +48,5 @@
 
 // Get the selected flash embed (if available).
-var oFakeImage = FCK.Selection.GetSelectedElement() ;
+var oFakeImage = dialog.Selection.GetSelectedElement() ;
 var oEmbed ;
 
@@ -73,8 +74,10 @@
 		GetE('frmUpload').action = FCKConfig.FlashUploadURL ;
 
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetAutoSize( true ) ;
 
 	// Activate the "OK" button.
-	window.parent.SetOkButton( true ) ;
+	dialog.SetOkButton( true ) ;
+
+	SelectField( 'txtUrl' ) ;
 }
 
@@ -115,5 +118,5 @@
 	if ( GetE('txtUrl').value.length == 0 )
 	{
-		window.parent.SetSelectedTab( 'Info' ) ;
+		dialog.SetSelectedTab( 'Info' ) ;
 		GetE('txtUrl').focus() ;
 
@@ -228,5 +231,5 @@
 	UpdatePreview() ;
 
-	window.parent.SetSelectedTab( 'Info' ) ;
+	dialog.SetSelectedTab( 'Info' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_form.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_form.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_form.html	(revision 1398)
@@ -30,10 +30,11 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
 
 // Gets the document DOM
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = oEditor.FCKSelection.MoveToAncestorNode( 'FORM' ) ;
+var oActiveEl = dialog.Selection.GetSelection().MoveToAncestorNode( 'FORM' ) ;
 
 window.onload = function()
@@ -51,6 +52,7 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
+	SelectField( 'txtName' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_hiddenfield.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_hiddenfield.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_hiddenfield.html	(revision 1398)
@@ -1,3 +1,3 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
+﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
 <!--
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
@@ -30,5 +30,7 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
+
 var FCK = oEditor.FCK ;
 
@@ -37,5 +39,5 @@
 
 // Get the selected flash embed (if available).
-var oFakeImage = FCK.Selection.GetSelectedElement() ;
+var oFakeImage = dialog.Selection.GetSelectedElement() ;
 var oActiveEl ;
 
@@ -59,6 +61,7 @@
 	}
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
+	SelectField( 'txtName' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_image/fck_image.js
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_image/fck_image.js	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_image/fck_image.js	(revision 1398)
@@ -22,5 +22,6 @@
  */
 
-var oEditor		= window.parent.InnerDialogLoaded() ;
+var dialog		= window.parent ;
+var oEditor		= dialog.InnerDialogLoaded() ;
 var FCK			= oEditor.FCK ;
 var FCKLang		= oEditor.FCKLang ;
@@ -33,14 +34,14 @@
 
 // Set the dialog tabs.
-window.parent.AddTab( 'Info', FCKLang.DlgImgInfoTab ) ;
+dialog.AddTab( 'Info', FCKLang.DlgImgInfoTab ) ;
 
 if ( !bImageButton && !FCKConfig.ImageDlgHideLink )
-	window.parent.AddTab( 'Link', FCKLang.DlgImgLinkTab ) ;
+	dialog.AddTab( 'Link', FCKLang.DlgImgLinkTab ) ;
 
 if ( FCKConfig.ImageUpload )
-	window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
+	dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
 
 if ( !FCKConfig.ImageDlgHideAdvanced )
-	window.parent.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;
+	dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;
 
 // Function called when a dialog tag is selected.
@@ -54,5 +55,5 @@
 
 // Get the selected image (if available).
-var oImage = FCK.Selection.GetSelectedElement() ;
+var oImage = dialog.Selection.GetSelectedElement() ;
 
 if ( oImage && oImage.tagName != 'IMG' && !( oImage.tagName == 'INPUT' && oImage.type == 'image' ) )
@@ -60,5 +61,5 @@
 
 // Get the active link.
-var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;
+var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ;
 
 var oImageOriginal ;
@@ -112,8 +113,10 @@
 		GetE('frmUpload').action = FCKConfig.ImageUploadURL ;
 
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetAutoSize( true ) ;
 
 	// Activate the "OK" button.
-	window.parent.SetOkButton( true ) ;
+	dialog.SetOkButton( true ) ;
+
+	SelectField( 'txtUrl' ) ;
 }
 
@@ -198,5 +201,5 @@
 	if ( GetE('txtUrl').value.length == 0 )
 	{
-		window.parent.SetSelectedTab( 'Info' ) ;
+		dialog.SetSelectedTab( 'Info' ) ;
 		GetE('txtUrl').focus() ;
 
@@ -247,4 +250,6 @@
 		else			// Creating a new link.
 		{
+			dialog.Selection.EnsureSelection() ;
+
 			if ( !bHasImage )
 				oEditor.FCKSelection.SelectNode( oImage ) ;
@@ -434,5 +439,5 @@
 	}
 
-	window.parent.SetSelectedTab( 'Info' ) ;
+	dialog.SetSelectedTab( 'Info' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_link/fck_link.js
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_link/fck_link.js	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_link/fck_link.js	(revision 1398)
@@ -22,5 +22,7 @@
  */
 
-var oEditor		= window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
+
 var FCK			= oEditor.FCK ;
 var FCKLang		= oEditor.FCKLang ;
@@ -32,14 +34,14 @@
 
 // Set the dialog tabs.
-window.parent.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ;
+dialog.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ;
 
 if ( !FCKConfig.LinkDlgHideTarget )
-	window.parent.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ;
+	dialog.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ;
 
 if ( FCKConfig.LinkUpload )
-	window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload, true ) ;
+	dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload, true ) ;
 
 if ( !FCKConfig.LinkDlgHideAdvanced )
-	window.parent.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;
+	dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;
 
 // Function called when a dialog tag is selected.
@@ -51,5 +53,5 @@
 	ShowE('divAttribs'	, ( tabCode == 'Advanced' ) ) ;
 
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
@@ -125,5 +127,5 @@
 
 // oLink: The actual selected link in the editor.
-var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;
+var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ;
 if ( oLink )
 	FCK.Selection.SelectNode( oLink ) ;
@@ -157,5 +159,6 @@
 
 	// Activate the "OK" button.
-	window.parent.SetOkButton( true ) ;
+	dialog.SetOkButton( true ) ;
+	SelectField( 'txtUrl' ) ;
 }
 
@@ -339,14 +342,14 @@
 
 	if ( !FCKConfig.LinkDlgHideTarget )
-		window.parent.SetTabVisibility( 'Target'	, (linkType == 'url') ) ;
+		dialog.SetTabVisibility( 'Target'	, (linkType == 'url') ) ;
 
 	if ( FCKConfig.LinkUpload )
-		window.parent.SetTabVisibility( 'Upload'	, (linkType == 'url') ) ;
+		dialog.SetTabVisibility( 'Upload'	, (linkType == 'url') ) ;
 
 	if ( !FCKConfig.LinkDlgHideAdvanced )
-		window.parent.SetTabVisibility( 'Advanced'	, (linkType != 'anchor' || bHasAnchors) ) ;
+		dialog.SetTabVisibility( 'Advanced'	, (linkType != 'anchor' || bHasAnchors) ) ;
 
 	if ( linkType == 'email' )
-		window.parent.SetAutoSize( true ) ;
+		dialog.SetAutoSize( true ) ;
 }
 
@@ -372,5 +375,5 @@
 
 	if ( targetType == 'popup' )
-		window.parent.SetAutoSize( true ) ;
+		dialog.SetAutoSize( true ) ;
 }
 
@@ -621,4 +624,5 @@
 
 	// Select the (first) link.
+	dialog.Selection.EnsureSelection() ;
 	oEditor.FCKSelection.SelectNode( aLinks[0] );
 
@@ -635,5 +639,5 @@
 	document.getElementById('txtUrl').value = url ;
 	OnUrlChange() ;
-	window.parent.SetSelectedTab( 'Info' ) ;
+	dialog.SetSelectedTab( 'Info' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_listprop.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_listprop.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_listprop.html	(revision 1398)
@@ -30,5 +30,6 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
 
 // Gets the document DOM
@@ -36,5 +37,5 @@
 var sListType = ( location.search == '?OL' ? 'OL' : 'UL' ) ;
 
-var oActiveEl = oEditor.FCKSelection.MoveToAncestorNode( sListType ) ;
+var oActiveEl = dialog.Selection.GetSelection().MoveToAncestorNode( sListType ) ;
 var oActiveSel ;
 
@@ -64,6 +65,8 @@
 	}
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
+
+	SelectField( 'txtStartPosition' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_paste.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_paste.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_paste.html	(revision 1398)
@@ -139,4 +139,5 @@
 		var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
 		var oDoc = oEditor.FCK.EditorDocument ;
+		dialog.Selection.EnsureSelection() ;
 		range.MoveToSelection() ;
 		range.DeleteContents() ;
Index: /FCKeditor/trunk/editor/dialog/fck_radiobutton.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_radiobutton.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_radiobutton.html	(revision 1398)
@@ -30,10 +30,11 @@
 		<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
 
 // Gets the document DOM
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 window.onload = function()
@@ -51,6 +52,7 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
+	SelectField( 'txtName' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_replace.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_replace.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_replace.html	(revision 1398)
@@ -30,9 +30,12 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
+var dialogArguments = dialog.Args() ;
+
 var FCKLang = oEditor.FCKLang ;
 
-window.parent.AddTab( 'Find', FCKLang.DlgFindTitle ) ;
-window.parent.AddTab( 'Replace', FCKLang.DlgReplaceTitle ) ;
+dialog.AddTab( 'Find', FCKLang.DlgFindTitle ) ;
+dialog.AddTab( 'Replace', FCKLang.DlgReplaceTitle ) ;
 var idMap = {} ;
 
@@ -46,5 +49,32 @@
 
 	if ( tabCode == 'Replace' )
-		window.parent.SetAutoSize( true ) ;
+		dialog.SetAutoSize( true ) ;
+}
+
+// Place a range at the start of document.
+// This will be the starting point of our search.
+var GlobalRange = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
+GlobalRange.SetStart( oEditor.FCK.EditorDocument.body, 1 ) ;
+GlobalRange.SetEnd( oEditor.FCK.EditorDocument.body, 1 ) ;
+GlobalRange.Collapse( true ) ;
+
+var HighlightRange = null ;
+function Highlight()
+{
+	if ( HighlightRange )
+		ClearHighlight() ;
+	var cloneRange = GlobalRange.Clone() ;
+	oEditor.FCKStyles.GetStyle( '_FCK_SelectionHighlight' ).ApplyToRange( cloneRange, false, true ) ;
+	HighlightRange = cloneRange ;
+	GlobalRange = HighlightRange.Clone() ;
+}
+
+function ClearHighlight()
+{
+	if ( HighlightRange )
+	{
+		oEditor.FCKStyles.GetStyle( '_FCK_SelectionHighlight' ).RemoveFromRange( HighlightRange, false, true ) ;
+		HighlightRange = null ;
+	}
 }
 
@@ -54,21 +84,14 @@
 	oEditor.FCKLanguageManager.TranslatePage( document ) ;
 
-	// Place the cursor at the start of document.
-	// This will be the starting point of our search.
-	var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-	range.SetStart( oEditor.FCK.EditorDocument.body, 1 ) ;
-	range.SetEnd( oEditor.FCK.EditorDocument.body, 1 ) ;
-	range.Collapse( true ) ;
-	range.Select() ;
-
 	// Show the appropriate tab at startup.
-	if ( window.parent.name.search( 'Replace' ) == -1 )
-	{
-		window.parent.SetSelectedTab( 'Find' ) ;
-		window.parent.SetAutoSize( true ) ;
+	if ( dialogArguments.CustomValue == 'Find' )
+	{
+		dialog.SetSelectedTab( 'Find' ) ;
+		dialog.SetAutoSize( true ) ;
 	}
 	else
-		window.parent.SetSelectedTab( 'Replace' ) ;
-
+		dialog.SetSelectedTab( 'Replace' ) ;
+
+	SelectField( 'txtFind' + dialogArguments.CustomValue ) ;
 }
 
@@ -79,11 +102,4 @@
 			document.getElementById('btnFind').disabled =
 				( document.getElementById(idMap["FindText"]).value.length == 0 ) ;
-}
-
-function GetSelection()
-{
-	var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-	range.MoveToSelection() ;
-	return range.CreateBookmark2() ;
 }
 
@@ -262,5 +278,5 @@
 	// Start from the end of the current selection.
 	var matcher = new KmpMatch( GetSearchString(), ! GetCheckCase() ) ;
-	var cursor = GetSelection().End ;
+	var cursor = GlobalRange.CreateBookmark2().End ;
 	var matchState = KMP_NOMATCH ;
 	var matchBookmark = null ;
@@ -342,11 +358,10 @@
 	}
 
-	// If we've found a match, select the match.
+	// If we've found a match, highlight the match.
 	if ( matchState == KMP_MATCHED )
 	{
-		var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-		range.MoveToBookmark2( matchBookmark ) ;
-		range.Select() ;
-		var focus = range._Range.endContainer ;
+		GlobalRange.MoveToBookmark2( matchBookmark ) ;
+		Highlight() ;
+		var focus = GlobalRange._Range.endContainer ;
 		while ( focus && focus.nodeType != 1 )
 			focus = focus.parentNode ;
@@ -368,30 +383,27 @@
 function Find()
 {
-	var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-	range.MoveToSelection() ;
-	range.Collapse( false ) ;
-	range.Select() ;
-
 	if ( ! _Find() )
+	{
+		ClearHighlight() ;
 		alert( FCKLang.DlgFindNotFoundMsg ) ;
+	}
 }
 
 function Replace()
 {
-	var selection = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-	selection.MoveToSelection() ;
-
-	if ( selection.CheckIsCollapsed() )
+	if ( GlobalRange.CheckIsCollapsed() )
 	{
 		if (! _Find() )
+		{
+			ClearHighlight() ;
 			alert( FCKLang.DlgFindNotFoundMsg ) ;
+		}
 	}
 	else
 	{
 		oEditor.FCKUndo.SaveUndoStep() ;
-		selection.DeleteContents() ;
-		selection.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
-		selection.Collapse( false ) ;
-		selection.Select() ;
+		GlobalRange.DeleteContents() ;
+		GlobalRange.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
+		GlobalRange.Collapse( false ) ;
 	}
 }
@@ -400,21 +412,23 @@
 {
 	oEditor.FCKUndo.SaveUndoStep() ;
-	var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-
 	var replaceCount = 0 ;
 
 	while ( _Find() )
 	{
-		range.MoveToSelection() ;
-		range.DeleteContents() ;
-		range.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
-		range.Collapse( false ) ;
-		range.Select() ;
+		dialog.Selection.EnsureSelection() ;
+		GlobalRange.DeleteContents() ;
+		GlobalRange.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
+		GlobalRange.Collapse( false ) ;
 		replaceCount++ ;
 	}
 	if ( replaceCount == 0 )
+	{
+		ClearHighlight() ;
 		alert( FCKLang.DlgFindNotFoundMsg ) ;
-	window.parent.Cancel() ;
-}
+	}
+	dialog.Cancel() ;
+}
+
+window.onunload = function(){ ClearHighlight() ; }
 	</script>
 </head>
Index: /FCKeditor/trunk/editor/dialog/fck_select.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_select.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_select.html	(revision 1398)
@@ -31,10 +31,11 @@
 		<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
 
 // Gets the document DOM
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 var oListText ;
@@ -69,6 +70,7 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
+	SelectField( 'txtName' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_smiley.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_smiley.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_smiley.html	(revision 1398)
@@ -37,5 +37,6 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
 
 window.onload = function ()
@@ -44,10 +45,13 @@
 	oEditor.FCKLanguageManager.TranslatePage(document) ;
 
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
 function InsertSmiley( url )
 {
+	dialog.Selection.EnsureSelection() ;
+
 	oEditor.FCKUndo.SaveUndoStep() ;
+
 	var oImg = oEditor.FCK.InsertElement( 'img' ) ;
 	oImg.src = url ;
@@ -59,5 +63,5 @@
 	document.body.innerHTML = '' ;
 
-	window.parent.Cancel() ;
+	dialog.Cancel() ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_specialchar.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_specialchar.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_specialchar.html	(revision 1398)
@@ -44,4 +44,5 @@
 {
 	oEditor.FCKUndo.SaveUndoStep() ;
+	parent.Selection.EnsureSelection() ;
 	oEditor.FCK.InsertHtml( charValue || "" ) ;
 	window.parent.Cancel() ;
Index: /FCKeditor/trunk/editor/dialog/fck_table.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_table.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_table.html	(revision 1398)
@@ -30,5 +30,7 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
+var dialogArguments = dialog.Args() ;
 
 // Gets the document DOM
@@ -37,5 +39,5 @@
 // Gets the table if there is one selected.
 var table ;
-var e = oEditor.FCKSelection.GetSelectedElement() ;
+var e = dialog.Selection.GetSelectedElement() ;
 
 if ( ( !e && document.location.search.substr(1) == 'Parent' ) || ( e && e.tagName != 'TABLE' ) )
@@ -89,8 +91,11 @@
 		document.getElementById('txtRows').disabled    = true ;
 		document.getElementById('txtColumns').disabled = true ;
-	}
-
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+		SelectField( 'txtWidth' ) ;
+	}
+	else
+		SelectField( 'txtRows' ) ;
+
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_tablecell.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_tablecell.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_tablecell.html	(revision 1398)
@@ -30,5 +30,6 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
 
 // Gets the document DOM
@@ -36,4 +37,5 @@
 
 // Array of selected Cells
+dialog.Selection.EnsureSelection() ;
 var aCells = oEditor.FCKTableHandler.GetSelectedCells() ;
 
@@ -45,6 +47,7 @@
 	SetStartupValue() ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
+	SelectField( 'txtWidth' ) ;
 }
 
@@ -119,5 +122,5 @@
 function SelectColor( wich )
 {
-	oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', oEditor.FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, wich == 'Back' ? SelectBackColor : SelectBorderColor, window ) ;
+	oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', oEditor.FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, wich == 'Back' ? SelectBackColor : SelectBorderColor, window ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_textarea.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_textarea.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_textarea.html	(revision 1398)
@@ -30,10 +30,11 @@
 		<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
 
 // Gets the document DOM
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 window.onload = function()
@@ -51,6 +52,7 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
+	SelectField( 'txtName' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dialog/fck_textfield.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_textfield.html	(revision 1397)
+++ /FCKeditor/trunk/editor/dialog/fck_textfield.html	(revision 1398)
@@ -30,10 +30,11 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
 
 // Gets the document DOM
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 window.onload = function()
@@ -55,6 +56,7 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
+	SelectField( 'txtName' ) ;
 }
 
Index: /FCKeditor/trunk/editor/dtd/fck_xhtml10strict.js
===================================================================
--- /FCKeditor/trunk/editor/dtd/fck_xhtml10strict.js	(revision 1397)
+++ /FCKeditor/trunk/editor/dtd/fck_xhtml10strict.js	(revision 1398)
@@ -1,3 +1,3 @@
-/*
+﻿/*
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  * Copyright (C) 2003-2007 Frederico Caldeira Knabben
Index: /FCKeditor/trunk/editor/dtd/fck_xhtml10transitional.js
===================================================================
--- /FCKeditor/trunk/editor/dtd/fck_xhtml10transitional.js	(revision 1397)
+++ /FCKeditor/trunk/editor/dtd/fck_xhtml10transitional.js	(revision 1398)
@@ -1,3 +1,3 @@
-/*
+﻿/*
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  * Copyright (C) 2003-2007 Frederico Caldeira Knabben
Index: /FCKeditor/trunk/editor/fckdialog.html
===================================================================
--- /FCKeditor/trunk/editor/fckdialog.html	(revision 1397)
+++ /FCKeditor/trunk/editor/fckdialog.html	(revision 1398)
@@ -1,3 +1,3 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+﻿<!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
@@ -24,11 +24,24 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 	<head>
+		<title></title>
 		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 		<meta name="robots" content="noindex, nofollow" />
 		<script type="text/javascript">
 
-var args = window.dialogArguments ;
-
-// Automatically detect the correct document.domain (#123).
+var E = frameElement._DialogArguments.Editor ;
+
+// It seems referencing to frameElement._DialogArguments directly would lead to memory leaks in IE.
+// So let's use functions to access its members instead.
+function Args()
+{
+	return frameElement._DialogArguments ;
+}
+
+function ParentDialog( dialog )
+{
+	return dialog ? dialog._ParentDialog : frameElement._ParentDialog ;
+}
+
+// Domain relaxation logic.
 (function()
 {
@@ -40,12 +53,13 @@
 		try
 		{
-			var parentDomain = window.opener ? window.opener.document.domain : args.Editor.document.domain ;
-			
+			var parentDomain = ( Args().TopWindow || E ).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( /.*?(?:\.|$)/, '' ) ;
@@ -53,322 +67,716 @@
 		if ( d.length == 0 )
 			break ;		// It was not able to detect the domain.
-		
+
 		document.domain = d ;
 	}
-})() ; 
-
-// On some Gecko browsers (probably over slow connections) the
-// "dialogArguments" are not set so we must get it from the opener window.
-if ( !args )
-	args = window.dialogArguments = window.opener.FCKLastDialogInfo ;
+})() ;
+
+var FCK				= E.FCK ;
+var FCKTools		= E.FCKTools ;
+var FCKDomTools		= E.FCKDomTools ;
+var FCKDialog		= E.FCKDialog ;
+var FCKBrowserInfo	= E.FCKBrowserInfo ;
+var FCKConfig		= E.FCKConfig ;
+
+// Steal the focus so that the caret would no longer stay in the editor iframe.
+window.focus() ;
 
 // Sets the Skin CSS
-document.write( '<link href="' + args.Editor.FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
+document.write( '<link href="' + FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
 
 // Sets the language direction.
-window.document.dir = args.Editor.FCKLang.Dir ;
-
-// IE does not set the window name in showModalDialog(), let's set it here.
-if ( args.Editor.FCKBrowserInfo.IsIE )
-	window.name = args.DialogName ;
-
-var sTitle = args.Title ;
-document.write( '<title>' + sTitle + '<\/title>' ) ;
-
-function LoadInnerDialog()
-{
-	if ( window.onresize )
-		window.onresize() ;
-
-	// First of all, translate the dialog box contents.
-	args.Editor.FCKLanguageManager.TranslatePage( document ) ;
-
-	document.getElementById( 'FrameCell' ).innerHTML = '<iframe id="frmMain" src="' + args.Page + '" name="frmMain" frameborder="0" height="100%" width="100%" scrolling="auto"></iframe>' ;
-}
-
-function InnerDialogLoaded()
-{
-	var oInnerDoc = document.getElementById('frmMain').contentWindow.document ;
-
-	// Set the language direction.
-	oInnerDoc.dir = args.Editor.FCKLang.Dir ;
-
-	// Sets the Skin CSS.
-	oInnerDoc.write( '<link href="' + args.Editor.FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
-
-	SetOnKeyDown( oInnerDoc ) ;
-	DisableContextMenu( oInnerDoc ) ;
-
-	return args.Editor ;
-}
-
-function SetOkButton( showIt )
-{
-	document.getElementById('btnOk').style.visibility = ( showIt ? '' : 'hidden' ) ;
-}
-
-var bAutoSize = false ;
-
-function SetAutoSize( autoSize )
-{
-	bAutoSize = autoSize ;
-	RefreshSize() ;
-}
-
-function RefreshSize()
-{
-	if ( bAutoSize )
-	{
-		var oInnerDoc = document.getElementById('frmMain').contentWindow.document ;
-
-		var iFrameHeight ;
-		if ( document.all )
-			iFrameHeight = oInnerDoc.body.offsetHeight ;
+var langDir = window.document.dir = E.FCKLang.Dir ;
+
+// For IE6-, the fck_dialog_ie6.js is loaded, used to fix limitations in the browser.
+if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
+	document.write( '<' + 'script type="text/javascript" src="' + FCKConfig.SkinPath + 'fck_dialog_ie6.js"><' + '\/script>' ) ;
+
+FCKTools.RegisterDollarFunction( window ) ;
+
+// Resize related functions.
+var Sizer = function()
+{
+	var bAutoSize = false ;
+
+	var retval = {
+		// Sets whether the dialog should auto-resize according to its content's height.
+		SetAutoSize : function( autoSize )
+		{
+			bAutoSize = autoSize ;
+			this.RefreshSize() ;
+		},
+
+		// Fit the dialog container's layout to the inner iframe's external size.
+		RefreshContainerSize : function()
+		{
+			var frmMain = $( 'frmMain' ) ;
+
+			if ( frmMain )
+			{
+				// Get the container size.
+				var height = $( 'contents' ).offsetHeight ;
+
+				// Subtract the size of other elements.
+				height -= $( 'TitleArea' ).offsetHeight ;
+				height -= $( 'TabsRow' ).offsetHeight ;
+				height -= $( 'DialogButtons' ).offsetHeight ;
+
+				frmMain.style.height = Math.max( height, 0 ) + 'px' ;
+			}
+		},
+
+		// Resize and re-layout the dialog.
+		// Triggers the onresize event for the layout logic.
+		ResizeDialog : function( width, height )
+		{
+			FCKDomTools.SetElementStyles( window.frameElement,
+					{
+						'width' : width + 'px',
+						'height' : height + 'px'
+					} ) ;
+
+			// If the skin have defined a function for resize fixes, call it now.
+			if ( typeof window.DoResizeFixes == 'function' )
+				window.DoResizeFixes() ;
+		},
+
+		// if bAutoSize is true, automatically fit the dialog size and layout to
+		// accomodate the inner iframe's internal height.
+		// if bAutoSize is false, then only the layout logic for the dialog decorations
+		// is run to accomodate the inner iframe's external height.
+		RefreshSize : function()
+		{
+			if ( bAutoSize )
+			{
+				var frmMain		= $( 'frmMain' ) ;
+				var innerDoc	= frmMain.contentWindow.document ;
+				var isStrict	= FCKTools.IsStrictMode( innerDoc ) ;
+
+				// Get the size of the frame contents.
+				var innerWidth	= isStrict ? innerDoc.documentElement.scrollWidth : innerDoc.body.scrollWidth ;
+				var innerHeight	= isStrict ? innerDoc.documentElement.scrollHeight : innerDoc.body.scrollHeight ;
+
+				// Get the current frame size.
+				var frameSize = FCKTools.GetViewPaneSize( frmMain.contentWindow ) ;
+
+				var deltaWidth	= innerWidth - frameSize.Width ;
+				var deltaHeight	= innerHeight - frameSize.Height ;
+
+				// If the contents fits the current size.
+				if ( deltaWidth <= 0 && deltaHeight <= 0 )
+					return ;
+
+				var dialogWidth		= frameElement.offsetWidth + Math.max( deltaWidth, 0 ) ;
+				var dialogHeight	= frameElement.offsetHeight + Math.max( deltaHeight, 0 ) ;
+
+				this.ResizeDialog( dialogWidth, dialogHeight ) ;
+			}
+			this.RefreshContainerSize() ;
+		}
+	}
+
+	/**
+	 * Safari seems to have a bug with the time when RefreshSize() is executed - it
+	 * thinks frmMain's innerHeight is 0 if we query the value too soon after the
+	 * page is loaded in some circumstances. (#1316)
+	 * TODO : Maybe this is not needed anymore after #35.
+	 */
+	if ( FCKBrowserInfo.IsSafari )
+	{
+		var originalRefreshSize = retval.RefreshSize ;
+
+		retval.RefreshSize = function()
+		{
+			window.setTimeout( originalRefreshSize, 1 ) ;
+		}
+	}
+
+	window.onresize = function()
+	{
+		retval.RefreshContainerSize() ;
+	}
+
+	window.SetAutoSize = FCKTools.Bind( retval, retval.SetAutoSize ) ;
+
+	return retval ;
+}() ;
+
+// Manages the throbber image that appears if the inner part of dialog is taking too long to load.
+var Throbber = function()
+{
+	var timer ;
+
+	var updateThrobber = function()
+	{
+		var throbberParent = $( 'throbberBlock' ) ;
+		var throbberBlocks = throbberParent.childNodes ;
+		var lastClass = throbberParent.lastChild.className ;
+
+		// From the last to the second one, copy the class from the previous one.
+		for ( var i = throbberBlocks.length - 1 ; i > 0 ; i-- )
+			throbberBlocks[i].className = throbberBlocks[i-1].className ;
+
+		// For the first one, copy the last class (rotation).
+		throbberBlocks[0].className = lastClass ;
+	}
+
+	return {
+		Show : function( waitMilliseconds )
+		{
+			// Auto-setup the Show function to be called again after the
+			// requested amount of time.
+			if ( waitMilliseconds && waitMilliseconds > 0 )
+			{
+				timer = FCKTools.SetTimeout( this.Show, waitMilliseconds, this, null, window ) ;
+				return ;
+			}
+
+			var throbberParent = $( 'throbberBlock' ) ;
+
+			// Create the throbber blocks.
+			var classIds = [ 1,2,3,4,5,4,3,2 ] ;
+			while ( classIds.length > 0 )
+				throbberParent.appendChild( document.createElement( 'div' ) ).className = ' throbber_' + classIds.shift() ;
+
+			// Center the throbber.
+			var frm = $( 'contents' ) ;
+			var frmCoords = FCKTools.GetDocumentPosition( window, frm ) ;
+			var x = frmCoords.x + ( frm.offsetWidth - throbberParent.offsetWidth ) / 2 ;
+			var y = frmCoords.y + ( frm.offsetHeight - throbberParent.offsetHeight ) / 2 ;
+			throbberParent.style.left = parseInt( x, 10 ) + 'px' ;
+			throbberParent.style.top = parseInt( y, 10 ) + 'px' ;
+
+			// Show it.
+			throbberParent.style.visibility = ''  ;
+
+			// Setup the animation interval.
+			timer = setInterval( updateThrobber, 100 ) ;
+		},
+
+		Hide : function()
+		{
+			if ( timer )
+			{
+				clearInterval( timer ) ;
+				timer = null ;
+			}
+
+			var throbberParent = document.getElementById( 'throbberBlock' ) ;
+			if ( throbberParent )
+				FCKDomTools.RemoveNode( throbberParent ) ;
+		}
+	} ;
+}() ;
+
+// Drag and drop handlers.
+var DragAndDrop = function()
+{
+	var registeredWindows = [] ;
+	var lastCoords ;
+	var currentPos ;
+
+	var cleanUpHandlers = function()
+	{
+		for ( var i = 0 ; i < registeredWindows.length ; i++ )
+		{
+			FCKTools.RemoveEventListener( registeredWindows[i].document, 'mousemove', dragMouseMoveHandler ) ;
+			FCKTools.RemoveEventListener( registeredWindows[i].document, 'mouseup', dragMouseUpHandler ) ;
+		}
+	}
+
+	var dragMouseMoveHandler = function( evt )
+	{
+		if ( !lastCoords )
+			return ;
+
+		if ( !evt )
+			evt = FCKTools.GetElementDocument( this ).parentWindow.event ;
+
+		// Updated the last coordinates.
+		var currentCoords =
+		{
+			x : evt.screenX,
+			y : evt.screenY
+		} ;
+
+		currentPos =
+		{
+			x : currentPos.x + ( currentCoords.x - lastCoords.x ),
+			y : currentPos.y + ( currentCoords.y - lastCoords.y )
+		} ;
+
+		lastCoords = currentCoords ;
+
+		frameElement.style.left	= currentPos.x + 'px' ;
+		frameElement.style.top	= currentPos.y + 'px' ;
+
+		if ( evt.preventDefault )
+			evt.preventDefault() ;
 		else
-			iFrameHeight = document.getElementById('frmMain').contentWindow.innerHeight ;
-
-		var iInnerHeight = oInnerDoc.body.scrollHeight ;
-
-		var iDiff = iInnerHeight - iFrameHeight ;
-
-		if ( iDiff > 0 )
-		{
-			if ( document.all )
-				window.dialogHeight = ( parseInt( window.dialogHeight, 10 ) + iDiff ) + 'px' ;
+			evt.returnValue = false ;
+	}
+
+	var dragMouseUpHandler = function( evt )
+	{
+		if ( !lastCoords )
+			return ;
+		if ( !evt )
+			evt = FCKTools.GetElementDocument( this ).parentWindow.event ;
+		cleanUpHandlers() ;
+		lastCoords = null ;
+	}
+
+	return {
+
+		MouseDownHandler : function( evt )
+		{
+			var view = null ;
+			if ( !evt )
+			{
+				view = FCKTools.GetElementDocument( this ).parentWindow ;
+				evt = view.event ;
+			}
 			else
-				window.resizeBy( 0, iDiff ) ;
-		}
-	}
-}
-
-// Kludge for #1316: Safari seems to have a bug with the time when RefreshSize() is executed - it thinks frmMain's innerHeight 
-// is 0 if we query the value too soon after the page is loaded in some circumstances.
-if ( args.Editor.FCKBrowserInfo.IsSafari )
-{
-	window.OriginalRefreshSize = RefreshSize ;
-
-	RefreshSize = function()
-	{
-		window.setTimeout( window.OriginalRefreshSize, 1 );
-	}
-}
-
-function Ok()
-{
-	if ( window.frames["frmMain"].Ok && window.frames["frmMain"].Ok() )
-		Cancel() ;
-}
-
-function Cancel( dontFireChange )
-{
-	if ( !dontFireChange && !args.Editor.FCK.EditMode )
-	{
-		// All dialog windows, by default, will fire the "OnSelectionChange"
-		// event, no matter the Ok or Cancel button has been pressed.
-		args.Editor.FCK.Events.FireEvent( 'OnSelectionChange' ) ;
-	}
-	window.close() ;
-}
-
-// Object that holds all available tabs.
-var oTabs = new Object() ;
-
-function TabDiv_OnClick()
-{
-	SetSelectedTab( this.TabCode ) ;
-}
-
-function AddTab( tabCode, tabText, startHidden )
-{
-	if ( typeof( oTabs[ tabCode ] ) != 'undefined' )
+				view = evt.view ;
+
+			var target = evt.srcElement || evt.target ;
+			if ( target.id == 'closeButton' || target.className == 'DialogTab' || target.className == 'DialogTabSelected' )
+				return ;
+
+			lastCoords =
+			{
+				x : evt.screenX,
+				y : evt.screenY
+			} ;
+
+			// Save the current IFRAME position.
+			currentPos =
+			{
+				x : parseInt( FCKDomTools.GetCurrentElementStyle( frameElement, 'left' ), 10 ),
+				y : parseInt( FCKDomTools.GetCurrentElementStyle( frameElement, 'top' ), 10 )
+			} ;
+
+			for ( var i = 0 ; i < registeredWindows.length ; i++ )
+			{
+				FCKTools.AddEventListener( registeredWindows[i].document, 'mousemove', dragMouseMoveHandler ) ;
+				FCKTools.AddEventListener( registeredWindows[i].document, 'mouseup', dragMouseUpHandler ) ;
+			}
+
+			if ( evt.preventDefault )
+				evt.preventDefault() ;
+			else
+				evt.returnValue = false ;
+		},
+
+		RegisterHandlers : function( w )
+		{
+			registeredWindows.push( w ) ;
+		}
+	}
+}() ;
+
+// Selection related functions.
+var Selection = function()
+{
+	return {
+		/**
+		 * Ensures that the editing area contains an active selection. This is a
+		 * requirement for IE, as it looses the selection when the focus moves to other
+		 * frames.
+		 */
+		EnsureSelection : function()
+		{
+			if ( FCKDialog.SelectionData )
+				FCKDialog.SelectionData.select() ;
+		},
+
+		/**
+		 * Get the FCKSelection object for the editor instance.
+		 */
+		GetSelection : function()
+		{
+			this.EnsureSelection() ;
+			return FCK.Selection ;
+		},
+
+		/**
+		 * Get the selected element in the editing area (for object selections).
+		 */
+		GetSelectedElement : function()
+		{
+			return this.GetSelection().GetSelectedElement() ;
+		}
+	} ;
+}() ;
+
+// Tab related functions.
+var Tabs = function()
+{
+	// Only element ids should be stored here instead of element references since setSelectedTab and TabDiv_OnClick
+	// would build circular references with the element references inside and cause memory leaks in IE6.
+	var oTabs = new Object() ;
+
+	var setSelectedTab = function( tabCode )
+	{
+		for ( var sCode in oTabs )
+		{
+			if ( sCode == tabCode )
+				$( oTabs[sCode] ).className = 'DialogTabSelected' ;
+			else
+				$( oTabs[sCode] ).className = 'DialogTab' ;
+		}
+
+		if ( typeof( window.frames["frmMain"].OnDialogTabChange ) == 'function' )
+			window.frames["frmMain"].OnDialogTabChange( tabCode ) ;
+	}
+
+	function TabDiv_OnClick()
+	{
+		setSelectedTab( this.TabCode ) ;
+	}
+
+	window.AddTab = function( tabCode, tabText, startHidden )
+	{
+		if ( typeof( oTabs[ tabCode ] ) != 'undefined' )
+			return ;
+
+		var eTabsRow = $( 'Tabs' ) ;
+
+		var oCell = eTabsRow.insertCell(  eTabsRow.cells.length - 1 ) ;
+		oCell.noWrap = true ;
+
+		var oDiv = document.createElement( 'DIV' ) ;
+		oDiv.className = 'DialogTab' ;
+		oDiv.innerHTML = tabText ;
+		oDiv.TabCode = tabCode ;
+		oDiv.onclick = TabDiv_OnClick ;
+		oDiv.id = Math.random() ;
+
+		if ( startHidden )
+			oDiv.style.display = 'none' ;
+
+		eTabsRow = $( 'TabsRow' ) ;
+
+		oCell.appendChild( oDiv ) ;
+
+		if ( eTabsRow.style.display == 'none' )
+		{
+			var eTitleArea = $( 'TitleArea' ) ;
+			eTitleArea.className = 'DialogTitle' ;
+
+			oDiv.className = 'DialogTabSelected' ;
+			eTabsRow.style.display = '' ;
+
+			if ( window.onresize )
+				window.onresize() ;
+		}
+
+		oTabs[ tabCode ] = oDiv.id ;
+
+		FCKTools.DisableSelection( oDiv ) ;
+	} ;
+
+	window.SetSelectedTab = setSelectedTab ;
+
+	window.SetTabVisibility = function( tabCode, isVisible )
+	{
+		var oTab = $( oTabs[ tabCode ] ) ;
+		oTab.style.display = isVisible ? '' : 'none' ;
+
+		if ( ! isVisible && oTab.className == 'DialogTabSelected' )
+		{
+			for ( var sCode in oTabs )
+			{
+				if ( $( oTabs[sCode] ).style.display != 'none' )
+				{
+					setSelectedTab( sCode ) ;
+					break ;
+				}
+			}
+		}
+	} ;
+}() ;
+
+// readystatechange handler for registering drag and drop handlers in cover
+// iframes, defined out here to avoid memory leak.
+// Do NOT put this function as a private function as it will induce memory leak
+// in IE and it's not detectable with Drip or sIEve and undetectable leaks are
+// really nasty (sigh).
+var onReadyRegister = function()
+{
+	if ( this.readyState != 'complete' )
 		return ;
-
-	var eTabsRow = document.getElementById( 'Tabs' ) ;
-
-	var oCell = eTabsRow.insertCell(  eTabsRow.cells.length - 1 ) ;
-	oCell.noWrap = true ;
-
-	var oDiv = document.createElement( 'DIV' ) ;
-	oDiv.className = 'PopupTab' ;
-	oDiv.innerHTML = tabText ;
-	oDiv.TabCode = tabCode ;
-	oDiv.onclick = TabDiv_OnClick ;
-
-	if ( startHidden )
-		oDiv.style.display = 'none' ;
-
-	eTabsRow = document.getElementById( 'TabsRow' ) ;
-
-	oCell.appendChild( oDiv ) ;
-
-	if ( eTabsRow.style.display == 'none' )
-	{
-		var eTitleArea = document.getElementById( 'TitleArea' ) ;
-		eTitleArea.className = 'PopupTitle' ;
-
-		oDiv.className = 'PopupTabSelected' ;
-		eTabsRow.style.display = '' ;
-
-		if ( window.onresize )
-			window.onresize() ;
-	}
-
-	oTabs[ tabCode ] = oDiv ;
-}
-
-function SetSelectedTab( tabCode )
-{
-	for ( var sCode in oTabs )
-	{
-		if ( sCode == tabCode )
-			oTabs[sCode].className = 'PopupTabSelected' ;
-		else
-			oTabs[sCode].className = 'PopupTab' ;
-	}
-
-	if ( typeof( window.frames["frmMain"].OnDialogTabChange ) == 'function' )
-		window.frames["frmMain"].OnDialogTabChange( tabCode ) ;
-}
-
-function SetTabVisibility( tabCode, isVisible )
-{
-	var oTab = oTabs[ tabCode ] ;
-	oTab.style.display = isVisible ? '' : 'none' ;
-
-	if ( ! isVisible && oTab.className == 'PopupTabSelected' )
-	{
-		for ( var sCode in oTabs )
-		{
-			if ( oTabs[sCode].style.display != 'none' )
-			{
-				SetSelectedTab( sCode ) ;
-				break ;
-			}
-		}
-	}
-}
-
-function SetOnKeyDown( targetDocument )
-{
-	targetDocument.onkeydown = function ( e )
-	{
-		e = e || event || this.parentWindow.event ;
-		switch ( e.keyCode )
-		{
-			case 13 :		// ENTER
-				var oTarget = e.srcElement || e.target ;
-				if ( oTarget.tagName == 'TEXTAREA' )
-					return true ;
-				Ok() ;
-				return false ;
-			case 27 :		// ESC
-				Cancel() ;
-				return false ;
-				break ;
-		}
-		return true ;
-	}
-}
-SetOnKeyDown( document ) ;
-
-function DisableContextMenu( targetDocument )
-{
-	if ( args.Editor.FCKBrowserInfo.IsIE ) return ;
-
-	// Disable Right-Click
-	var oOnContextMenu = function( e )
+	DragAndDrop.RegisterHandlers( this.contentWindow ) ;
+} ;
+
+// The business logic of the dialog, dealing with operational things like
+// dialog open/dialog close/enable/disable/etc.
+(function()
+{
+	var setOnKeyDown = function( targetDocument )
+	{
+		targetDocument.onkeydown = function ( e )
+		{
+			e = e || event || this.parentWindow.event ;
+			switch ( e.keyCode )
+			{
+				case 13 :		// ENTER
+					var oTarget = e.srcElement || e.target ;
+					if ( oTarget.tagName == 'TEXTAREA' )
+						return true ;
+					Ok() ;
+					return false ;
+
+				case 27 :		// ESC
+					Cancel() ;
+					return false ;
+			}
+			return true ;
+		}
+	} ;
+
+	var contextMenuBlocker = function( e )
 	{
 		var sTagName = e.target.tagName ;
 		if ( ! ( ( sTagName == "INPUT" && e.target.type == "text" ) || sTagName == "TEXTAREA" ) )
 			e.preventDefault() ;
-	}
-	targetDocument.addEventListener( 'contextmenu', oOnContextMenu, true ) ;
-}
-DisableContextMenu( document ) ;
-
-if ( args.Editor.FCKBrowserInfo.IsGecko && !args.Editor.FCKBrowserInfo.IsOpera )
-{
-	window.onresize = function( e )
-	{
-		// Running in Chrome makes the window receive the event including subframes.
-		// we care only about this window. Ticket #1642
-		if ( e && e.originalTarget !== document )
-				return ;
-
-		var oFrame = document.getElementById("frmMain") ;
-
-		if ( ! oFrame )
+	} ;
+
+	var disableContextMenu = function( targetDocument )
+	{
+		if ( FCKBrowserInfo.IsIE )
 			return ;
 
-		oFrame.height = 0 ;
-
-		var oCell = document.getElementById("FrameCell") ;
-		var iHeight = oCell.offsetHeight ;
-
-		oFrame.height = iHeight - 2 ;
-	}
-}
-
-if ( args.Editor.FCKBrowserInfo.IsIE )
-{
-	function Window_OnBeforeUnload()
-	{
-		for ( var t in oTabs )
-			oTabs[t] = null ;
-
-		args.Editor = null ;
-	}
-	window.attachEvent( "onbeforeunload", Window_OnBeforeUnload ) ;
-}
-
-function Window_OnClose()
-{
-	args.Editor.FCKFocusManager.Unlock() ;
-}
-
-if ( window.addEventListener )
-	window.addEventListener( 'unload', Window_OnClose, false ) ;
-
+		targetDocument.addEventListener( 'contextmenu', contextMenuBlocker, true ) ;
+	} ;
+
+	// Program entry point.
+	window.Init = function()
+	{
+		// Start the throbber timer.
+		Throbber.Show( 1000 ) ;
+
+		Sizer.RefreshContainerSize() ;
+		LoadInnerDialog() ;
+
+		FCKTools.DisableSelection( document.body ) ;
+
+		// Make the title area draggable.
+		var titleElement = $( 'header' ) ;
+		titleElement.onmousedown = DragAndDrop.MouseDownHandler ;
+
+		// Connect mousemove and mouseup events from dialog frame and outer window to dialog dragging logic.
+		DragAndDrop.RegisterHandlers( window ) ;
+		DragAndDrop.RegisterHandlers( Args().TopWindow ) ;
+
+		// Disable the previous dialog if it exists.
+		if ( ParentDialog() )
+		{
+			ParentDialog().contentWindow.SetEnabled( false ) ;
+			if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
+			{
+				var currentParent = ParentDialog() ;
+				while ( currentParent )
+				{
+					var blockerFrame = currentParent.contentWindow.$( 'blocker' ) ;
+					if ( blockerFrame.readyState == 'complete' )
+						DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;
+					else
+						blockerFrame.onreadystatechange = onReadyRegister ;
+					currentParent = ParentDialog( currentParent ) ;
+				}
+			}
+			else
+			{
+				var currentParent = ParentDialog() ;
+				while ( currentParent )
+				{
+					DragAndDrop.RegisterHandlers( currentParent.contentWindow ) ;
+					currentParent = ParentDialog( currentParent ) ;
+				}
+			}
+		}
+
+		// If this is the only dialog on screen, enable the background cover.
+		if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
+		{
+			var blockerFrame = FCKDialog.GetCover().firstChild ;
+			if ( blockerFrame.readyState == 'complete' )
+				DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;
+			else
+				blockerFrame.onreadystatechange = onReadyRegister;
+		}
+
+		// Add Enter/Esc hotkeys and disable context menu for the dialog.
+		setOnKeyDown( document ) ;
+		disableContextMenu( document ) ;
+	} ;
+
+	window.LoadInnerDialog = function()
+	{
+		if ( window.onresize )
+			window.onresize() ;
+
+		// First of all, translate the dialog box contents.
+		E.FCKLanguageManager.TranslatePage( document ) ;
+
+		// Create the IFRAME that holds the dialog contents.
+		$( 'innerContents' ).innerHTML = '<iframe id="frmMain" src="' + Args().Page + '" name="frmMain" frameborder="0" width="100%" height="100%" scrolling="auto" style="visibility: hidden;" allowtransparency="true"></iframe>' ;
+	} ;
+
+	window.InnerDialogLoaded = function()
+	{
+		// If the dialog has been closed before the iframe is loaded, do nothing.
+		if ( !frameElement.parentNode )
+			return null ;
+
+		Throbber.Hide() ;
+
+		var frmMain = $('frmMain') ;
+		var innerWindow = frmMain.contentWindow ;
+		var innerDoc = innerWindow.document ;
+
+		// Show the loaded iframe.
+		frmMain.style.visibility = '' ;
+
+		// Set the language direction.
+		innerDoc.dir = langDir ;
+
+		// Sets the Skin CSS.
+		innerDoc.write( '<link href="' + FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
+
+		setOnKeyDown( innerDoc ) ;
+		disableContextMenu( innerDoc ) ;
+
+		Sizer.RefreshContainerSize();
+
+		DragAndDrop.RegisterHandlers( innerWindow ) ;
+
+		innerWindow.focus() ;
+
+		return E ;
+	} ;
+
+	window.SetOkButton = function( showIt )
+	{
+		$('btnOk').style.visibility = ( showIt ? '' : 'hidden' ) ;
+	} ;
+
+	window.Ok = function()
+	{
+		Selection.EnsureSelection() ;
+
+		var frmMain = window.frames["frmMain"] ;
+
+		if ( frmMain.Ok && frmMain.Ok() )
+			CloseDialog() ;
+		else
+			frmMain.focus() ;
+	} ;
+
+	window.Cancel = function( dontFireChange )
+	{
+		return CloseDialog( dontFireChange ) ;
+	} ;
+
+	window.CloseDialog = function( dontFireChange )
+	{
+		Throbber.Hide() ;
+
+		Selection.EnsureSelection() ;
+
+		// Points the src to a non-existent location to avoid loading errors later, in case the dialog
+		// haven't been completed loaded at this point.
+		if ( $( 'frmMain' ) )
+			$( 'frmMain' ).src = FCKTools.GetVoidUrl() ;
+
+		if ( !dontFireChange && !FCK.EditMode )
+		{
+			// All dialog windows, by default, will fire the "OnSelectionChange"
+			// event, no matter the Ok or Cancel button has been pressed.
+			FCK.Events.FireEvent( 'OnSelectionChange' ) ;
+		}
+
+		FCKDialog.OnDialogClose( window ) ;
+	} ;
+
+	window.SetEnabled = function( isEnabled )
+	{
+		var cover = $( 'cover' ) ;
+		cover.style.display = isEnabled ? 'none' : '' ;
+
+		if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
+		{
+			if ( !isEnabled )
+			{
+				// Inser the blocker IFRAME before the cover.
+				var blocker = document.createElement( 'iframe' ) ;
+				blocker.src = FCKTools.GetVoidUrl() ;
+				blocker.hideFocus = true ;
+				blocker.frameBorder = 0 ;
+				blocker.id = blocker.className = 'blocker' ;
+				cover.appendChild( blocker ) ;
+			}
+			else
+			{
+				var blocker = $( 'blocker' ) ;
+				if ( blocker && blocker.parentNode )
+					blocker.parentNode.removeChild( blocker ) ;
+			}
+		}
+	} ;
+})() ;
 		</script>
 	</head>
-	<body onload="LoadInnerDialog();" class="PopupBody">
-		<table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
-			<tr>
-				<td id="TitleArea" class="PopupTitle PopupTitleBorder">
+	<body onload="Init();" class="DialogBody">
+		<div class="contents" id="contents">
+			<div id="header">
+				<div id="TitleArea" class="DialogTitle DialogTitleBorder">
 					<script type="text/javascript">
-document.write( sTitle ) ;
+document.write( Args().Title ) ;
 					</script>
-				</td>
-			</tr>
-			<tr id="TabsRow" style="DISPLAY: none">
-				<td class="PopupTabArea">
+					<div id="closeButton" onclick="Cancel();"></div>
+				</div>
+				<div id="TabsRow" class="DialogTabArea" style="display: none">
 					<table border="0" cellpadding="0" cellspacing="0" width="100%">
-						<tr id="Tabs" onselectstart="return false;">
-							<td class="PopupTabEmptyArea">&nbsp;</td>
-							<td class="PopupTabEmptyArea" width="100%">&nbsp;</td>
+						<tr id="Tabs">
+							<td class="DialogTabEmptyArea">&nbsp;</td>
+							<td class="DialogTabEmptyArea" width="100%">&nbsp;</td>
 						</tr>
 					</table>
-				</td>
-			</tr>
-			<tr>
-				<td id="FrameCell" height="100%" valign="top">
-					&nbsp;
-				</td>
-			</tr>
-			<tr>
-				<td class="PopupButtons">
-					<table border="0" cellpadding="0" cellspacing="0">
-						<tr>
-							<td width="100%">&nbsp;</td>
-							<td nowrap="nowrap">
-								<input id="btnOk" style="VISIBILITY: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" />
-								&nbsp; 
-								<input id="btnCancel" type="button" value="Cancel" class="Button" onclick="Cancel();" fckLang="DlgBtnCancel" />
-							</td>
-						</tr>
-					</table>
-				</td>
-			</tr>
-		</table>
+				</div>
+			</div>
+			<div id="innerContents"></div>
+			<div id="DialogButtons" class="DialogButtons">
+				<table border="0" cellpadding="0" cellspacing="0">
+					<tr>
+						<td width="100%">&nbsp;</td>
+						<td nowrap="nowrap">
+							<input id="btnOk" style="visibility: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" />
+							&nbsp;
+							<input id="btnCancel" type="button" value="Cancel" class="Button" onclick="Cancel();" fckLang="DlgBtnCancel" />
+						</td>
+					</tr>
+				</table>
+			</div>
+		</div>
+		<div class="tl"></div>
+		<div class="tc"></div>
+		<div class="tr"></div>
+		<div class="ml"></div>
+		<div class="mr"></div>
+		<div class="bl"></div>
+		<div class="bc"></div>
+		<div class="br"></div>
+		<div class="cover" id="cover" style="display:none"></div>
+		<div id="throbberBlock" style="position: absolute; visibility: hidden"></div>
+		<script type="text/javascript">
+			// Set the class name for language direction.
+			document.body.className += ' ' + langDir ;
+
+			var cover = $( 'cover' ) ;
+			cover.style.backgroundColor = FCKConfig.BackgroundBlockerColor ;
+			FCKDomTools.SetOpacity( cover, FCKConfig.BackgroundBlockerOpacity ) ;
+		</script>
 	</body>
 </html>
Index: /FCKeditor/trunk/editor/fckeditor.html
===================================================================
--- /FCKeditor/trunk/editor/fckeditor.html	(revision 1397)
+++ /FCKeditor/trunk/editor/fckeditor.html	(revision 1398)
@@ -182,5 +182,4 @@
 LoadScript( '_source/internals/fcktoolbarset.js' ) ;
 LoadScript( '_source/internals/fckdialog.js' ) ;
-LoadScript( '_source/internals/fckdialog_' + sSuffix + '.js' ) ;
 LoadScript( '_source/classes/fckmenuitem.js' ) ;
 LoadScript( '_source/classes/fckmenublock.js' ) ;
@@ -238,4 +237,9 @@
 
 FCKConfig_PreProcess() ;
+
+// Popup the debug window if debug mode is set to true. It guarantees that the
+// first debug message will not be lost.
+if ( FCKConfig.Debug )
+	FCKDebug._GetWindow() ;
 
 // Load the active skin CSS.
Index: /FCKeditor/trunk/editor/filemanager/connectors/aspx/connector.aspx
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/aspx/connector.aspx	(revision 1397)
+++ /FCKeditor/trunk/editor/filemanager/connectors/aspx/connector.aspx	(revision 1398)
@@ -1,3 +1,3 @@
-<%@ Page Language="c#" Trace="false" Inherits="FredCK.FCKeditorV2.FileBrowser.Connector" AutoEventWireup="false" %>
+﻿<%@ Page Language="c#" Trace="false" Inherits="FredCK.FCKeditorV2.FileBrowser.Connector" AutoEventWireup="false" %>
 <%@ Register Src="config.ascx" TagName="Config" TagPrefix="FCKeditor" %>
 <%--
Index: /FCKeditor/trunk/editor/filemanager/connectors/aspx/upload.aspx
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/aspx/upload.aspx	(revision 1397)
+++ /FCKeditor/trunk/editor/filemanager/connectors/aspx/upload.aspx	(revision 1398)
@@ -1,3 +1,3 @@
-<%@ Page Language="c#" Trace="false" Inherits="FredCK.FCKeditorV2.FileBrowser.Uploader" AutoEventWireup="false" %>
+﻿<%@ Page Language="c#" Trace="false" Inherits="FredCK.FCKeditorV2.FileBrowser.Uploader" AutoEventWireup="false" %>
 <%@ Register Src="config.ascx" TagName="Config" TagPrefix="FCKeditor" %>
 <%--
Index: /FCKeditor/trunk/editor/plugins/placeholder/fckplugin.js
===================================================================
--- /FCKeditor/trunk/editor/plugins/placeholder/fckplugin.js	(revision 1397)
+++ /FCKeditor/trunk/editor/plugins/placeholder/fckplugin.js	(revision 1398)
@@ -23,5 +23,5 @@
 
 // Register the related command.
-FCKCommands.RegisterCommand( 'Placeholder', new FCKDialogCommand( 'Placeholder', FCKLang.PlaceholderDlgTitle, FCKPlugins.Items['placeholder'].Path + 'fck_placeholder.html', 340, 170 ) ) ;
+FCKCommands.RegisterCommand( 'Placeholder', new FCKDialogCommand( 'Placeholder', FCKLang.PlaceholderDlgTitle, FCKPlugins.Items['placeholder'].Path + 'fck_placeholder.html', 340, 160 ) ) ;
 
 // Create the "Plaholder" toolbar button.
Index: /FCKeditor/trunk/editor/skins/default/fck_dialog.css
===================================================================
--- /FCKeditor/trunk/editor/skins/default/fck_dialog.css	(revision 1397)
+++ /FCKeditor/trunk/editor/skins/default/fck_dialog.css	(revision 1398)
@@ -1,3 +1,3 @@
-/*
+﻿/*
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  * Copyright (C) 2003-2007 Frederico Caldeira Knabben
@@ -22,7 +22,13 @@
  */
 
+html, body
+{
+	background-color: transparent;
+	margin: 0px;
+	padding: 0px;
+}
+
 body
 {
-	margin: 0px;
 	padding: 10px;
 }
@@ -39,11 +45,19 @@
 }
 
-.PopupBody
-{
-	margin: 0px;
+.DialogBody
+{
+	height: 100%;
+	width: 100%;
+	overflow: hidden;
+	background-color: transparent;
 	padding: 0px;
 }
 
-.PopupTitle
+#header
+{
+	cursor: move;
+}
+
+.DialogTitle
 {
 	font-weight: bold;
@@ -54,6 +68,8 @@
 }
 
-.PopupButtons
-{
+.DialogButtons
+{
+	position: absolute;
+	bottom: 0px;
 	border-top: #d5d59d 1px solid;
 	background-color: #e3e3c7;
@@ -83,10 +99,10 @@
 }
 
-.PopupTitleBorder
+.DialogTitleBorder
 {
 	border-bottom: #d5d59d 1px solid;
 }
 
-.PopupTabArea
+.DialogTabArea
 {
 	color: #737357;
@@ -94,11 +110,11 @@
 }
 
-.PopupTabEmptyArea
-{
-	padding-left: 10px ;
+.DialogTabEmptyArea
+{
+	padding-left: 10px;
 	border-bottom: #d5d59d 1px solid;
 }
 
-.PopupTab, .PopupTabSelected
+.DialogTab, .DialogTabSelected
 {
 	border-right: #d5d59d 1px solid;
@@ -109,5 +125,5 @@
 }
 
-.PopupTab
+.DialogTab
 {
 	margin-top: 1px;
@@ -117,7 +133,7 @@
 }
 
-.PopupTabSelected
-{
-	font-weight:bold;
+.DialogTabSelected
+{
+	font-weight: bold;
 	cursor: default;
 	padding-top: 4px;
@@ -126,5 +142,5 @@
 }
 
-.PopupSelectionBox
+.DialogSelectionBox
 {
 	border: #ff9933 1px solid !important;
@@ -134,6 +150,251 @@
 }
 
-#tdBrowse 
+#tdBrowse
 {
 	vertical-align: bottom;
 }
+
+/**
+ * Dialog frame related styles.
+ */
+
+.contents
+{
+	position: absolute;
+	top: 2px;
+	left: 16px;
+	right: 16px;
+	bottom: 20px;
+	background-color: #f1f1e3;
+	overflow: hidden;
+	z-index: 1;
+}
+
+.tl, .tr, .tc, .bl, .br, .bc
+{
+	position: absolute;
+	background-image: url(images/sprites.png);
+	background-repeat: no-repeat;
+}
+
+* html .tl, * html .tr, * html .tc, * html .bl, * html .br, * html .bc
+{
+	background-image: url(images/sprites.gif);
+}
+
+.ml, .mr
+{
+	position: absolute;
+	background-image: url(images/dialog.sides.png);
+	background-repeat: repeat-y;
+}
+
+* html .ml, * html .mr
+{
+	background-image: url(images/dialog.sides.gif);
+}
+
+.rtl .ml, .rtl .mr
+{
+	position: absolute;
+	background-image: url(images/dialog.sides.rtl.png);
+	background-repeat: repeat-y;
+}
+
+* html .rtl .ml, * html .rtl .mr
+{
+	background-image: url(images/dialog.sides.gif);
+}
+
+.tl
+{
+	top: 0px;
+	left: 0px;
+	width: 16px;
+	height: 16px;
+	background-position: -16px -16px;
+}
+
+.rtl .tl
+{
+	background-position: -16px -397px;
+}
+
+.tr
+{
+	top: 0px;
+	right: 0px;
+	width: 16px;
+	height: 16px;
+	background-position: -16px -76px;
+}
+
+.rtl .tr
+{
+	background-position: -16px -457px;
+}
+
+.tc
+{
+	top: 0px;
+	right: 16px;
+	left: 16px;
+	height: 16px;
+	background-position: 0px -136px;
+	background-repeat: repeat-x;
+}
+
+.ml
+{
+	top: 16px;
+	left: 0px;
+	width: 16px;
+	bottom: 51px;
+	background-position: 0px 0px;
+}
+
+.mr
+{
+	top: 16px;
+	right: 0px;
+	width: 16px;
+	bottom: 51px;
+	background-position: -16px 0px;
+}
+
+.bl
+{
+	bottom: 0px;
+	left: 0px;
+	width: 30px;
+	height: 51px;
+	background-position: -16px -196px;
+}
+
+.rtl .bl
+{
+	background-position: -16px -517px;
+}
+
+.br
+{
+	bottom: 0px;
+	right: 0px;
+	width: 30px;
+	height: 51px;
+	background-position: -16px -263px;
+}
+
+.rtl .br
+{
+	background-position: -16px -584px;
+}
+
+.bc
+{
+	bottom: 0px;
+	right: 30px;
+	left: 30px;
+	height: 51px;
+	background-position: 0px -330px;
+	background-repeat: repeat-x;
+}
+
+/* For IE6. Do not change it. */
+* html .blocker
+{
+	position: absolute;
+	width: 100%;
+	height: 100%;
+	z-index: 12;
+	filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
+}
+
+/* The layer used to cover the dialog when opening a child dialog. */
+.cover
+{
+	position: absolute;
+	top: 0px;
+	left: 14px;
+	right: 14px;
+	bottom: 18px;
+	z-index: 11;
+}
+
+#closeButton
+{
+	position: absolute;
+	right: 0px;
+	top: 0px;
+	margin-top: 5px;
+	margin-right: 10px;
+	width: 20px;
+	height: 20px;
+	cursor: pointer;
+	background-image: url(images/sprites.png);
+	background-repeat: no-repeat;
+	background-position: -16px -651px;
+}
+
+* html #closeButton
+{
+	cursor: hand;
+	background-image: url(images/sprites.gif);
+}
+
+.rtl #closeButton
+{
+	right: auto;
+	left: 0px;
+	margin-left: 10px;
+}
+
+#closeButton:hover
+{
+	background-position: -16px -687px;
+}
+
+#throbberBlock 
+{
+	z-index: 10; 
+}
+
+#throbberBlock div
+{
+	float: left;
+	width: 8px;
+	height: 9px;
+	margin-left: 2px;
+	margin-right: 2px;
+	font-size: 1px;	/* IE6 */
+}
+
+/* 
+	Color Gradient Generator:
+	http://www.herethere.net/~samson/php/color_gradient/?cbegin=737357&cend=E3E3C7&steps=4
+*/
+
+.throbber_1
+{
+	background-color: #737357;
+}
+
+.throbber_2
+{
+	background-color: #8f8f73;
+}
+
+.throbber_3
+{
+	background-color: #abab8f;
+}
+
+.throbber_4
+{
+	background-color: #c7c7ab;
+}
+
+.throbber_5
+{
+	background-color: #e3e3c7;
+}
Index: /FCKeditor/trunk/editor/skins/default/fck_dialog_ie6.js
===================================================================
--- /FCKeditor/trunk/editor/skins/default/fck_dialog_ie6.js	(revision 1398)
+++ /FCKeditor/trunk/editor/skins/default/fck_dialog_ie6.js	(revision 1398)
@@ -0,0 +1,110 @@
+﻿/*
+ * 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 ==
+ */
+
+(function()
+{
+	// IE6 doens't handle absolute positioning properly (it is always in quirks
+	// mode). This function fixes the sizes and positions of many elements that
+	// compose the skin (this is skin specific).
+	var fixSizes = window.DoResizeFixes = function()
+	{
+		var fckDlg = window.document.body ;
+		
+		for ( var i = 0 ; i < fckDlg.childNodes.length ; i++ )
+		{
+			var child = fckDlg.childNodes[i] ;
+			switch ( child.className )
+			{
+				case 'contents' :
+					child.style.width = Math.max( 0, fckDlg.offsetWidth - 16 - 16 ) ;	// -left -right
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 20 - 2 ) ;	// -bottom -top
+					break ;
+
+				case 'blocker' :
+				case 'cover' :
+					child.style.width = Math.max( 0, fckDlg.offsetWidth - 16 - 16 + 4 ) ;	// -left -right + 4
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 20 - 2 + 4 ) ;	// -bottom -top + 4
+					break ;
+				
+				case 'tr' :
+					child.style.left = Math.max( 0, fckDlg.clientWidth - 16 ) ;
+					break ;
+
+				case 'tc' :
+					child.style.width = Math.max( 0, fckDlg.clientWidth - 16 - 16 ) ;
+					break ;
+				
+				case 'ml' :
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 16 - 51 ) ;
+					break ;
+				
+				case 'mr' :
+					child.style.left = Math.max( 0, fckDlg.clientWidth - 16 ) ;
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 16 - 51 ) ;
+					break ;
+				
+				case 'bl' :
+					child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ;
+					break ;
+				
+				case 'br' :
+					child.style.left = Math.max( 0, fckDlg.clientWidth - 30 ) ;
+					child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ;
+					break ;
+				
+				case 'bc' :
+					child.style.width = Math.max( 0, fckDlg.clientWidth - 30 - 30 ) ;
+					child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ;
+					break ;
+			}
+		}
+	}
+	
+	var closeButtonOver = function()
+	{
+		this.style.backgroundPosition = '-16px -687px' ;
+	} ;
+	
+	var closeButtonOut = function()
+	{
+		this.style.backgroundPosition = '-16px -651px' ;
+	} ;
+	
+	var fixCloseButton = function()
+	{
+		var closeButton = document.getElementById ( 'closeButton' ) ;
+
+		closeButton.onmouseover	= closeButtonOver ;
+		closeButton.onmouseout	= closeButtonOut ;
+	}
+	
+	var onLoad = function()
+	{
+		fixSizes() ;
+		fixCloseButton() ;
+		
+		window.attachEvent( 'onresize', fixSizes ) ;
+		window.detachEvent( 'onload', onLoad ) ;
+	}
+	
+	window.attachEvent( 'onload', onLoad ) ;
+
+})() ;
Index: /FCKeditor/trunk/editor/skins/office2003/fck_dialog.css
===================================================================
--- /FCKeditor/trunk/editor/skins/office2003/fck_dialog.css	(revision 1397)
+++ /FCKeditor/trunk/editor/skins/office2003/fck_dialog.css	(revision 1398)
@@ -1,3 +1,3 @@
-/*
+﻿/*
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  * Copyright (C) 2003-2007 Frederico Caldeira Knabben
@@ -22,9 +22,14 @@
  */
 
+html, body
+{
+	background-color: transparent;
+	margin: 0px;
+	padding: 0px;
+}
+
 body
 {
-	margin: 0px;
 	padding: 10px;
-	background-color: #f7f8fd;
 }
 
@@ -40,11 +45,19 @@
 }
 
-.PopupBody
-{
-	margin: 0px;
+.DialogBody
+{
+	height: 100%;
+	width: 100%;
+	overflow: hidden;
+	background-color: transparent;
 	padding: 0px;
 }
 
-.PopupTitle
+#header
+{
+	cursor: move;
+}
+
+.DialogTitle
 {
 	font-weight: bold;
@@ -55,6 +68,8 @@
 }
 
-.PopupButtons
-{
+.DialogButtons
+{
+	position: absolute;
+	bottom: 0px;
 	border-top: #466ca6 1px solid;
 	background-color: #8cb2fd;
@@ -84,10 +99,10 @@
 }
 
-.PopupTitleBorder
+.DialogTitleBorder
 {
 	border-bottom: #d5d59d 1px solid;
 }
 
-.PopupTabArea
+.DialogTabArea
 {
 	color: #0e3460;
@@ -95,5 +110,5 @@
 }
 
-.PopupTabEmptyArea
+.DialogTabEmptyArea
 {
 	padding-left: 10px ;
@@ -101,5 +116,5 @@
 }
 
-.PopupTab, .PopupTabSelected
+.DialogTab, .DialogTabSelected
 {
 	border-right: #466ca6 1px solid;
@@ -110,5 +125,5 @@
 }
 
-.PopupTab
+.DialogTab
 {
 	margin-top: 1px;
@@ -118,7 +133,7 @@
 }
 
-.PopupTabSelected
-{
-	font-weight:bold;
+.DialogTabSelected
+{
+	font-weight: bold;
 	cursor: default;
 	padding-top: 4px;
@@ -127,5 +142,5 @@
 }
 
-.PopupSelectionBox
+.DialogSelectionBox
 {
 	border: #1e90ff 1px solid !important;
@@ -139,2 +154,247 @@
 	vertical-align: bottom;
 }
+
+/**
+ * Dialog frame related styles.
+ */
+
+.contents
+{
+	position: absolute;
+	top: 2px;
+	left: 16px;
+	right: 16px;
+	bottom: 20px;
+	background-color: #f7f8fD;
+	overflow: hidden;
+	z-index: 1;
+}
+
+.tl, .tr, .tc, .bl, .br, .bc
+{
+	position: absolute;
+	background-image: url(images/sprites.png);
+	background-repeat: no-repeat;
+}
+
+* html .tl, * html .tr, * html .tc, * html .bl, * html .br, * html .bc
+{
+	background-image: url(images/sprites.gif);
+}
+
+.ml, .mr
+{
+	position: absolute;
+	background-image: url(images/dialog.sides.png);
+	background-repeat: repeat-y;
+}
+
+* html .ml, * html .mr
+{
+	background-image: url(images/dialog.sides.gif);
+}
+
+.rtl .ml, .rtl .mr
+{
+	position: absolute;
+	background-image: url(images/dialog.sides.rtl.png);
+	background-repeat: repeat-y;
+}
+
+* html .rtl .ml, * html .rtl .mr
+{
+	background-image: url(images/dialog.sides.gif);
+}
+
+.tl
+{
+	top: 0px;
+	left: 0px;
+	width: 16px;
+	height: 16px;
+	background-position: -16px -16px;
+}
+
+.rtl .tl
+{
+	background-position: -16px -397px;
+}
+
+.tr
+{
+	top: 0px;
+	right: 0px;
+	width: 16px;
+	height: 16px;
+	background-position: -16px -76px;
+}
+
+.rtl .tr
+{
+	background-position: -16px -457px;
+}
+
+.tc
+{
+	top: 0px;
+	right: 16px;
+	left: 16px;
+	height: 16px;
+	background-position: 0px -136px;
+	background-repeat: repeat-x;
+}
+
+.ml
+{
+	top: 16px;
+	left: 0px;
+	width: 16px;
+	bottom: 51px;
+	background-position: 0px 0px;
+}
+
+.mr
+{
+	top: 16px;
+	right: 0px;
+	width: 16px;
+	bottom: 51px;
+	background-position: -16px 0px;
+}
+
+.bl
+{
+	bottom: 0px;
+	left: 0px;
+	width: 30px;
+	height: 51px;
+	background-position: -16px -196px;
+}
+
+.rtl .bl
+{
+	background-position: -16px -517px;
+}
+
+.br
+{
+	bottom: 0px;
+	right: 0px;
+	width: 30px;
+	height: 51px;
+	background-position: -16px -263px;
+}
+
+.rtl .br
+{
+	background-position: -16px -584px;
+}
+
+.bc
+{
+	bottom: 0px;
+	right: 30px;
+	left: 30px;
+	height: 51px;
+	background-position: 0px -330px;
+	background-repeat: repeat-x;
+}
+
+/* For IE6. Do not change it. */
+* html .blocker
+{
+	position: absolute;
+	width: 100%;
+	height: 100%;
+	z-index: 12;
+	filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
+}
+
+/* The layer used to cover the dialog when opening a child dialog. */
+.cover
+{
+	position: absolute;
+	top: 0px;
+	left: 14px;
+	right: 14px;
+	bottom: 18px;
+	z-index: 11;
+}
+
+#closeButton
+{
+	position: absolute;
+	right: 0px;
+	top: 0px;
+	margin-top: 5px;
+	margin-right: 10px;
+	width: 20px;
+	height: 20px;
+	cursor: pointer;
+	background-image: url(images/sprites.png);
+	background-repeat: no-repeat;
+	background-position: -16px -651px;
+}
+
+* html #closeButton
+{
+	cursor: hand;
+	background-image: url(images/sprites.gif);
+}
+
+.rtl #closeButton
+{
+	right: auto;
+	left: 0px;
+	margin-left: 10px;
+}
+
+#closeButton:hover
+{
+	background-position: -16px -687px;
+}
+
+#throbberBlock 
+{
+	z-index: 10; 
+}
+
+#throbberBlock div
+{
+	float: left;
+	width: 8px;
+	height: 9px;
+	margin-left: 2px;
+	margin-right: 2px;
+	font-size: 1px;	/* IE6 */
+}
+
+/* 
+	Color Gradient Generator:
+	http://www.herethere.net/~samson/php/color_gradient/?cbegin=0E3460&cend=8cb2fd&steps=4
+*/
+
+.throbber_1
+{
+	background-color: #0E3460;
+}
+
+.throbber_2
+{
+	background-color: #2D5387;
+}
+
+.throbber_3
+{
+	background-color: #4D73AE;
+}
+
+.throbber_4
+{
+	background-color: #6C92D5;
+}
+
+.throbber_5
+{
+	background-color: #8CB2FD;
+}
Index: /FCKeditor/trunk/editor/skins/office2003/fck_dialog_ie6.js
===================================================================
--- /FCKeditor/trunk/editor/skins/office2003/fck_dialog_ie6.js	(revision 1398)
+++ /FCKeditor/trunk/editor/skins/office2003/fck_dialog_ie6.js	(revision 1398)
@@ -0,0 +1,110 @@
+﻿/*
+ * 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 ==
+ */
+
+(function()
+{
+	// IE6 doens't handle absolute positioning properly (it is always in quirks
+	// mode). This function fixes the sizes and positions of many elements that
+	// compose the skin (this is skin specific).
+	var fixSizes = window.DoResizeFixes = function()
+	{
+		var fckDlg = window.document.body ;
+		
+		for ( var i = 0 ; i < fckDlg.childNodes.length ; i++ )
+		{
+			var child = fckDlg.childNodes[i] ;
+			switch ( child.className )
+			{
+				case 'contents' :
+					child.style.width = Math.max( 0, fckDlg.offsetWidth - 16 - 16 ) ;	// -left -right
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 20 - 2 ) ;	// -bottom -top
+					break ;
+
+				case 'blocker' :
+				case 'cover' :
+					child.style.width = Math.max( 0, fckDlg.offsetWidth - 16 - 16 + 4 ) ;	// -left -right + 4
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 20 - 2 + 4 ) ;	// -bottom -top + 4
+					break ;
+				
+				case 'tr' :
+					child.style.left = Math.max( 0, fckDlg.clientWidth - 16 ) ;
+					break ;
+
+				case 'tc' :
+					child.style.width = Math.max( 0, fckDlg.clientWidth - 16 - 16 ) ;
+					break ;
+				
+				case 'ml' :
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 16 - 51 ) ;
+					break ;
+				
+				case 'mr' :
+					child.style.left = Math.max( 0, fckDlg.clientWidth - 16 ) ;
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 16 - 51 ) ;
+					break ;
+				
+				case 'bl' :
+					child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ;
+					break ;
+				
+				case 'br' :
+					child.style.left = Math.max( 0, fckDlg.clientWidth - 30 ) ;
+					child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ;
+					break ;
+				
+				case 'bc' :
+					child.style.width = Math.max( 0, fckDlg.clientWidth - 30 - 30 ) ;
+					child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ;
+					break ;
+			}
+		}
+	}
+	
+	var closeButtonOver = function()
+	{
+		this.style.backgroundPosition = '-16px -687px' ;
+	} ;
+	
+	var closeButtonOut = function()
+	{
+		this.style.backgroundPosition = '-16px -651px' ;
+	} ;
+	
+	var fixCloseButton = function()
+	{
+		var closeButton = document.getElementById ( 'closeButton' ) ;
+
+		closeButton.onmouseover	= closeButtonOver ;
+		closeButton.onmouseout	= closeButtonOut ;
+	}
+	
+	var onLoad = function()
+	{
+		fixSizes() ;
+		fixCloseButton() ;
+		
+		window.attachEvent( 'onresize', fixSizes ) ;
+		window.detachEvent( 'onload', onLoad ) ;
+	}
+	
+	window.attachEvent( 'onload', onLoad ) ;
+
+})() ;
Index: /FCKeditor/trunk/editor/skins/silver/fck_dialog.css
===================================================================
--- /FCKeditor/trunk/editor/skins/silver/fck_dialog.css	(revision 1397)
+++ /FCKeditor/trunk/editor/skins/silver/fck_dialog.css	(revision 1398)
@@ -1,3 +1,3 @@
-/*
+﻿/*
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  * Copyright (C) 2003-2007 Frederico Caldeira Knabben
@@ -22,9 +22,14 @@
  */
 
+html, body
+{
+	background-color: transparent;
+	margin: 0px;
+	padding: 0px;
+}
+
 body
 {
-	margin: 0px;
 	padding: 10px;
-	background-color: #f7f7f7;
 }
 
@@ -40,24 +45,31 @@
 }
 
-.PopupBody
-{
-	margin: 0px;
+.DialogBody
+{
+	height: 100%;
+	width: 100%;
+	overflow: hidden;
+	background-color: transparent;
 	padding: 0px;
 }
 
-.PopupTitle
-{
-	padding-right: 10px;
-	padding-left: 10px;
+#header
+{
+	cursor: move;
+}
+
+.DialogTitle
+{
 	font-weight: bold;
 	font-size: 14pt;
-	padding-bottom: 3px;
 	color: #504845;
-	padding-top: 3px;
 	background-color: #dedede;
-}
-
-.PopupButtons
-{
+	padding: 3px 10px 3px 10px;
+}
+
+.DialogButtons
+{
+	position: absolute;
+	bottom: 0px;
 	border-top: #cec6b5 1px solid;
 	background-color: #DEDEDE;
@@ -87,10 +99,10 @@
 }
 
-.PopupTitleBorder
+.DialogTitleBorder
 {
 	border-bottom: #cec6b5 1px solid;
 }
 
-.PopupTabArea
+.DialogTabArea
 {
 	color: #504845;
@@ -98,5 +110,5 @@
 }
 
-.PopupTabEmptyArea
+.DialogTabEmptyArea
 {
 	padding-left: 10px ;
@@ -104,5 +116,5 @@
 }
 
-.PopupTab, .PopupTabSelected
+.DialogTab, .DialogTabSelected
 {
 	border-right: #cec6b5 1px solid;
@@ -113,5 +125,5 @@
 }
 
-.PopupTab
+.DialogTab
 {
 	margin-top: 1px;
@@ -121,5 +133,5 @@
 }
 
-.PopupTabSelected
+.DialogTabSelected
 {
 	font-weight:bold;
@@ -130,5 +142,5 @@
 }
 
-.PopupSelectionBox
+.DialogSelectionBox
 {
 	border: #a9a9a9 1px solid !important;
@@ -142,2 +154,247 @@
 	vertical-align: bottom;
 }
+
+/**
+ * Dialog frame related styles.
+ */
+
+.contents
+{
+	position: absolute;
+	top: 2px;
+	left: 16px;
+	right: 16px;
+	bottom: 20px;
+	background-color: #f7f7f7;
+	overflow: hidden;
+	z-index: 1;
+}
+
+.tl, .tr, .tc, .bl, .br, .bc
+{
+	position: absolute;
+	background-image: url(images/sprites.png);
+	background-repeat: no-repeat;
+}
+
+* html .tl, * html .tr, * html .tc, * html .bl, * html .br, * html .bc
+{
+	background-image: url(images/sprites.gif);
+}
+
+.ml, .mr
+{
+	position: absolute;
+	background-image: url(images/dialog.sides.png);
+	background-repeat: repeat-y;
+}
+
+* html .ml, * html .mr
+{
+	background-image: url(images/dialog.sides.gif);
+}
+
+.rtl .ml, .rtl .mr
+{
+	position: absolute;
+	background-image: url(images/dialog.sides.rtl.png);
+	background-repeat: repeat-y;
+}
+
+* html .rtl .ml, * html .rtl .mr
+{
+	background-image: url(images/dialog.sides.gif);
+}
+
+.tl
+{
+	top: 0px;
+	left: 0px;
+	width: 16px;
+	height: 16px;
+	background-position: -16px -16px;
+}
+
+.rtl .tl
+{
+	background-position: -16px -397px;
+}
+
+.tr
+{
+	top: 0px;
+	right: 0px;
+	width: 16px;
+	height: 16px;
+	background-position: -16px -76px;
+}
+
+.rtl .tr
+{
+	background-position: -16px -457px;
+}
+
+.tc
+{
+	top: 0px;
+	right: 16px;
+	left: 16px;
+	height: 16px;
+	background-position: 0px -136px;
+	background-repeat: repeat-x;
+}
+
+.ml
+{
+	top: 16px;
+	left: 0px;
+	width: 16px;
+	bottom: 51px;
+	background-position: 0px 0px;
+}
+
+.mr
+{
+	top: 16px;
+	right: 0px;
+	width: 16px;
+	bottom: 51px;
+	background-position: -16px 0px;
+}
+
+.bl
+{
+	bottom: 0px;
+	left: 0px;
+	width: 30px;
+	height: 51px;
+	background-position: -16px -196px;
+}
+
+.rtl .bl
+{
+	background-position: -16px -517px;
+}
+
+.br
+{
+	bottom: 0px;
+	right: 0px;
+	width: 30px;
+	height: 51px;
+	background-position: -16px -263px;
+}
+
+.rtl .br
+{
+	background-position: -16px -584px;
+}
+
+.bc
+{
+	bottom: 0px;
+	right: 30px;
+	left: 30px;
+	height: 51px;
+	background-position: 0px -330px;
+	background-repeat: repeat-x;
+}
+
+/* For IE6. Do not change it. */
+* html .blocker
+{
+	position: absolute;
+	width: 100%;
+	height: 100%;
+	z-index: 12;
+	filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
+}
+
+/* The layer used to cover the dialog when opening a child dialog. */
+.cover
+{
+	position: absolute;
+	top: 0px;
+	left: 14px;
+	right: 14px;
+	bottom: 18px;
+	z-index: 11;
+}
+
+#closeButton
+{
+	position: absolute;
+	right: 0px;
+	top: 0px;
+	margin-top: 5px;
+	margin-right: 10px;
+	width: 20px;
+	height: 20px;
+	cursor: pointer;
+	background-image: url(images/sprites.png);
+	background-repeat: no-repeat;
+	background-position: -16px -651px;
+}
+
+* html #closeButton
+{
+	cursor: hand;
+	background-image: url(images/sprites.gif);
+}
+
+.rtl #closeButton
+{
+	right: auto;
+	left: 0px;
+	margin-left: 10px;
+}
+
+#closeButton:hover
+{
+	background-position: -16px -687px;
+}
+
+#throbberBlock 
+{
+	z-index: 10; 
+}
+
+#throbberBlock div
+{
+	float: left;
+	width: 8px;
+	height: 9px;
+	margin-left: 2px;
+	margin-right: 2px;
+	font-size: 1px;	/* IE6 */
+}
+
+/* 
+	Color Gradient Generator:
+	http://www.herethere.net/~samson/php/color_gradient/?cbegin=504845&cend=DEDEDE&steps=4
+*/
+
+.throbber_1
+{
+	background-color: #504845;
+}
+
+.throbber_2
+{
+	background-color: #736D6B;
+}
+
+.throbber_3
+{
+	background-color: #979391;
+}
+
+.throbber_4
+{
+	background-color: #BAB8B7;
+}
+
+.throbber_5
+{
+	background-color: #DEDEDE;
+}
Index: /FCKeditor/trunk/editor/skins/silver/fck_dialog_ie6.js
===================================================================
--- /FCKeditor/trunk/editor/skins/silver/fck_dialog_ie6.js	(revision 1398)
+++ /FCKeditor/trunk/editor/skins/silver/fck_dialog_ie6.js	(revision 1398)
@@ -0,0 +1,110 @@
+﻿/*
+ * 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 ==
+ */
+
+(function()
+{
+	// IE6 doens't handle absolute positioning properly (it is always in quirks
+	// mode). This function fixes the sizes and positions of many elements that
+	// compose the skin (this is skin specific).
+	var fixSizes = window.DoResizeFixes = function()
+	{
+		var fckDlg = window.document.body ;
+		
+		for ( var i = 0 ; i < fckDlg.childNodes.length ; i++ )
+		{
+			var child = fckDlg.childNodes[i] ;
+			switch ( child.className )
+			{
+				case 'contents' :
+					child.style.width = Math.max( 0, fckDlg.offsetWidth - 16 - 16 ) ;	// -left -right
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 20 - 2 ) ;	// -bottom -top
+					break ;
+
+				case 'blocker' :
+				case 'cover' :
+					child.style.width = Math.max( 0, fckDlg.offsetWidth - 16 - 16 + 4 ) ;	// -left -right + 4
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 20 - 2 + 4 ) ;	// -bottom -top + 4
+					break ;
+				
+				case 'tr' :
+					child.style.left = Math.max( 0, fckDlg.clientWidth - 16 ) ;
+					break ;
+
+				case 'tc' :
+					child.style.width = Math.max( 0, fckDlg.clientWidth - 16 - 16 ) ;
+					break ;
+				
+				case 'ml' :
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 16 - 51 ) ;
+					break ;
+				
+				case 'mr' :
+					child.style.left = Math.max( 0, fckDlg.clientWidth - 16 ) ;
+					child.style.height = Math.max( 0, fckDlg.clientHeight - 16 - 51 ) ;
+					break ;
+				
+				case 'bl' :
+					child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ;
+					break ;
+				
+				case 'br' :
+					child.style.left = Math.max( 0, fckDlg.clientWidth - 30 ) ;
+					child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ;
+					break ;
+				
+				case 'bc' :
+					child.style.width = Math.max( 0, fckDlg.clientWidth - 30 - 30 ) ;
+					child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ;
+					break ;
+			}
+		}
+	}
+	
+	var closeButtonOver = function()
+	{
+		this.style.backgroundPosition = '-16px -687px' ;
+	} ;
+	
+	var closeButtonOut = function()
+	{
+		this.style.backgroundPosition = '-16px -651px' ;
+	} ;
+	
+	var fixCloseButton = function()
+	{
+		var closeButton = document.getElementById ( 'closeButton' ) ;
+
+		closeButton.onmouseover	= closeButtonOver ;
+		closeButton.onmouseout	= closeButtonOut ;
+	}
+	
+	var onLoad = function()
+	{
+		fixSizes() ;
+		fixCloseButton() ;
+		
+		window.attachEvent( 'onresize', fixSizes ) ;
+		window.detachEvent( 'onload', onLoad ) ;
+	}
+	
+	window.attachEvent( 'onload', onLoad ) ;
+
+})() ;
Index: /FCKeditor/trunk/fckconfig.js
===================================================================
--- /FCKeditor/trunk/fckconfig.js	(revision 1397)
+++ /FCKeditor/trunk/fckconfig.js	(revision 1398)
@@ -240,5 +240,7 @@
 	},
 	
-	'BackColor'		: { Element : 'span', Styles : { 'background-color' : '#("Color","color")' } }
+	'BackColor'		: { Element : 'span', Styles : { 'background-color' : '#("Color","color")' } },
+
+	'SelectionHighlight' : { Element : 'span', Styles : { 'background-color' : 'navy', 'color' : 'white' } }
 };
 
@@ -303,4 +305,6 @@
 FCKConfig.SmileyColumns = 8 ;
 FCKConfig.SmileyWindowWidth		= 320 ;
-FCKConfig.SmileyWindowHeight	= 240 ;
-
+FCKConfig.SmileyWindowHeight	= 210 ;
+
+FCKConfig.BackgroundBlockerColor = '#ffffff' ;
+FCKConfig.BackgroundBlockerOpacity = 0.50 ;
Index: /FCKeditor/trunk/fckpackager.xml
===================================================================
--- /FCKeditor/trunk/fckpackager.xml	(revision 1397)
+++ /FCKeditor/trunk/fckpackager.xml	(revision 1398)
@@ -152,5 +152,4 @@
 		<File path="editor/_source/internals/fcktoolbarset.js" />
 		<File path="editor/_source/internals/fckdialog.js" />
-		<File path="editor/_source/internals/fckdialog_ie.js" />
 
 		<File path="editor/_source/classes/fckmenuitem.js" />
@@ -248,5 +247,4 @@
 		<File path="editor/_source/internals/fcktoolbarset.js" />
 		<File path="editor/_source/internals/fckdialog.js" />
-		<File path="editor/_source/internals/fckdialog_gecko.js" />
 
 		<File path="editor/_source/classes/fckmenuitem.js" />
