Index: /FCKeditor/branches/features/floating_dialog/_test/manual/fckdialog/test1.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/_test/manual/fckdialog/test1.html	(revision 1254)
+++ /FCKeditor/branches/features/floating_dialog/_test/manual/fckdialog/test1.html	(revision 1255)
@@ -63,5 +63,5 @@
 		{
 			if ( iframes[i].src.search( 'fckdialog.html' ) != -1 )
-				iframes[i].parentNode.removeChild( iframes[i] ) ;
+				iframes[i].contentWindow.CloseDialog() ;
 		}
 	}
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdialog.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdialog.js	(revision 1254)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckdialog.js	(revision 1255)
@@ -24,5 +24,5 @@
 var FCKDialog = ( function()
 {
-//	var topDialog ;
+	var topDialog ;
 	var baseZIndex ;
 	var cover ;
@@ -84,8 +84,6 @@
 		OpenDialog : function( dialogName, dialogTitle, dialogPage, width, height, customValue, parentWindow, resizable )
 		{
-/*
 			if ( !topDialog )
 				this.DisplayMainCover() ;
-*/
 
 			// Setup the dialog info to be passed to the dialog.
@@ -105,5 +103,5 @@
 			// IFRAMEs, like the dialog, so the current selection must be saved to
 			// be restored in the dialog code.
-			if ( FCKBrowserInfo.IsIE /* && !topDialog */ )
+			if ( FCKBrowserInfo.IsIE && !topDialog )
 			{
 				var editorDocument = currentInstance.EditorDocument ;
@@ -160,7 +158,7 @@
 
 			// Keep record of the dialog's parent/child relationships.
-			// dialog._ParentDialog = topDialog ;
-			// topDialog = dialog ;
-		}
+			dialog._ParentDialog = topDialog ;
+			topDialog = dialog ;
+		},
 
 		/**
@@ -168,8 +166,8 @@
 		 * Called when the top dialog is closed.
 		 */
-/*
 		OnDialogClose : function( dialogWindow )
 		{
 			var dialog = dialogWindow.frameElement ;
+			FCKDomTools.RemoveNode( dialog ) ;
 
 			// Pop the dialog from the dialog stack, and disable dialog mode if the stack is empty.
@@ -181,11 +179,8 @@
 			else
 			{
-//				this.HideMainCover() ;
+				this.HideMainCover() ;
 				topDialog = null ;
 				this.SelectionData = null ;
 			}
-
-			// Destroy the dialog IFRAME.
-			FCKDomTools.RemoveNode( dialog ) ;
 		},
 
@@ -225,5 +220,5 @@
 
 			// We need to manually adjust the cover size on resize.
-			// FCKTools.AddEventListener( topWindow, 'resize', resizeHandler ) ;
+			FCKTools.AddEventListener( topWindow, 'resize', resizeHandler ) ;
 			resizeHandler() ;
 
@@ -243,5 +238,4 @@
 			return cover ;
 		}
-*/
 	} ;
 } )() ;
Index: /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html	(revision 1254)
+++ /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html	(revision 1255)
@@ -389,8 +389,54 @@
 }() ;
 
+// 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() ;
+		}
+	} ;
+}() ;
 
 // The business logic of the dialog, dealing with operational things like dialog open/dialog close/enable/disable/etc.
 var Main = function()
 {
+	// Unlock focus manager for non-IE browsers.
+	if ( window.addEventListener )
+		window.addEventListener( 'unload', function(){ Editor().FCKFocusManager.Unlock() ; }, false ) ;
+
+
+	// readystatechange handler for registering drag and drop handlers in cover iframes, defined out here to avoid memory leak.
+	onReadyRegister = function()
+	{
+		if ( this.readyState != 'complete' )
+			return ;
+		DragAndDrop.RegisterHandlers( this.contentWindow ) ;
+	}
+
 	var retval = {
 		// Program entry point.
@@ -423,17 +469,8 @@
 					{
 						var blockerFrame = currentParent.contentWindow.$( 'blocker' ) ;
-						/*
 						if ( blockerFrame.readyState == 'complete' )
-							DnD.RegisterHandlers( blockerFrame.contentWindow ) ;
+							DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;
 						else
-						{
-							blockerFrame.onreadystatechange = function()
-							{
-								if ( this.readyState != 'complete' )
-									return ;
-								DnD.RegisterHandlers( this.contentWindow ) ;
-							}
-						}
-						*/
+							blockerFrame.onreadystatechange = onReadyRegister ;
 						currentParent = ParentDialog( currentParent ) ;
 					}
@@ -451,21 +488,12 @@
 
 			// 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' )
-					DnD.RegisterHandlers( blockerFrame.contentWindow ) ;
+					DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;
 				else
-				{
-					blockerFrame.onreadystatechange = function()
-					{
-						if ( this.readyState != 'complete' )
-							return ;
-						DnD.RegisterHandlers( this.contentWindow ) ;
-					}
-				}
-			}
-			*/
+					blockerFrame.onreadystatechange = onReadyRegister;
+			}
 		},
 
@@ -513,4 +541,69 @@
 
 			return Editor() ;
+		},
+
+		SetOkButton : function( showIt )
+		{
+			$('btnOk').style.visibility = ( showIt ? '' : 'hidden' ) ;
+		},
+
+		Ok : function()
+		{
+			Selection.EnsureSelection() ;
+			
+			var frmMain = window.frames["frmMain"] ;
+
+			if ( frmMain.Ok && frmMain.Ok() )
+				CloseDialog() ;
+			else
+				frmMain.focus() ;
+		},
+
+		Cancel : function( dontFireChange )
+		{
+			return this.CloseDialog( dontFireChange ) ;
+		},
+
+		CloseDialog : function( dontFireChange )
+		{
+			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.
+			$( '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 ) ;
+		},
+
+		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 = $( '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 ) ;
+				}
+			}
 		}
 	}
@@ -524,5 +617,13 @@
 	var APIs = [
 		[ Main, 'InnerDialogLoaded' ],
-		[ Sizer, 'SetAutoSize' ]
+		[ Main, 'SetOkButton' ],
+		[ Main, 'Ok' ],
+		[ Main, 'Cancel' ],
+		[ Main, 'CloseDialog' ],
+		[ Main, 'SetEnabled' ],
+		[ Sizer, 'SetAutoSize' ],
+		[ Selection, 'EnsureSelection' ],
+		[ Selection, 'GetSelection' ],
+		[ Selection, 'GetSelectedElement' ]
 	] ;
 	for ( var i = 0 ; i < APIs.length ; i++ )
@@ -645,5 +746,4 @@
 
 	// If this is the only dialog on screen, enable the background cover.
-	/*
 	if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
 	{
@@ -661,5 +761,4 @@
 		}
 	}
-	*/
 }
 
Index: /FCKeditor/branches/features/floating_dialog/test_results
===================================================================
--- /FCKeditor/branches/features/floating_dialog/test_results	(revision 1254)
+++ /FCKeditor/branches/features/floating_dialog/test_results	(revision 1255)
@@ -10,2 +10,3 @@
 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
+9. Added logic for closing dialogs, cover blocks, disabling and enabling dialogs, and selection handler/No noticeable increase.
