Index: /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckdomrangeiterator.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckdomrangeiterator.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckdomrangeiterator.js	(revision 1220)
@@ -126,4 +126,9 @@
 					}
 
+					// The range must finish right before the boundary,
+					// including possibly skipped empty spaces. (#1603)
+					if ( range )
+						range.SetEnd( currentNode, 3, true ) ;
+
 					closeRange = true ;
 				}
@@ -182,4 +187,5 @@
 
 					currentNode = parentNode ;
+					includeNode = true ;
 					isLast = ( currentNode == lastNode ) ;
 					continueFromSibling = true ;
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckelementpath.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckelementpath.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckelementpath.js	(revision 1220)
@@ -47,6 +47,7 @@
 				if ( FCKListsLib.PathBlockLimitElements[ sElementName ] != null )
 				{
-					// DIV is considered the Block, if no block is available (#525).
-					if ( !eBlock && sElementName == 'div' )
+					// DIV is considered the Block, if no block is available (#525)
+					// and if it doesn't contain other blocks.
+					if ( !eBlock && sElementName == 'div' && !FCKElementPath._CheckHasBlock( e ) )
 						eBlock = e ;
 					else
@@ -68,3 +69,20 @@
 }
 
+/**
+ * Check if an element contains any block element.
+ */
+FCKElementPath._CheckHasBlock = function( element )
+{
+	var childNodes = element.childNodes ;
+	
+	for ( var i = 0, count = childNodes.length ; i < count ; i++ )
+	{
+		var child = childNodes[i] ;
+		
+		if ( child.nodeType == 1 && FCKListsLib.BlockElements[ child.nodeName.toLowerCase() ] )
+			return true ;
+	}
+	
+	return false ;
+}
 
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckenterkey.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckenterkey.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckenterkey.js	(revision 1220)
@@ -462,5 +462,4 @@
 			if ( elementPath )
 			{
-				var eFocusElement = eNewBlock ;
 				for ( var i = 0, len = elementPath.Elements.length ; i < len ; i++ )
 				{
@@ -469,7 +468,11 @@
 					if ( element == elementPath.Block || element == elementPath.BlockLimit )
 						break ;
-
+					
 					if ( FCKListsLib.InlineChildReqElements[ element.nodeName.toLowerCase() ] )
-						eFocusElement = eFocusElement.appendChild( FCKDomTools.CloneElement( element ) ) ;
+					{
+						element = FCKDomTools.CloneElement( element ) ;
+						FCKDomTools.MoveChildren( eNewBlock, element ) ;
+						eNewBlock.appendChild( element ) ;
+					}
 				}
 			}
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fcktoolbarbuttonui.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fcktoolbarbuttonui.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fcktoolbarbuttonui.js	(revision 1220)
@@ -156,5 +156,4 @@
 	else if ( button.State == FCK_TRISTATE_ON )
 		this.className = 'TB_Button_On_Over' ;
-	FCK.ToolbarSet.CurrentInstance.LastActiveButton = button ;
 }
 
@@ -165,5 +164,4 @@
 	else if ( button.State == FCK_TRISTATE_ON )
 		this.className = 'TB_Button_On' ;
-	FCK.ToolbarSet.CurrentInstance.LastActiveButton = button ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fck.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fck.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fck.js	(revision 1220)
@@ -31,7 +31,5 @@
 	Toolbar			: null,
 	HasFocus		: false,
-	DataProcessor		: new FCKDataProcessor(),
-	Window			: window,
-	LastActiveButton	: null,
+	DataProcessor	: new FCKDataProcessor(),
 
 	AttachToOnSelectionChange : function( functionPointer )
@@ -800,106 +798,4 @@
 
 		return true ;
-	},
-
-	SetDialogMode: function( isEnabled )
-	{
-		var doc = this.Window.parent.document ;
-		var editorFrame = this.Window.frameElement ;
-		var editorParentElement = editorFrame.parentNode ;
-		var me = this ;
-		var isIE6 = FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 ;
-		var resizeHandler = function()
-		{
-			if ( !me.BackgroundBlocker )
-				return ;
-			FCKDomTools.SetElementStyles( me.BackgroundBlocker,
-				{
-					'width' : Math.max( doc.documentElement.scrollWidth,
-						doc.documentElement.clientWidth,
-						doc.body.scrollWidth ) - 1 + 'px',
-					'height' : Math.max( doc.documentElement.scrollHeight,
-						doc.documentElement.clientHeight,
-						doc.body.scrollHeight ) - 1 + 'px'
-				} ) ;
-		}
-		FCKTools.AddEventListener( this.Window.parent, 'resize', resizeHandler ) ;
-
-		if ( !this.BackgroundBlocker )
-		{
-			this.BackgroundBlocker = doc.createElement( 'div' ) ;
-			FCKDomTools.SetElementStyles( this.BackgroundBlocker,
-				{
-					'position' : 'absolute',
-					'zIndex' : 0,
-					'backgroundColor' : FCKConfig.BackgroundBlockerColor
-				} ) ;
-			FCKDomTools.SetOpacity( this.BackgroundBlocker, FCKConfig.BackgroundBlockerOpacity ) ;
-			editorParentElement.style.overflow = 'visible' ;
-
-			if ( isIE6 )
-			{
-				var iframe = doc.createElement( 'iframe' ) ;
-				iframe.src = 'javascript:void(0);' ;
-				iframe.hideFocus = true ;
-				iframe.frameBorder = 0 ;
-				FCKDomTools.SetElementStyles( iframe, 
-					{
-						'width' : '100%',
-						'height' : '100%',
-						'position' : 'absolute',
-						'left' : '0px',
-						'top' : '0px',
-						'filter' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)'
-					} ) ;
-				this.BackgroundBlocker.appendChild( iframe ) ;
-			}
-		}
-
-		if ( isEnabled )
-		{
-			var positionedAncestor = FCKDomTools.GetPositionedAncestor( this.Window.parent, editorParentElement ) ;
-			var positionedAncestorCoords = positionedAncestor ? 
-				FCKTools.GetDocumentPosition( this.Window.parent, positionedAncestor ) :
-				{ 'x' : 0, 'y' : 0 } ;
-			var editorFrameCoords=  FCKTools.GetDocumentPosition( this.Window.parent, editorFrame ) ;
-			resizeHandler() ;
-			FCKDomTools.SetElementStyles( this.BackgroundBlocker,
-				{
-					'left' : ( -1 * positionedAncestorCoords.x ) + 'px',
-					'top' : (-1 * positionedAncestorCoords.y ) + 'px',
-					'display' : ''
-				} ) ;
-
-			var currentElement = editorFrame ;
-			while ( ( currentElement = currentElement.parentNode ) )
-			{
-				if ( currentElement.nodeType == 1 )
-				{
-					currentElement._fckPreviousZIndex = currentElement.style.zIndex ? currentElement.style.zIndex : '' ;
-					currentElement.style.zIndex = FCKConfig.FloatingPanelsZIndex - 1 ;
-				}
-			}
-			editorParentElement.insertBefore( this.BackgroundBlocker, editorFrame ) ;
-
-			if ( this.LastActiveButton )
-				FCKToolbarButtonUI_OnMouseOut.apply( this.LastActiveButton.MainElement, [null, this.LastActiveButton ] ) ;
-
-			FCKFocusManager.Lock() ;
-		}
-		else
-		{
-			var currentElement = editorFrame ;
-			while ( ( currentElement = currentElement.parentNode ) )
-			{
-				if ( currentElement.nodeType == 1 && currentElement._fckPreviousZIndex != undefined )
-				{
-					currentElement.style.zIndex = currentElement._fckPreviousZIndex ;
-					FCKDomTools.ClearElementJSProperty( currentElement, '_fckPreviousZIndex' ) ;
-				}
-			}
-			this.BackgroundBlocker.parentNode.removeChild( this.BackgroundBlocker ) ;
-
-			FCKFocusManager.Unlock() ;
-		}
 	}
 } ;
@@ -1059,14 +955,4 @@
 		return ;
 
-	// Popup a debug window if debug mode is set to true.
-	if ( FCKConfig.Debug )
-		FCKDebug._GetWindow() ;
-
-	// Apply floating dialog blocker styles to the parent document if not already applied.
-	if ( ! window.parent.FCK_BLOCKER_STYLES_APPLIED )
-	{
-		window.parent.FCK_BLOCKER_STYLES_APPLIED = true ;
-	}
-
 	FCK.SetStatus( FCK_STATUS_ACTIVE ) ;
 }
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdebug.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdebug.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdebug.js	(revision 1220)
@@ -27,7 +27,5 @@
 {
 	if ( !this.DebugWindow || this.DebugWindow.closed )
-	{
 		this.DebugWindow = window.open( FCKConfig.BasePath + 'fckdebug.html', 'FCKeditorDebug', 'menubar=no,scrollbars=yes,resizable=yes,location=no,toolbar=no,width=600,height=500', true ) ;
-	}
 
 	return this.DebugWindow ;
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdialog.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdialog.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdialog.js	(revision 1220)
@@ -22,92 +22,200 @@
  */
 
-var FCKDialog =
+var FCKDialog = ( function()
 {
-	_BaseZIndex : FCKConfig.FloatingPanelsZIndex + 1,
-	TopDialog : null,
-	LastSelectionData : null
-} ;
-
-// This method opens a dialog window using the standard dialog template.
-FCKDialog.OpenDialog = function( dialogName, dialogTitle, dialogPage, width, height, customValue, parentWindow, resizable )
-{
-	// Setup the dialog info.
-	var dialogInfo =
+	var topDialog ;
+	var baseZIndex ;
+	var cover ;
+	
+	// The document that holds the dialog.
+	var topWindow = window.parent ;
+	var topDocument = topWindow.document ;
+
+	var getZIndex = function()
 	{
-		Title : dialogTitle,
-		Page : dialogPage,
-		Editor : window,
-		CustomValue : customValue,		// Optional
-		SelectionData : null
+		if ( !baseZIndex )
+			baseZIndex = FCKConfig.FloatingPanelsZIndex + 999 ;
+		return ++baseZIndex ;
 	}
 
-	if ( FCKBrowserInfo.IsIE )
+	// TODO : This logic is not actually working when reducing the window, only
+	// when enlarging it.
+	var resizeHandler = function()
 	{
-		var oSel = FCK.ToolbarSet.CurrentInstance.EditorDocument.selection ;
-		var bInvalidRange = false ;
-
-		if ( !oSel )
-			bInvalidRange = true ;
-
-		var oRange = oSel.createRange() ;
-		if ( !oRange )
-			bInvalidRange = true ;
-		if ( oRange.parentElement && oRange.parentElement().ownerDocument != FCK.ToolbarSet.CurrentInstance.EditorDocument )
-			bInvalidRange = true ;
-		if ( oRange.item && oRange.item(0).ownerDocument != FCK.ToolbarSet.CurrentInstance.EditorDocument )
-			bInvalidRange = true ;
-
-		if ( bInvalidRange )
-			dialogInfo.SelectionData = this.LastSelectionData ;
-		else
-		{
-			dialogInfo.SelectionData = oRange ;
-			this.LastSelectionData = oRange ;
+		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
+			}
+
+			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' ;
+			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 ;
+
+			// Pop the dialog from the dialog stack, and disable dialog mode if the stack is empty.
+			if ( dialog._ParentDialog )
+			{
+				topDialog = dialog._ParentDialog ;
+				dialog._ParentDialog.contentWindow.SetEnabled( true ) ;
+			}
+			else
+			{
+				this.HideMainCover() ;
+				topDialog = null ;
+				this.SelectionData = null ;
+			}
+
+			// Destroy the dialog IFRAME.
+			FCKDomTools.RemoveNode( dialog ) ;
+		},
+
+		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 = doc.createElement( 'iframe' ) ;
+				iframe.src = 'javascript:void(0);' ;
+				iframe.hideFocus = true ;
+				iframe.frameBorder = 0 ;
+				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 ;
 		}
-	}
-
-	var url = FCKConfig.BasePath + 'fckdialog.html' ;
-	var ownerWindow = FCK.ToolbarSet.CurrentInstance.Window.parent ;
-	var ownerDocument = ownerWindow.document ;
-
-	var viewSize = FCKTools.GetViewPaneSize( ownerWindow ) ;
-	var scrollPosition = FCKTools.GetScrollPosition( ownerWindow ) ;
-
-	// Calculate the dialog position, centering it on the screen.
-	var iTop  = Math.max( scrollPosition.Y + ( viewSize.Height - height - 20 ) / 2, 0 ) ;
-	var iLeft = Math.max( scrollPosition.X + ( viewSize.Width - width - 20 )  / 2, 0 ) ;
-
-	var dialog = ownerDocument.createElement( 'iframe' ) ;
-	dialog.frameBorder = 0 ;
-	dialog.allowTransparency = true ;
-	FCKDomTools.SetElementStyles( dialog,
-			{
-				'position' : 'absolute',
-				'top' : iTop + 'px',
-				'left' : iLeft + 'px',
-				'zIndex' : this._BaseZIndex += 100
-			} ) ;
-
-	// Save the dialog info to be used by the dialog page once loaded.
-	dialog._DialogArguments = dialogInfo ;
-
-	ownerDocument.body.appendChild( dialog ) ;
-	FCKDomTools.SetElementStyles( dialog,
-			{
-				'width' : width + 'px',
-				'height' : height + 'px'
-			} ) ;
-
-	// Assigning dialog.src directly does not work in Opera 9.5, need to use a timeout trick
-	setTimeout( function()
-		{
-			dialog.src = url ;
-		}, 0 ) ;
-
-	var oWindow = dialog.contentWindow ;
-	oWindow.focus() ;
-
-	// Keep record of the dialog's parent/child relationships.
-	dialog._ParentDialog = this.TopDialog ;
-	this.TopDialog = dialog ;
-}
+	} ;
+} )() ;
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdomtools.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdomtools.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdomtools.js	(revision 1220)
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fcktools_gecko.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fcktools_gecko.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fcktools_gecko.js	(revision 1220)
@@ -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).
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/common/fck_dialog_common.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/common/fck_dialog_common.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/common/fck_dialog_common.js	(revision 1220)
@@ -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/branches/features/floating_dialog/editor/dialog/fck_anchor.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_anchor.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_anchor.html	(revision 1220)
@@ -30,16 +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 ;
-
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-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.GetSelectedElement() ;
+
 var oAnchor ;
 
@@ -72,4 +72,6 @@
 	window.parent.SetOkButton( true ) ;
 	window.parent.SetAutoSize( true ) ;
+
+	SelectField( 'txtName' ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_button.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_button.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_button.html	(revision 1220)
@@ -30,12 +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 ;
 
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.GetSelectedElement() ;
 
 window.onload = function()
@@ -55,6 +54,6 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_checkbox.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_checkbox.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_checkbox.html	(revision 1220)
@@ -30,12 +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 ;
 
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.GetSelectedElement() ;
 
 window.onload = function()
@@ -53,6 +52,6 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_flash/fck_flash.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_flash/fck_flash.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_flash/fck_flash.js	(revision 1220)
@@ -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,7 +48,5 @@
 
 // Get the selected flash embed (if available).
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oFakeImage = FCK.Selection.GetSelectedElement() ;
+var oFakeImage = dialog.GetSelectedElement() ;
 var oEmbed ;
 
@@ -75,8 +74,8 @@
 		GetE('frmUpload').action = FCKConfig.FlashUploadURL ;
 
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetAutoSize( true ) ;
 
 	// Activate the "OK" button.
-	window.parent.SetOkButton( true ) ;
+	dialog.SetOkButton( true ) ;
 }
 
@@ -117,5 +116,5 @@
 	if ( GetE('txtUrl').value.length == 0 )
 	{
-		window.parent.SetSelectedTab( 'Info' ) ;
+		dialog.SetSelectedTab( 'Info' ) ;
 		GetE('txtUrl').focus() ;
 
@@ -230,5 +229,5 @@
 	UpdatePreview() ;
 
-	window.parent.SetSelectedTab( 'Info' ) ;
+	dialog.SetSelectedTab( 'Info' ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_form.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_form.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_form.html	(revision 1220)
@@ -30,12 +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 ;
 
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oActiveEl = oEditor.FCKSelection.MoveToAncestorNode( 'FORM' ) ;
+var oActiveEl = dialog.GetSelection().MoveToAncestorNode( 'FORM' ) ;
 
 window.onload = function()
@@ -53,6 +52,6 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_hiddenfield.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_hiddenfield.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_hiddenfield.html	(revision 1220)
@@ -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,7 +39,5 @@
 
 // Get the selected flash embed (if available).
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oFakeImage = FCK.Selection.GetSelectedElement() ;
+var oFakeImage = dialog.GetSelectedElement() ;
 var oActiveEl ;
 
@@ -61,6 +61,6 @@
 	}
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_image/fck_image.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_image/fck_image.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_image/fck_image.js	(revision 1220)
@@ -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,7 +55,5 @@
 
 // Get the selected image (if available).
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oImage = FCK.Selection.GetSelectedElement() ;
+var oImage = dialog.GetSelectedElement() ;
 
 if ( oImage && oImage.tagName != 'IMG' && !( oImage.tagName == 'INPUT' && oImage.type == 'image' ) )
@@ -62,5 +61,5 @@
 
 // Get the active link.
-var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;
+var oLink = dialog.GetSelection().MoveToAncestorNode( 'A' ) ;
 
 var oImageOriginal ;
@@ -114,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' ) ;
 }
 
@@ -200,5 +201,5 @@
 	if ( GetE('txtUrl').value.length == 0 )
 	{
-		window.parent.SetSelectedTab( 'Info' ) ;
+		dialog.SetSelectedTab( 'Info' ) ;
 		GetE('txtUrl').focus() ;
 
@@ -249,6 +250,6 @@
 		else			// Creating a new link.
 		{
-			if ( window.parent.dialogArguments.SelectionData )
-				window.parent.dialogArguments.SelectionData.select() ;
+			dialog.EnsureSelection() ;
+
 			if ( !bHasImage )
 				oEditor.FCKSelection.SelectNode( oImage ) ;
@@ -438,5 +439,5 @@
 	}
 
-	window.parent.SetSelectedTab( 'Info' ) ;
+	dialog.SetSelectedTab( 'Info' ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_link/fck_link.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_link/fck_link.js	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_link/fck_link.js	(revision 1220)
@@ -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,7 +127,5 @@
 
 // oLink: The actual selected link in the editor.
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;
+var oLink = dialog.GetSelection().MoveToAncestorNode( 'A' ) ;
 if ( oLink )
 	FCK.Selection.SelectNode( oLink ) ;
@@ -159,5 +159,5 @@
 
 	// Activate the "OK" button.
-	window.parent.SetOkButton( true ) ;
+	dialog.SetOkButton( true ) ;
 }
 
@@ -341,14 +341,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 ) ;
 }
 
@@ -374,5 +374,5 @@
 
 	if ( targetType == 'popup' )
-		window.parent.SetAutoSize( true ) ;
+		dialog.SetAutoSize( true ) ;
 }
 
@@ -623,6 +623,5 @@
 
 	// Select the (first) link.
-	if ( window.parent.dialogArguments.SelectionData )
-		window.parent.dialogArguments.SelectionData.select() ;
+	dialog.EnsureSelection() ;
 	oEditor.FCKSelection.SelectNode( aLinks[0] );
 
@@ -639,5 +638,5 @@
 	document.getElementById('txtUrl').value = url ;
 	OnUrlChange() ;
-	window.parent.SetSelectedTab( 'Info' ) ;
+	dialog.SetSelectedTab( 'Info' ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_listprop.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_listprop.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_listprop.html	(revision 1220)
@@ -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,7 +37,5 @@
 var sListType = ( location.search == '?OL' ? 'OL' : 'UL' ) ;
 
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oActiveEl = oEditor.FCKSelection.MoveToAncestorNode( sListType ) ;
+var oActiveEl = dialog.GetSelection().MoveToAncestorNode( sListType ) ;
 var oActiveSel ;
 
@@ -66,6 +65,6 @@
 	}
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_paste.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_paste.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_paste.html	(revision 1220)
@@ -139,6 +139,5 @@
 		var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
 		var oDoc = oEditor.FCK.EditorDocument ;
-		if ( window.parent.dialogArguments.SelectionData )
-			window.parent.dialogArguments.SelectionData.select() ;
+		dialog.EnsureSelection() ;
 		range.MoveToSelection() ;
 		range.DeleteContents() ;
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_radiobutton.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_radiobutton.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_radiobutton.html	(revision 1220)
@@ -30,12 +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 ;
 
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.GetSelectedElement() ;
 
 window.onload = function()
@@ -53,6 +52,6 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html	(revision 1220)
@@ -30,10 +30,12 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
+var dialogArguments = dialog.dialogArguments ;
+
 var FCKLang = oEditor.FCKLang ;
-var dialogArguments = parent.dialogArguments ;
-
-window.parent.AddTab( 'Find', FCKLang.DlgFindTitle ) ;
-window.parent.AddTab( 'Replace', FCKLang.DlgReplaceTitle ) ;
+
+dialog.AddTab( 'Find', FCKLang.DlgFindTitle ) ;
+dialog.AddTab( 'Replace', FCKLang.DlgReplaceTitle ) ;
 var idMap = {} ;
 
@@ -47,5 +49,5 @@
 
 	if ( tabCode == 'Replace' )
-		window.parent.SetAutoSize( true ) ;
+		dialog.SetAutoSize( true ) ;
 }
 
@@ -66,9 +68,9 @@
 	if ( dialogArguments.CustomValue == 'Find' )
 	{
-		window.parent.SetSelectedTab( 'Find' ) ;
-		window.parent.SetAutoSize( true ) ;
+		dialog.SetSelectedTab( 'Find' ) ;
+		dialog.SetAutoSize( true ) ;
 	}
 	else
-		window.parent.SetSelectedTab( 'Replace' ) ;
+		dialog.SetSelectedTab( 'Replace' ) ;
 
 }
@@ -86,6 +88,5 @@
 	var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
 
-	if ( window.parent.dialogArguments.SelectionData )
-		window.parent.dialogArguments.SelectionData.select() ;
+	dialog.EnsureSelection() ;
 	range.MoveToSelection() ;
 	return range.CreateBookmark2() ;
@@ -373,6 +374,5 @@
 {
 	var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-	if ( window.parent.dialogArguments.SelectionData )
-		window.parent.dialogArguments.SelectionData.select() ;
+	dialog.EnsureSelection() ;
 	range.MoveToSelection() ;
 	range.Collapse( false ) ;
@@ -386,6 +386,5 @@
 {
 	var selection = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-	if ( window.parent.dialogArguments.SelectionData )
-		window.parent.dialogArguments.SelectionData.select() ;
+	dialog.EnsureSelection() ;
 	selection.MoveToSelection() ;
 
@@ -414,6 +413,5 @@
 	while ( _Find() )
 	{
-		if ( window.parent.dialogArguments.SelectionData )
-			window.parent.dialogArguments.SelectionData.select() ;
+		dialog.EnsureSelection() ;
 		range.MoveToSelection() ;
 		range.DeleteContents() ;
@@ -425,5 +423,5 @@
 	if ( replaceCount == 0 )
 		alert( FCKLang.DlgFindNotFoundMsg ) ;
-	window.parent.Cancel() ;
+	dialog.Cancel() ;
 }
 	</script>
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_select.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_select.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_select.html	(revision 1220)
@@ -31,12 +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 ;
 
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.GetSelectedElement() ;
 
 var oListText ;
@@ -71,6 +70,6 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_smiley.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_smiley.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_smiley.html	(revision 1220)
@@ -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,11 +45,11 @@
 	oEditor.FCKLanguageManager.TranslatePage(document) ;
 
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
 function InsertSmiley( url )
 {
-	if ( parent.dialogArguments.SelectionData )
-		parent.dialogArguments.SelectionData.select() ;
+	dialog.EnsureSelection() ;
+
 	oEditor.FCKUndo.SaveUndoStep() ;
 
@@ -62,5 +63,5 @@
 	document.body.innerHTML = '' ;
 
-	window.parent.Cancel() ;
+	dialog.Cancel() ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_table.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_table.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_table.html	(revision 1220)
@@ -30,6 +30,7 @@
 	<script type="text/javascript">
 
-var oEditor = window.parent.InnerDialogLoaded() ;
-var dialogArguments = window.parent.dialogArguments ;
+var dialog	= window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
+var dialogArguments = dialog.dialogArguments ;
 
 // Gets the document DOM
@@ -38,7 +39,5 @@
 // Gets the table if there is one selected.
 var table ;
-if ( dialogArguments.SelectionData )
-	dialogArguments.SelectionData.select() ;
-var e = oEditor.FCKSelection.GetSelectedElement() ;
+var e = dialog.GetSelectedElement() ;
 
 if ( ( !e && document.location.search.substr(1) == 'Parent' ) || ( e && e.tagName != 'TABLE' ) )
@@ -94,6 +93,6 @@
 	}
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_tablecell.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_tablecell.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_tablecell.html	(revision 1220)
@@ -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,6 +37,5 @@
 
 // Array of selected Cells
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
+dialog.EnsureSelection() ;
 var aCells = oEditor.FCKTableHandler.GetSelectedCells() ;
 
@@ -47,6 +47,6 @@
 	SetStartupValue() ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textarea.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textarea.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textarea.html	(revision 1220)
@@ -30,12 +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 ;
 
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.GetSelectedElement() ;
 
 window.onload = function()
@@ -53,6 +52,6 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textfield.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textfield.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textfield.html	(revision 1220)
@@ -30,12 +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 ;
 
-if ( window.parent.dialogArguments.SelectionData )
-	window.parent.dialogArguments.SelectionData.select() ;
-var oActiveEl = oEditor.FCKSelection.GetSelectedElement() ;
+var oActiveEl = dialog.GetSelectedElement() ;
 
 window.onload = function()
@@ -57,6 +56,6 @@
 		oActiveEl = null ;
 
-	window.parent.SetOkButton( true ) ;
-	window.parent.SetAutoSize( true ) ;
+	dialog.SetOkButton( true ) ;
+	dialog.SetAutoSize( true ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html	(revision 1220)
@@ -24,4 +24,5 @@
 <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" />
@@ -33,8 +34,13 @@
 var editor		= args.Editor ;
 var eventId		= Math.random() ;
+
+var FCK				= editor.FCK ;
 var FCKTools		= editor.FCKTools ;
 var FCKDomTools		= editor.FCKDomTools ;
 var FCKDialog		= editor.FCKDialog ;
-var FCK			= editor.FCK ;
+var FCKBrowserInfo	= editor.FCKBrowserInfo ;
+var FCKConfig		= editor.FCKConfig ;
+
+window.focus() ;
 
 // Automatically detect the correct document.domain (#123).
@@ -66,7 +72,4 @@
 })() ;
 
-var FCKBrowserInfo	= editor.FCKBrowserInfo ;
-var FCKConfig		= editor.FCKConfig ;
-
 // Sets the Skin CSS
 document.write( '<link href="' + FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
@@ -85,30 +88,21 @@
 }
 
-var sTitle = args.Title ;
-document.write( '<title>' + sTitle + '<\/title>' ) ;
-
 function Init()
 {
+	// Start the throbber timer.
+	Throbber.Show( 1000 ) ;
+
 	RefreshContainerSize() ;
 	LoadInnerDialog() ;
-	ShowThrobberTimer = setTimeout( ShowThrobber, 1000 ) ;
+
+	FCKTools.DisableSelection( document.body ) ;
 
 	var titleElement = document.getElementById( 'TitleArea' ) ;
 	titleElement.onmousedown = DragMouseDownHandler ;
 
-	if ( FCKBrowserInfo.IsIE )
-		titleElement.setAttribute( 'unselectable', 'on' ) ;
-	else if ( FCKBrowserInfo.IsGecko )
-		titleElement.style.MozUserSelect = 'none' ;
-	else if ( FCKBrowserInfo.IsSafari )
-		titleElement.style.KhtmlUserSelect = 'none' ;
-	else
-		titleElement.style.userSelect = 'none' ;
 	RegisterDragHandlers( window ) ;
 	RegisterDragHandlers( window.parent ) ;
 
-	if ( !frameElement._ParentDialog )
-		FCK.ToolbarSet.CurrentInstance.SetDialogMode( true ) ;
-	else
+	if ( frameElement._ParentDialog )
 	{
 		frameElement._ParentDialog.contentWindow.SetEnabled( false ) ;
@@ -147,5 +141,6 @@
 	if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
 	{
-		var blockerFrame = FCK.ToolbarSet.CurrentInstance.BackgroundBlocker.firstChild ;
+		var blockerFrame = FCKDialog.GetCover().firstChild ;
+
 		if ( blockerFrame._Loaded )
 			RegisterDragHandlers( blockerFrame.contentWindow ) ;
@@ -156,4 +151,5 @@
 				if ( this.readyState != 'complete' )
 					return ;
+
 				RegisterDragHandlers( this.contentWindow ) ;
 				this._Loaded = true ;
@@ -170,30 +166,7 @@
 	// First of all, translate the dialog box contents.
 	editor.FCKLanguageManager.TranslatePage( document ) ;
-	document.getElementById( 'FrameCell' ).innerHTML = '<iframe id="frmMain" src="' + args.Page + '" name="frmMain" frameborder="0" width="100%" scrolling="auto" style="background-color: white;"></iframe>' ;
-}
-
-function ShowThrobber()
-{
-	var throbberParent = document.getElementById( 'throbberBlock' ) ;
-	var frm = document.getElementById( 'frmMain' ) ;
-	var html = '<img src="%%" width="28" height="28" border="0" />'.replace( '%%', FCKConfig.SkinPath + 'images/loading.gif' ) ;
-	throbberParent.innerHTML = html ;
-
-	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) + 'px' ;
-	throbberParent.style.top = parseInt(y) + 'px' ;
-
-	ShowThrobberTimer = null ;
-}
-
-function HideThrobber()
-{
-	if ( ShowThrobberTimer )
-		clearTimeout( ShowThrobberTimer ) ;
-	var throbberParent = document.getElementById( 'throbberBlock' ) ;
-	if ( throbberParent )
-		throbberParent.parentNode.removeChild( throbberParent ) ;
+	
+	// Create the IFRAME that holds the dialog contents.
+	document.getElementById( 'FrameCell' ).innerHTML = '<iframe id="frmMain" src="' + args.Page + '" name="frmMain" frameborder="0" width="100%" scrolling="auto" style="background-color: transparent;" allowtransparency="true"></iframe>' ;
 }
 
@@ -204,20 +177,24 @@
 		return ;
 
-	HideThrobber() ;
-
-	var oInnerDoc = document.getElementById('frmMain').contentWindow.document ;
+	Throbber.Hide() ;
+
+	var innerWindow = document.getElementById('frmMain').contentWindow ;
+	var innerDoc = innerWindow.document ;
 
 	// Set the language direction.
-	oInnerDoc.dir = editor.FCKLang.Dir ;
+	innerDoc.dir = editor.FCKLang.Dir ;
 
 	// Sets the Skin CSS.
-	oInnerDoc.write( '<link href="' + FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
-
-	SetOnKeyDown( oInnerDoc ) ;
-	DisableContextMenu( oInnerDoc ) ;
+	innerDoc.write( '<link href="' + FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
+
+	SetOnKeyDown( innerDoc ) ;
+	DisableContextMenu( innerDoc ) ;
 
 	RefreshContainerSize();
 
 	RegisterDragHandlers( document.getElementById('frmMain').contentWindow ) ;
+	
+	innerWindow.focus() ;
+
 	return editor ;
 }
@@ -241,6 +218,6 @@
 	var innerWidth = dialogFrame.offsetWidth ;
 	var innerHeight = dialogFrame.offsetHeight ;
-	document.getElementById( 'contents' ).style.width = ( innerWidth - 32 ) + 'px' ; // 32 pixels for left and right shadow
-	document.getElementById( 'contents' ).style.height = (innerHeight - 22 ) + 'px' ; // 22 pixels for top and bottom shadow
+//	document.getElementById( 'contents' ).style.width = ( innerWidth - 32 ) + 'px' ; // 32 pixels for left and right shadow
+//	document.getElementById( 'contents' ).style.height = (innerHeight - 22 ) + 'px' ; // 22 pixels for top and bottom shadow
 	var frmMain = document.getElementById( 'frmMain' ) ;
 	if ( frmMain )
@@ -271,13 +248,13 @@
 	if ( bAutoSize )
 	{
-		var oInnerDoc = frmMain.contentWindow.document ;
+		var innerDoc = frmMain.contentWindow.document ;
 
 		var iFrameHeight ;
 		if ( document.all )
-			iFrameHeight = oInnerDoc.body.offsetHeight ;
+			iFrameHeight = innerDoc.body.offsetHeight ;
 		else
 			iFrameHeight = frmMain.contentWindow.innerHeight ;
 
-		var iInnerHeight = oInnerDoc.body.scrollHeight ;
+		var iInnerHeight = innerDoc.body.scrollHeight ;
 		frmMain.style.height = iInnerHeight + 'px' ;
 
@@ -304,6 +281,6 @@
 function Ok()
 {
-	if ( dialogArguments.SelectionData )
-		dialogArguments.SelectionData.select() ;
+	EnsureSelection() ;
+
 	if ( window.frames["frmMain"].Ok && window.frames["frmMain"].Ok() )
 		CloseDialog() ;
@@ -314,6 +291,4 @@
 function Cancel( dontFireChange )
 {
-	if ( dialogArguments.SelectionData )
-		dialogArguments.SelectionData.select() ;
 	return CloseDialog( dontFireChange ) ;
 }
@@ -321,4 +296,6 @@
 function CloseDialog( dontFireChange )
 {
+	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.
@@ -332,19 +309,5 @@
 	}
 
-	FCKDialog._BaseZIndex -= 100 ;
-
-	// Pop the dialog from the dialog stack, and disable dialog mode if the stack is empty.
-	if ( frameElement._ParentDialog == null )
-	{
-		FCK.ToolbarSet.CurrentInstance.SetDialogMode( false ) ;
-		FCKDialog.TopDialog = null ;
-	}
-	else
-	{
-		FCKDialog.TopDialog = frameElement._ParentDialog ;
-		frameElement._ParentDialog.contentWindow.SetEnabled( true ) ;
-	}
-	
-	frameElement.parentNode.removeChild( frameElement ) ;
+	FCKDialog.OnDialogClose( window ) ;
 }
 
@@ -613,4 +576,68 @@
 	}
 }
+
+/**
+ * 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.
+ */
+function EnsureSelection()
+{
+	if ( FCKDialog.SelectionData )
+		FCKDialog.SelectionData.select() ;
+}
+
+/**
+ * Get the FCKSelection object for the editor instance.
+ */
+function GetSelection()
+{
+	EnsureSelection() ;
+	return FCK.Selection ;
+}
+
+/**
+ * Get the selected element in the editing area (for object selections).
+ */
+function GetSelectedElement()
+{
+	var element = GetSelection().GetSelectedElement() ;
+	return element ;
+}
+
+var Throbber =
+{
+	Show : function( waitMilliseconds )
+	{
+		if ( waitMilliseconds && waitMilliseconds > 0 )
+		{
+			this._Timer = FCKTools.SetTimeout( this.Show, waitMilliseconds, this, null, window ) ;
+			return ;
+		}
+
+		var throbberParent = document.getElementById( 'throbberBlock' ) ;
+		throbberParent.innerHTML = '<img src="%%images/loading.gif" width="28" height="28" border="0" />'.replace( '%%', FCKConfig.SkinPath ) ; ;
+
+		var frm = document.getElementById( 'FrameCell' ) ;
+		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) + 'px' ;
+		throbberParent.style.top = parseInt(y) + 'px' ;
+
+		this._Timer = null ;
+	},
+
+	Hide : function()
+	{
+		if ( this._Timer )
+			clearTimeout( this._Timer ) ;
+
+		var throbberParent = document.getElementById( 'throbberBlock' ) ;
+		if ( throbberParent )
+			FCKDomTools.RemoveNode( throbberParent ) ;
+	}
+} ;
+
 		</script>
 	</head>
@@ -621,5 +648,5 @@
 				<td id="TitleArea" class="DialogTitle DialogTitleBorder">
 					<script type="text/javascript">
-document.write( sTitle ) ;
+document.write( args.Title ) ;
 					</script>
 					<div id="closeButton" onclick="Cancel();"></div>
Index: /FCKeditor/branches/features/floating_dialog/editor/fckeditor.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/fckeditor.html	(revision 1219)
+++ /FCKeditor/branches/features/floating_dialog/editor/fckeditor.html	(revision 1220)
@@ -237,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.
