Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_anchor.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_anchor.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_anchor.html	(revision 1328)
@@ -40,5 +40,5 @@
 var oDOM			= FCK.EditorDocument ;
 
-var oFakeImage = dialog.GetSelectedElement() ;
+var oFakeImage = dialog.Selection.GetSelectedElement() ;
 
 var oAnchor ;
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_button.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_button.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_button.html	(revision 1328)
@@ -36,5 +36,5 @@
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = dialog.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 window.onload = function()
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_checkbox.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_checkbox.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_checkbox.html	(revision 1328)
@@ -36,5 +36,5 @@
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = dialog.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 window.onload = function()
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 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_flash/fck_flash.js	(revision 1328)
@@ -48,5 +48,5 @@
 
 // Get the selected flash embed (if available).
-var oFakeImage = dialog.GetSelectedElement() ;
+var oFakeImage = dialog.Selection.GetSelectedElement() ;
 var oEmbed ;
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_form.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_form.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_form.html	(revision 1328)
@@ -36,5 +36,5 @@
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = dialog.GetSelection().MoveToAncestorNode( 'FORM' ) ;
+var oActiveEl = dialog.Selection.GetSelection().MoveToAncestorNode( 'FORM' ) ;
 
 window.onload = function()
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_hiddenfield.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_hiddenfield.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_hiddenfield.html	(revision 1328)
@@ -39,5 +39,5 @@
 
 // Get the selected flash embed (if available).
-var oFakeImage = dialog.GetSelectedElement() ;
+var oFakeImage = dialog.Selection.GetSelectedElement() ;
 var oActiveEl ;
 
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 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_image/fck_image.js	(revision 1328)
@@ -55,5 +55,5 @@
 
 // Get the selected image (if available).
-var oImage = dialog.GetSelectedElement() ;
+var oImage = dialog.Selection.GetSelectedElement() ;
 
 if ( oImage && oImage.tagName != 'IMG' && !( oImage.tagName == 'INPUT' && oImage.type == 'image' ) )
@@ -61,5 +61,5 @@
 
 // Get the active link.
-var oLink = dialog.GetSelection().MoveToAncestorNode( 'A' ) ;
+var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ;
 
 var oImageOriginal ;
@@ -250,5 +250,5 @@
 		else			// Creating a new link.
 		{
-			dialog.EnsureSelection() ;
+			dialog.Selection.EnsureSelection() ;
 
 			if ( !bHasImage )
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 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_link/fck_link.js	(revision 1328)
@@ -127,5 +127,5 @@
 
 // oLink: The actual selected link in the editor.
-var oLink = dialog.GetSelection().MoveToAncestorNode( 'A' ) ;
+var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ;
 if ( oLink )
 	FCK.Selection.SelectNode( oLink ) ;
@@ -624,5 +624,5 @@
 
 	// Select the (first) link.
-	dialog.EnsureSelection() ;
+	dialog.Selection.EnsureSelection() ;
 	oEditor.FCKSelection.SelectNode( aLinks[0] );
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_listprop.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_listprop.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_listprop.html	(revision 1328)
@@ -37,5 +37,5 @@
 var sListType = ( location.search == '?OL' ? 'OL' : 'UL' ) ;
 
-var oActiveEl = dialog.GetSelection().MoveToAncestorNode( sListType ) ;
+var oActiveEl = dialog.Selection.GetSelection().MoveToAncestorNode( sListType ) ;
 var oActiveSel ;
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_paste.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_paste.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_paste.html	(revision 1328)
@@ -139,5 +139,5 @@
 		var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
 		var oDoc = oEditor.FCK.EditorDocument ;
-		dialog.EnsureSelection() ;
+		dialog.Selection.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 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_radiobutton.html	(revision 1328)
@@ -36,5 +36,5 @@
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = dialog.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 window.onload = function()
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html	(revision 1328)
@@ -418,5 +418,5 @@
 	while ( _Find() )
 	{
-		dialog.EnsureSelection() ;
+		dialog.Selection.EnsureSelection() ;
 		GlobalRange.DeleteContents() ;
 		GlobalRange.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_select.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_select.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_select.html	(revision 1328)
@@ -37,5 +37,5 @@
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = dialog.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 var oListText ;
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_smiley.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_smiley.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_smiley.html	(revision 1328)
@@ -50,5 +50,5 @@
 function InsertSmiley( url )
 {
-	dialog.EnsureSelection() ;
+	dialog.Selection.EnsureSelection() ;
 
 	oEditor.FCKUndo.SaveUndoStep() ;
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_specialchar.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_specialchar.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_specialchar.html	(revision 1328)
@@ -44,5 +44,5 @@
 {
 	oEditor.FCKUndo.SaveUndoStep() ;
-	parent.EnsureSelection() ;
+	parent.Selection.EnsureSelection() ;
 	oEditor.FCK.InsertHtml( charValue || "" ) ;
 	window.parent.Cancel() ;
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_table.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_table.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_table.html	(revision 1328)
@@ -39,5 +39,5 @@
 // Gets the table if there is one selected.
 var table ;
-var e = dialog.GetSelectedElement() ;
+var e = dialog.Selection.GetSelectedElement() ;
 
 if ( ( !e && document.location.search.substr(1) == 'Parent' ) || ( e && e.tagName != 'TABLE' ) )
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_tablecell.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_tablecell.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_tablecell.html	(revision 1328)
@@ -37,5 +37,5 @@
 
 // Array of selected Cells
-dialog.EnsureSelection() ;
+dialog.Selection.EnsureSelection() ;
 var aCells = oEditor.FCKTableHandler.GetSelectedCells() ;
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textarea.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textarea.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textarea.html	(revision 1328)
@@ -36,5 +36,5 @@
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = dialog.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 window.onload = function()
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textfield.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textfield.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_textfield.html	(revision 1328)
@@ -36,5 +36,5 @@
 var oDOM = oEditor.FCK.EditorDocument ;
 
-var oActiveEl = dialog.GetSelectedElement() ;
+var oActiveEl = dialog.Selection.GetSelectedElement() ;
 
 window.onload = function()
Index: /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html	(revision 1327)
+++ /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html	(revision 1328)
@@ -206,4 +206,5 @@
 	}
 
+	window.SetAutoSize = FCKTools.Hitch( retval, 'SetAutoSize' );
 	return retval ;
 }() ;
@@ -444,71 +445,69 @@
 	}
 
-	return {
-		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 ) ;
-		},
-
-		SetSelectedTab : setSelectedTab,
-
-		SetTabVisibility : function( tabCode, isVisible )
-		{
-			var oTab = $( oTabs[ tabCode ] ) ;
-			oTab.style.display = isVisible ? '' : 'none' ;
-
-			if ( ! isVisible && oTab.className == 'DialogTabSelected' )
-			{
-				for ( var sCode in oTabs )
+	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' )
 				{
-					if ( $( oTabs[sCode] ).style.display != 'none' )
-					{
-						setSelectedTab( sCode ) ;
-						break ;
-					}
+					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 inside Main() 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).
+// 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()
 {
@@ -516,8 +515,8 @@
 		return ;
 	DragAndDrop.RegisterHandlers( this.contentWindow ) ;
-}
+} ;
 
 // The business logic of the dialog, dealing with operational things like dialog open/dialog close/enable/disable/etc.
-var Main = function()
+(function()
 {
 	// Unlock focus manager for non-IE browsers.
@@ -528,5 +527,4 @@
 		window.addEventListener( 'unload', function(){ editorRef.FCKFocusManager.Unlock() ; }, false ) ;
 	}
-
 
 	var setOnKeyDown = function( targetDocument )
@@ -550,5 +548,5 @@
 			return true ;
 		}
-	}
+	} ;
 
 	var contextMenuBlocker = function( e )
@@ -557,5 +555,5 @@
 		if ( ! ( ( sTagName == "INPUT" && e.target.type == "text" ) || sTagName == "TEXTAREA" ) )
 			e.preventDefault() ;
-	}
+	} ;
 
 	var disableContextMenu = function( targetDocument )
@@ -563,205 +561,181 @@
 		if ( FCKBrowserInfo.IsIE ) return ;
 		targetDocument.addEventListener( 'contextmenu', contextMenuBlocker, true ) ;
-	}
-
-	return {
-		// Program entry point.
-		Init : function()
-		{
-			// Start the throbber timer.
-			Throbber.Show( 1000 ) ;
-
-			Sizer.RefreshContainerSize() ;
-			this.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 )
+	} ;
+
+	// 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 currentParent = ParentDialog() ;
-					while ( currentParent )
-					{
-						var blockerFrame = currentParent.contentWindow.$( 'blocker' ) ;
-						if ( blockerFrame.readyState == 'complete' )
-							DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;
-						else
-							blockerFrame.onreadystatechange = onReadyRegister ;
-						currentParent = ParentDialog( currentParent ) ;
-					}
+					var blockerFrame = currentParent.contentWindow.$( 'blocker' ) ;
+					if ( blockerFrame.readyState == 'complete' )
+						DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;
+					else
+						blockerFrame.onreadystatechange = onReadyRegister ;
+					currentParent = ParentDialog( currentParent ) ;
 				}
-				else
+			}
+			else
+			{
+				var currentParent = ParentDialog() ;
+				while ( currentParent )
 				{
-					var currentParent = ParentDialog() ;
-					while ( currentParent )
-					{
-						DragAndDrop.RegisterHandlers( currentParent.contentWindow ) ;
-						currentParent = ParentDialog( 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 ) ;
-		},
-
-		LoadInnerDialog : function()
-		{
-			if ( window.onresize )
-				window.onresize() ;
-
-			// First of all, translate the dialog box contents.
-			Editor().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>' ;
-		},
+		}
+
+		// 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.
+		Editor().FCKLanguageManager.TranslatePage( document ) ;
 		
-		InnerDialogLoaded : function()
-		{
-			// If the dialog has been closed before the iframe is loaded, do nothing.
-			if ( !frameElement.parentNode )
-				return ;
-
-			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 = Editor().FCKLang.Dir ;
-
-			// 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 Editor() ;
-		},
-
-		SetOkButton : function( showIt )
-		{
-			$('btnOk').style.visibility = ( showIt ? '' : 'hidden' ) ;
-		},
-
-		Ok : function()
-		{
-			Selection.EnsureSelection() ;
-			
-			var frmMain = window.frames["frmMain"] ;
-
-			if ( frmMain.Ok && frmMain.Ok() )
-				CloseDialog() ;
+		// 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 ;
+
+		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 = Editor().FCKLang.Dir ;
+
+		// 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 Editor() ;
+	} ;
+
+	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 )
+	{
+		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 ) ;
+	} ;
+
+	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
-				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 ) ;
-				}
-			}
-		}
-	}
-}() ;
-
-// Export some packaged functions for use in the inner dialog code.
-(function()
-{	
-	var APIs = [
-		[ Main, 'InnerDialogLoaded' ],
-		[ Main, 'SetOkButton' ],
-		[ Main, 'Ok' ],
-		[ Main, 'Cancel' ],
-		[ Main, 'CloseDialog' ],
-		[ Main, 'SetEnabled' ],
-		[ Sizer, 'SetAutoSize' ],
-		[ Selection, 'EnsureSelection' ],
-		[ Selection, 'GetSelection' ],
-		[ Selection, 'GetSelectedElement' ],
-		[ Tabs, 'AddTab' ],
-		[ Tabs, 'SetSelectedTab' ],
-		[ Tabs, 'SetTabVisibility' ]
-	] ;
-	for ( var i = 0 ; i < APIs.length ; i++ )
-		window[APIs[i][1]] = FCKTools.Hitch( APIs[i][0], APIs[i][1] ) ;
+			{
+				var blocker = $( 'blocker' ) ;
+				if ( blocker && blocker.parentNode )
+					blocker.parentNode.removeChild( blocker ) ;
+			}
+		}
+	} ;
 })() ;
 		</script>
 	</head>
-	<body onload="Main.Init();" class="DialogBody">
+	<body onload="Init();" class="DialogBody">
 		<div class="contents" id="contents">
 			<div id="header">
