Index: /FCKeditor/branches/features/floating_dialog/_whatsnew.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/_whatsnew.html	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/_whatsnew.html	(revision 1229)
@@ -60,4 +60,8 @@
 		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1643">#1643</a>] Resolved
 			several "strict warning" messages in Firefox when running FCKeditor.</li>
+		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1603">#1603</a>] Certain
+			specific markup was making FCKeditor entering in a loop, blocking its execution.</li>
+		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1664">#1664</a>] The ENTER
+			key will not any more swap the order of the tags when hit at the end of paragraphs.</li>
 	</ul>
 	<p>
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/commandclasses/fcktextcolorcommand.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/commandclasses/fcktextcolorcommand.js	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/commandclasses/fcktextcolorcommand.js	(revision 1229)
@@ -107,5 +107,5 @@
 	this.className = 'ColorDeselected' ;
 	command._Panel.Hide() ;
-	FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, FCKTools.Hitch(command, 'SetColor') ) ;
+	FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, FCKTools.Hitch(command, 'SetColor') ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckcommands.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckcommands.js	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fckcommands.js	(revision 1229)
@@ -48,24 +48,24 @@
 		case 'RemoveFormat'	: oCommand = new FCKRemoveFormatCommand() ; break ;
 
-		case 'DocProps'		: oCommand = new FCKDialogCommand( 'DocProps'	, FCKLang.DocProps				, 'dialog/fck_docprops.html'	, 400, 390, FCKCommands.GetFullPageState ) ; break ;
+		case 'DocProps'		: oCommand = new FCKDialogCommand( 'DocProps'	, FCKLang.DocProps				, 'dialog/fck_docprops.html'	, 400, 380, FCKCommands.GetFullPageState ) ; break ;
 		case 'Templates'	: oCommand = new FCKDialogCommand( 'Templates'	, FCKLang.DlgTemplatesTitle		, 'dialog/fck_template.html'	, 380, 450 ) ; break ;
-		case 'Link'			: oCommand = new FCKDialogCommand( 'Link'		, FCKLang.DlgLnkWindowTitle		, 'dialog/fck_link.html'		, 400, 330 ) ; break ;
+		case 'Link'			: oCommand = new FCKDialogCommand( 'Link'		, FCKLang.DlgLnkWindowTitle		, 'dialog/fck_link.html'		, 400, 300 ) ; break ;
 		case 'Unlink'		: oCommand = new FCKUnlinkCommand() ; break ;
-		case 'Anchor'		: oCommand = new FCKDialogCommand( 'Anchor'		, FCKLang.DlgAnchorTitle		, 'dialog/fck_anchor.html'		, 370, 170 ) ; break ;
+		case 'Anchor'		: oCommand = new FCKDialogCommand( 'Anchor'		, FCKLang.DlgAnchorTitle		, 'dialog/fck_anchor.html'		, 370, 160 ) ; break ;
 		case 'AnchorDelete'	: oCommand = new FCKAnchorDeleteCommand() ; break ;
-		case 'BulletedList'	: oCommand = new FCKDialogCommand( 'BulletedList', FCKLang.BulletedListProp		, 'dialog/fck_listprop.html?UL'	, 370, 170 ) ; break ;
-		case 'NumberedList'	: oCommand = new FCKDialogCommand( 'NumberedList', FCKLang.NumberedListProp		, 'dialog/fck_listprop.html?OL'	, 370, 170 ) ; break ;
-		case 'About'		: oCommand = new FCKDialogCommand( 'About'		, FCKLang.About					, 'dialog/fck_about.html'		, 400, 330 ) ; break ;
+		case 'BulletedList'	: oCommand = new FCKDialogCommand( 'BulletedList', FCKLang.BulletedListProp		, 'dialog/fck_listprop.html?UL'	, 370, 160 ) ; break ;
+		case 'NumberedList'	: oCommand = new FCKDialogCommand( 'NumberedList', FCKLang.NumberedListProp		, 'dialog/fck_listprop.html?OL'	, 370, 160 ) ; break ;
+		case 'About'		: oCommand = new FCKDialogCommand( 'About'		, FCKLang.About					, 'dialog/fck_about.html'		, 400, 310 ) ; break ;
 
-		case 'Find'			: oCommand = new FCKDialogCommand( 'Find'		, FCKLang.DlgFindAndReplaceTitle			, 'dialog/fck_replace.html'		, 340, 250, null, null, 'Find' ) ; break ;
-		case 'Replace'		: oCommand = new FCKDialogCommand( 'Replace'	, FCKLang.DlgFindAndReplaceTitle		, 'dialog/fck_replace.html'		, 340, 250, null, null, 'Replace' ) ; break ;
+		case 'Find'			: oCommand = new FCKDialogCommand( 'Find'		, FCKLang.DlgFindAndReplaceTitle, 'dialog/fck_replace.html'		, 340, 230, null, null, 'Find' ) ; break ;
+		case 'Replace'		: oCommand = new FCKDialogCommand( 'Replace'	, FCKLang.DlgFindAndReplaceTitle, 'dialog/fck_replace.html'		, 340, 230, null, null, 'Replace' ) ; break ;
 
-		case 'Image'		: oCommand = new FCKDialogCommand( 'Image'		, FCKLang.DlgImgTitle			, 'dialog/fck_image.html'		, 450, 400 ) ; break ;
-		case 'Flash'		: oCommand = new FCKDialogCommand( 'Flash'		, FCKLang.DlgFlashTitle			, 'dialog/fck_flash.html'		, 450, 400 ) ; break ;
-		case 'SpecialChar'	: oCommand = new FCKDialogCommand( 'SpecialChar', FCKLang.DlgSpecialCharTitle	, 'dialog/fck_specialchar.html'	, 400, 280 ) ; break ;
+		case 'Image'		: oCommand = new FCKDialogCommand( 'Image'		, FCKLang.DlgImgTitle			, 'dialog/fck_image.html'		, 450, 390 ) ; break ;
+		case 'Flash'		: oCommand = new FCKDialogCommand( 'Flash'		, FCKLang.DlgFlashTitle			, 'dialog/fck_flash.html'		, 450, 390 ) ; break ;
+		case 'SpecialChar'	: oCommand = new FCKDialogCommand( 'SpecialChar', FCKLang.DlgSpecialCharTitle	, 'dialog/fck_specialchar.html'	, 400, 290 ) ; break ;
 		case 'Smiley'		: oCommand = new FCKDialogCommand( 'Smiley'		, FCKLang.DlgSmileyTitle		, 'dialog/fck_smiley.html'		, FCKConfig.SmileyWindowWidth, FCKConfig.SmileyWindowHeight ) ; break ;
 		case 'Table'		: oCommand = new FCKDialogCommand( 'Table'		, FCKLang.DlgTableTitle			, 'dialog/fck_table.html'		, 480, 250 ) ; break ;
 		case 'TableProp'	: oCommand = new FCKDialogCommand( 'Table'		, FCKLang.DlgTableTitle			, 'dialog/fck_table.html?Parent', 480, 250 ) ; break ;
-		case 'TableCellProp': oCommand = new FCKDialogCommand( 'TableCell'	, FCKLang.DlgCellTitle			, 'dialog/fck_tablecell.html'	, 550, 250 ) ; break ;
+		case 'TableCellProp': oCommand = new FCKDialogCommand( 'TableCell'	, FCKLang.DlgCellTitle			, 'dialog/fck_tablecell.html'	, 550, 240 ) ; break ;
 
 		case 'Style'		: oCommand = new FCKStyleCommand() ; break ;
@@ -113,13 +113,13 @@
 		case 'TableDelete'				: oCommand = new FCKTableCommand('TableDelete') ; break ;
 
-		case 'Form'			: oCommand = new FCKDialogCommand( 'Form'		, FCKLang.Form			, 'dialog/fck_form.html'		, 380, 230 ) ; break ;
-		case 'Checkbox'		: oCommand = new FCKDialogCommand( 'Checkbox'	, FCKLang.Checkbox		, 'dialog/fck_checkbox.html'	, 380, 230 ) ; break ;
-		case 'Radio'		: oCommand = new FCKDialogCommand( 'Radio'		, FCKLang.RadioButton	, 'dialog/fck_radiobutton.html'	, 380, 230 ) ; break ;
-		case 'TextField'	: oCommand = new FCKDialogCommand( 'TextField'	, FCKLang.TextField		, 'dialog/fck_textfield.html'	, 380, 230 ) ; break ;
-		case 'Textarea'		: oCommand = new FCKDialogCommand( 'Textarea'	, FCKLang.Textarea		, 'dialog/fck_textarea.html'	, 380, 230 ) ; break ;
-		case 'HiddenField'	: oCommand = new FCKDialogCommand( 'HiddenField', FCKLang.HiddenField	, 'dialog/fck_hiddenfield.html'	, 380, 230 ) ; break ;
-		case 'Button'		: oCommand = new FCKDialogCommand( 'Button'		, FCKLang.Button		, 'dialog/fck_button.html'		, 380, 230 ) ; break ;
-		case 'Select'		: oCommand = new FCKDialogCommand( 'Select'		, FCKLang.SelectionField, 'dialog/fck_select.html'		, 400, 380 ) ; break ;
-		case 'ImageButton'	: oCommand = new FCKDialogCommand( 'ImageButton', FCKLang.ImageButton	, 'dialog/fck_image.html?ImageButton', 450, 400 ) ; break ;
+		case 'Form'			: oCommand = new FCKDialogCommand( 'Form'		, FCKLang.Form			, 'dialog/fck_form.html'		, 380, 210 ) ; break ;
+		case 'Checkbox'		: oCommand = new FCKDialogCommand( 'Checkbox'	, FCKLang.Checkbox		, 'dialog/fck_checkbox.html'	, 380, 200 ) ; break ;
+		case 'Radio'		: oCommand = new FCKDialogCommand( 'Radio'		, FCKLang.RadioButton	, 'dialog/fck_radiobutton.html'	, 380, 200 ) ; break ;
+		case 'TextField'	: oCommand = new FCKDialogCommand( 'TextField'	, FCKLang.TextField		, 'dialog/fck_textfield.html'	, 380, 210 ) ; break ;
+		case 'Textarea'		: oCommand = new FCKDialogCommand( 'Textarea'	, FCKLang.Textarea		, 'dialog/fck_textarea.html'	, 380, 210 ) ; break ;
+		case 'HiddenField'	: oCommand = new FCKDialogCommand( 'HiddenField', FCKLang.HiddenField	, 'dialog/fck_hiddenfield.html'	, 380, 190 ) ; break ;
+		case 'Button'		: oCommand = new FCKDialogCommand( 'Button'		, FCKLang.Button		, 'dialog/fck_button.html'		, 380, 210 ) ; break ;
+		case 'Select'		: oCommand = new FCKDialogCommand( 'Select'		, FCKLang.SelectionField, 'dialog/fck_select.html'		, 400, 340 ) ; break ;
+		case 'ImageButton'	: oCommand = new FCKDialogCommand( 'ImageButton', FCKLang.ImageButton	, 'dialog/fck_image.html?ImageButton', 450, 390 ) ; break ;
 
 		case 'SpellCheck'	: oCommand = new FCKSpellCheckCommand() ; break ;
Index: /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fcktools.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fcktools.js	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/internals/fcktools.js	(revision 1229)
@@ -367,6 +367,6 @@
 {
 	// There is no compatMode in Safari, but it seams that it always behave as
-	// CSS1Compat, so let's assume it as the default.
-	return ( 'CSS1Compat' == ( document.compatMode || 'CSS1Compat' ) ) ;
+	// CSS1Compat, so let's assume it as the default for that browser.
+	return ( 'CSS1Compat' == ( document.compatMode || ( FCKBrowserInfo.IsSafari ? 'CSS1Compat' : null ) ) ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_docprops.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_docprops.html	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_docprops.html	(revision 1229)
@@ -375,9 +375,9 @@
 	switch ( wich )
 	{
-		case 'Back'			: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectBackColor, window ) ; return ;
-		case 'ColorText'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectColorText, window ) ; return ;
-		case 'ColorLink'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectColorLink, window ) ; return ;
-		case 'ColorVisited'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectColorVisited, window ) ; return ;
-		case 'ColorActive'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectColorActive, window ) ; return ;
+		case 'Back'			: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, SelectBackColor, window ) ; return ;
+		case 'ColorText'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, SelectColorText, window ) ; return ;
+		case 'ColorLink'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, SelectColorLink, window ) ; return ;
+		case 'ColorVisited'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, SelectColorVisited, window ) ; return ;
+		case 'ColorActive'	: oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, SelectColorActive, window ) ; return ;
 	}
 }
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_tablecell.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_tablecell.html	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_tablecell.html	(revision 1229)
@@ -121,5 +121,5 @@
 function SelectColor( wich )
 {
-	oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', oEditor.FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, wich == 'Back' ? SelectBackColor : SelectBorderColor, window ) ;
+	oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', oEditor.FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, wich == 'Back' ? SelectBackColor : SelectBorderColor, window ) ;
 }
 
Index: /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/editor/fckdialog.html	(revision 1229)
@@ -1,3 +1,3 @@
-﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <!--
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
@@ -99,10 +99,10 @@
 
 	// Make the title area draggable.
-	var titleElement = document.getElementById( 'TitleArea' ) ;
-	titleElement.onmousedown = DragMouseDownHandler ;
+	var titleElement = document.getElementById( 'header' ) ;
+	titleElement.onmousedown = DnD.MouseDownHandler ;
 
 	// Connect mousemove and mouseup events from dialog frame and outer window to dialog dragging logic.
-	RegisterDragHandlers( window ) ;
-	RegisterDragHandlers( window.parent ) ;
+	DnD.RegisterHandlers( window ) ;
+	DnD.RegisterHandlers( window.parent ) ;
 
 	// Disable the previous dialog if it exists.
@@ -117,5 +117,5 @@
 				var blockerFrame = currentParent.contentWindow.document.getElementById( 'blocker' ) ;
 				if ( blockerFrame.readyState == 'complete' )
-					RegisterDragHandlers( blockerFrame.contentWindow ) ;
+					DnD.RegisterHandlers( blockerFrame.contentWindow ) ;
 				else
 				{
@@ -124,5 +124,5 @@
 						if ( this.readyState != 'complete' )
 							return ;
-						RegisterDragHandlers( this.contentWindow ) ;
+						DnD.RegisterHandlers( this.contentWindow ) ;
 					}
 				}
@@ -135,5 +135,5 @@
 			while ( currentParent )
 			{
-				RegisterDragHandlers( currentParent.contentWindow ) ;
+				DnD.RegisterHandlers( currentParent.contentWindow ) ;
 				currentParent = currentParent._ParentDialog ;
 			}
@@ -146,5 +146,5 @@
 		var blockerFrame = FCKDialog.GetCover().firstChild ;
 		if ( blockerFrame.readyState == 'complete' )
-			RegisterDragHandlers( blockerFrame.contentWindow ) ;
+			DnD.RegisterHandlers( blockerFrame.contentWindow ) ;
 		else
 		{
@@ -153,5 +153,5 @@
 				if ( this.readyState != 'complete' )
 					return ;
-				RegisterDragHandlers( this.contentWindow ) ;
+				DnD.RegisterHandlers( this.contentWindow ) ;
 			}
 		}
@@ -168,5 +168,5 @@
 	
 	// 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="visibility: hidden;" allowtransparency="true"></iframe>' ;
+	document.getElementById( 'innerContents' ).innerHTML = '<iframe id="frmMain" src="' + args.Page + '" name="frmMain" frameborder="0" width="100%" height="100%" scrolling="auto" style="visibility: hidden;" allowtransparency="true"></iframe>' ;
 }
 
@@ -197,5 +197,5 @@
 	RefreshContainerSize();
 
-	RegisterDragHandlers( innerWindow ) ;
+	DnD.RegisterHandlers( innerWindow ) ;
 	
 	innerWindow.focus() ;
@@ -220,15 +220,17 @@
 function RefreshContainerSize()
 {
-	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
 	var frmMain = document.getElementById( 'frmMain' ) ;
+	
 	if ( frmMain )
 	{
-		var frmHeight = innerHeight - 22 - 64 ; // 22 pixels for shadow, 64 pixels for title and button rows
-		if ( document.getElementById( 'TabsRow' ).offsetHeight )
-			frmHeight -= 22 ; // 22 pixels for tabs row if it is visible
-		frmMain.style.height = frmHeight + 'px' ;
+		// Get the container size.
+		var height = document.getElementById( 'contents' ).offsetHeight ;
+		
+		// Subtract the size of other elements.
+		height -= document.getElementById( 'TitleArea' ).offsetHeight ;
+		height -= document.getElementById( 'TabsRow' ).offsetHeight ;
+		height -= document.getElementById( 'DialogButtons' ).offsetHeight ;
+		
+		frmMain.style.height = Math.max( height, 0 ) + 'px' ;
 	}
 }
@@ -236,5 +238,5 @@
 // Resize and re-layout the dialog.
 // Triggers the onresize event for the layout logic.
-function ResizeDialog(width, height)
+function ResizeDialog( width, height )
 {
 	FCKDomTools.SetElementStyles( window.frameElement,
@@ -243,53 +245,60 @@
 				'height' : height + 'px'
 			} ) ;
-}
-
-// if bAutoSize is true, automatically fit the dialog size and layout to accomodate the inner iframe's internal height.
-// if bAutoSize is false, then only the layout logic for the dialog decorations is run to accomodate the inner iframe's external height.
+
+	// If the skin have defined a function for resize fixes, call it now.
+	if ( typeof DoResizeFixes == 'function' )
+		DoResizeFixes() ;
+}
+
+// if bAutoSize is true, automatically fit the dialog size and layout to
+// accomodate the inner iframe's internal height.
+// if bAutoSize is false, then only the layout logic for the dialog decorations
+// is run to accomodate the inner iframe's external height.
 function RefreshSize()
 {
-	var frmMain = document.getElementById('frmMain') ;
 	if ( bAutoSize )
 	{
-		var innerDoc = frmMain.contentWindow.document ;
-
-		var iFrameHeight, iFrameWidth ;
-		if ( FCKBrowserInfo.IsIE )
-		{
-			iFrameHeight = innerDoc.documentElement.offsetHeight ;
-			iFrameWidth = innerDoc.documentElement.offsetWidth ;
-		}
-		else
-		{
-			iFrameHeight = frmMain.contentWindow.innerHeight ;
-			iFrameWidth = frmMain.contentWindow.innerWidth ;
-		}
-
-		var iInnerHeight = ( innerDoc.compatMode || 'BackCompat' ) == 'BackCompat' ? 
-			innerDoc.body.scrollHeight : innerDoc.documentElement.scrollHeight ;
-		var iInnerWidth = ( innerDoc.compatMode || 'BackCompat' ) == 'BackCompat' ? 
-			innerDoc.body.scrollWidth : innerDoc.documentElement.scrollWidth ;
-		frmMain.style.height = iInnerHeight + 'px' ;
-		frmMain.style.width = iInnerWidth + 'px' ;
-
-		var iDeltaHeight = Math.max( iInnerHeight - iFrameHeight, 0 ) ;
-		var iDeltaWidth = Math.max( iInnerWidth - iFrameWidth, 0 ) ;
-
-		if ( iDeltaHeight > 0 || iDeltaWidth > 0 )
-			ResizeDialog( dialogFrame.offsetWidth + iDeltaWidth, dialogFrame.offsetHeight + iDeltaHeight ) ;
-	}
+		var frmMain		= document.getElementById('frmMain') ;
+		var innerDoc	= frmMain.contentWindow.document ;
+		var isStrict	= FCKTools.IsStrictMode( innerDoc ) ;
+
+		// Get the size of the frame contents.
+		var innerWidth	= isStrict ? innerDoc.documentElement.scrollWidth : innerDoc.body.scrollWidth ;
+		var innerHeight	= isStrict ? innerDoc.documentElement.scrollHeight : innerDoc.body.scrollHeight ;
+
+		// Get the current frame size.
+		var frameSize = FCKTools.GetViewPaneSize( frmMain.contentWindow ) ;
+		
+		var deltaWidth	= innerWidth - frameSize.Width ;
+		var deltaHeight	= innerHeight - frameSize.Height ;
+
+		// If the contents fits the current size.		
+		if ( deltaWidth <= 0 && deltaHeight <= 0 )
+			return ;
+		
+		var dialogWidth		= dialogFrame.offsetWidth + Math.max( deltaWidth, 0 ) ;
+		var dialogHeight	= dialogFrame.offsetHeight + Math.max( deltaHeight, 0 ) ;
+
+		ResizeDialog( dialogWidth, dialogHeight ) ;
+	}
+
 	RefreshContainerSize() ;
 }
 
-// Kludge for #1316: Safari seems to have a bug with the time when RefreshSize() is executed - it thinks frmMain's innerHeight
-// is 0 if we query the value too soon after the page is loaded in some circumstances.
+// Safari seems to have a bug with the time when RefreshSize() is executed - it
+// thinks frmMain's innerHeight is 0 if we query the value too soon after the
+// page is loaded in some circumstances. (#1316)
+// TODO : Maybe this is not needed anymore after #35.
 if ( FCKBrowserInfo.IsSafari )
 {
-	window.OriginalRefreshSize = RefreshSize ;
-
-	RefreshSize = function()
-	{
-		window.setTimeout( window.OriginalRefreshSize, 1 );
-	}
+	(function()
+	{
+		var originalRefreshSize = RefreshSize ;
+
+		window.RefreshSize = function()
+		{
+			window.setTimeout( originalRefreshSize, 1 ) ;
+		}
+	})() ;
 }
 
@@ -297,9 +306,11 @@
 {
 	EnsureSelection() ;
-
-	if ( window.frames["frmMain"].Ok && window.frames["frmMain"].Ok() )
+	
+	var frmMain = window.frames["frmMain"] ;
+
+	if ( frmMain.Ok && frmMain.Ok() )
 		CloseDialog() ;
 	else
-		window.frames["frmMain"].focus() ;
+		frmMain.focus() ;
 }
 
@@ -396,4 +407,6 @@
 
 	oTabs[ tabCode ] = oDiv ;
+
+	FCKTools.DisableSelection( oDiv ) ;
 }
 
@@ -487,5 +500,5 @@
 function Window_OnClose()
 {
-	CleanUpDragHandlers() ;
+	DnD.CleanUpHandlers() ;
 	editor.FCKFocusManager.Unlock() ;
 }
@@ -494,114 +507,124 @@
 	window.addEventListener( 'unload', Window_OnClose, false ) ;
 
-// drag and move handlers
-LastCoords = null ;
-GetMouseCoordinates = function( evt )
-{
-	var element = evt.srcElement || evt.target ;
-	var doc = FCKTools.GetElementDocument( element ) ;
-	var view = doc.parentWindow || evt.view ;
-	var retval = { 'x': evt.clientX, 'y': evt.clientY };
-
-	if ( view != window.parent )
-	{
-		var offset = FCKTools.GetDocumentPosition( window.parent, doc.documentElement ) ;
-		retval.x += offset.x ;
-		retval.y += offset.y ;
-	}
-
-	return retval ;
-}
-
-DragMouseDownHandler = function( evt )
-{
-	var view = null ;
-	if ( !evt )
-	{
-		view = FCKTools.GetElementDocument( this ).parentWindow ;
-		evt = view.event ;
-	}
-	else
-		view = evt.view ;
-
-	var target = evt.srcElement || evt.target ;
-	if ( target.id == 'closeButton' )
-		return ;
-
-	LastCoords = GetMouseCoordinates( evt ) ;
-
-	if ( evt.preventDefault )
-		evt.preventDefault() ;
-	else
-		evt.returnValue = false ;
-}
-
-DragMouseMoveHandler = function( evt )
-{
-	if ( !window.LastCoords )
-		return ;
-
-	// Debouncing logic for Opera, for preventing the dialog from vibrating during mouse drags.
-	if ( FCKBrowserInfo.IsOpera )
-	{
-		if ( window.LastMoveTimestamp > (new Date()).getTime() - 20 )
+// Drad-and-drop handler.
+var DnD = (function()
+{
+	var registeredWindows = [] ;
+	var lastCoords = null ;
+	
+	var getMouseCoordinates = function( evt )
+	{
+		var element = evt.srcElement || evt.target ;
+		var doc = FCKTools.GetElementDocument( element ) ;
+		var view = doc.parentWindow || evt.view ;
+		var retval = { 'x': evt.clientX, 'y': evt.clientY };
+
+		if ( view != window.parent )
+		{
+			var offset = FCKTools.GetDocumentPosition( window.parent, doc.documentElement ) ;
+			retval.x += offset.x ;
+			retval.y += offset.y ;
+		}
+
+		return retval ;
+	}
+
+	var dragMouseMoveHandler = function( evt )
+	{
+		if ( !lastCoords )
 			return ;
+
+		// Debouncing logic for Opera, for preventing the dialog from vibrating during mouse drags.
+		if ( FCKBrowserInfo.IsOpera )
+		{
+			if ( window.LastMoveTimestamp > (new Date()).getTime() - 20 )
+				return ;
+			else
+				window.LastMoveTimestamp = (new Date()).getTime() ;
+		}
+
+		if ( !evt )
+			evt = FCKTools.GetElementDocument( this ).parentWindow.event ;
+
+		var currentCoords = getMouseCoordinates( evt );
+		var dx = currentCoords.x - lastCoords.x;
+		var dy = currentCoords.y - lastCoords.y;
+		lastCoords = currentCoords;
+
+		var x = parseInt( FCKDomTools.GetCurrentElementStyle( window.parent, frameElement, 'left' ) ) + dx ;
+		var y = parseInt( FCKDomTools.GetCurrentElementStyle( window.parent, frameElement, 'top' ) ) + dy ;
+		FCKDomTools.SetElementStyles( frameElement,
+				{
+				'left' : x + 'px',
+				'top' : y + 'px'
+				} ) ;
+
+		if ( evt.preventDefault )
+			evt.preventDefault() ;
 		else
-			window.LastMoveTimestamp = (new Date()).getTime() ;
-	}
-
-	if ( !evt )
-		evt = FCKTools.GetElementDocument( this ).parentWindow.event ;
-
-	var currentCoords = GetMouseCoordinates( evt );
-	var dx = currentCoords.x - LastCoords.x;
-	var dy = currentCoords.y - LastCoords.y;
-	LastCoords = currentCoords;
-
-	var x = parseInt( FCKDomTools.GetCurrentElementStyle( window.parent, frameElement, 'left' ) ) + dx ;
-	var y = parseInt( FCKDomTools.GetCurrentElementStyle( window.parent, frameElement, 'top' ) ) + dy ;
-	FCKDomTools.SetElementStyles( frameElement,
+			evt.returnValue = false ;
+	}
+
+	var dragMouseUpHandler = function( evt )
+	{
+		if ( !lastCoords )
+			return ;
+		if ( !evt )
+			evt = FCKTools.GetElementDocument( this ).parentWindow.event ;
+		lastCoords = null ;
+	}
+
+	
+	return {
+
+		MouseDownHandler : function( evt )
+		{
+			var view = null ;
+			if ( !evt )
 			{
-			'left' : x + 'px',
-			'top' : y + 'px'
-			} ) ;
-
-	if ( evt.preventDefault )
-		evt.preventDefault() ;
-	else
-		evt.returnValue = false ;
-}
-
-DragMouseUpHandler = function( evt )
-{
-	if ( !window.LastCoords )
-		return ;
-	if ( !evt )
-		evt = FCKTools.GetElementDocument( this ).parentWindow.event ;
-	LastCoords = null ;
-}
-
-var RegisteredWindows = [] ;
-RegisterDragHandlers = function( w )
-{
-	if ( w['_FCKDialogHandlersRegistered_' + eventId] )
-		return ;
-
-	FCKTools.AddEventListener( w.document.documentElement, 'mousemove', DragMouseMoveHandler ) ;
-	FCKTools.AddEventListener( w.document.documentElement, 'mouseup', DragMouseUpHandler ) ;
-	w['_FCKDialogHandlersRegistered_' + eventId] = true ;
-	RegisteredWindows.push( w ) ;
-}
-
-
-CleanUpDragHandlers = function()
-{
-	while ( RegisteredWindows.length > 0 )
-	{
-		var item = RegisteredWindows.shift() ;
-		FCKTools.RemoveEventListener( item.document.documentElement, 'mousemove', DragMouseMoveHandler ) ;
-		FCKTools.RemoveEventListener( item.document.documentElement, 'mouseup', DragMouseMoveHandler ) ;
-		item['_FCKDialogHandlersRegistered_' + eventId] = undefined;
-	}
-}
+				view = FCKTools.GetElementDocument( this ).parentWindow ;
+				evt = view.event ;
+			}
+			else
+				view = evt.view ;
+
+			var target = evt.srcElement || evt.target ;
+			if ( target.id == 'closeButton' || target.className == 'DialogTab' || target.className == 'DialogTabSelected' )
+				return ;
+
+			lastCoords = getMouseCoordinates( evt ) ;
+
+			if ( evt.preventDefault )
+				evt.preventDefault() ;
+			else
+				evt.returnValue = false ;
+		},
+
+		RegisterHandlers : function( w )
+		{
+			if ( w['_FCKDialogHandlersRegistered_' + eventId] )
+				return ;
+
+			var documentElement = w.document.documentElement ;
+
+			FCKTools.AddEventListener( documentElement, 'mousemove', dragMouseMoveHandler ) ;
+			FCKTools.AddEventListener( documentElement, 'mouseup', dragMouseUpHandler ) ;
+			w['_FCKDialogHandlersRegistered_' + eventId] = true ;
+			registeredWindows.push( w ) ;
+		},
+
+		CleanUpHandlers : function()
+		{
+			while ( registeredWindows.length > 0 )
+			{
+				var item = registeredWindows.shift() ;
+				var documentElement = item.document.documentElement ;
+				FCKTools.RemoveEventListener( documentElement, 'mousemove', dragMouseMoveHandler ) ;
+				FCKTools.RemoveEventListener( documentElement, 'mouseup', dragMouseUpHandler ) ;
+				item['_FCKDialogHandlersRegistered_' + eventId] = undefined;
+			}
+		}
+	}
+})() ;
 
 /**
@@ -647,5 +670,5 @@
 		throbberParent.innerHTML = '<img src="%%images/loading.gif" width="28" height="28" border="0" />'.replace( '%%', FCKConfig.SkinPath ) ; ;
 
-		var frm = document.getElementById( 'FrameCell' ) ;
+		var frm = document.getElementById( 'contents' ) ;
 		var frmCoords = FCKTools.GetDocumentPosition( window, frm ) ;
 		var x = frmCoords.x + ( frm.offsetWidth - throbberParent.offsetWidth ) / 2 ;
@@ -672,43 +695,33 @@
 	<body onload="Init();" class="DialogBody">
 		<div class="contents" id="contents">
-		<table height="100%" cellspacing="0" cellpadding="0" border="0" width="100%">
-			<tr>
-				<td id="TitleArea" class="DialogTitle DialogTitleBorder">
+			<div id="header">
+				<div id="TitleArea" class="DialogTitle DialogTitleBorder">
 					<script type="text/javascript">
 document.write( args.Title ) ;
 					</script>
 					<div id="closeButton" onclick="Cancel();"></div>
-				</td>
-			</tr>
-			<tr id="TabsRow" style="DISPLAY: none">
-				<td class="DialogTabArea">
+				</div>
+				<div id="TabsRow" class="DialogTabArea" style="display: none">
 					<table border="0" cellpadding="0" cellspacing="0" width="100%">
-						<tr id="Tabs" onselectstart="return false;">
+						<tr id="Tabs">
 							<td class="DialogTabEmptyArea">&nbsp;</td>
 							<td class="DialogTabEmptyArea" width="100%">&nbsp;</td>
 						</tr>
 					</table>
-				</td>
-			</tr>
-			<tr>
-				<td id="FrameCell" valign="top">
-					&nbsp;
-				</td>
-			</tr>
-			<tr>
-				<td class="DialogButtons" id="DialogButtons">
-					<table border="0" cellpadding="0" cellspacing="0">
-						<tr>
-							<td width="100%">&nbsp;</td>
-							<td nowrap="nowrap">
-								<input id="btnOk" style="VISIBILITY: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" />
-								&nbsp;
-								<input id="btnCancel" type="button" value="Cancel" class="Button" onclick="Cancel();" fckLang="DlgBtnCancel" />
-							</td>
-						</tr>
-					</table>
-				</td>
-			</tr>
-		</table>
+				</div>
+			</div>
+			<div id="innerContents"></div>
+			<div id="DialogButtons" class="DialogButtons">
+				<table border="0" cellpadding="0" cellspacing="0">
+					<tr>
+						<td width="100%">&nbsp;</td>
+						<td nowrap="nowrap">
+							<input id="btnOk" style="VISIBILITY: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" />
+							&nbsp;
+							<input id="btnCancel" type="button" value="Cancel" class="Button" onclick="Cancel();" fckLang="DlgBtnCancel" />
+						</td>
+					</tr>
+				</table>
+			</div>
 		</div>
 		<div class="tl"></div>
Index: /FCKeditor/branches/features/floating_dialog/editor/plugins/placeholder/fckplugin.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/plugins/placeholder/fckplugin.js	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/editor/plugins/placeholder/fckplugin.js	(revision 1229)
@@ -23,5 +23,5 @@
 
 // Register the related command.
-FCKCommands.RegisterCommand( 'Placeholder', new FCKDialogCommand( 'Placeholder', FCKLang.PlaceholderDlgTitle, FCKPlugins.Items['placeholder'].Path + 'fck_placeholder.html', 340, 170 ) ) ;
+FCKCommands.RegisterCommand( 'Placeholder', new FCKDialogCommand( 'Placeholder', FCKLang.PlaceholderDlgTitle, FCKPlugins.Items['placeholder'].Path + 'fck_placeholder.html', 340, 160 ) ) ;
 
 // Create the "Plaholder" toolbar button.
Index: /FCKeditor/branches/features/floating_dialog/editor/skins/default/fck_dialog.css
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/skins/default/fck_dialog.css	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/editor/skins/default/fck_dialog.css	(revision 1229)
@@ -58,4 +58,9 @@
 }
 
+#header
+{
+	cursor: move;
+}
+
 .DialogTitle
 {
@@ -65,9 +70,10 @@
 	background-color: #e3e3c7;
 	padding: 3px 10px 3px 10px;
-	cursor: move;
 }
 
 .DialogButtons
 {
+	position: absolute;
+	bottom: 0px;
 	border-top: #d5d59d 1px solid;
 	background-color: #e3e3c7;
Index: /FCKeditor/branches/features/floating_dialog/editor/skins/default/fck_dialog_ie6.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/skins/default/fck_dialog_ie6.js	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/editor/skins/default/fck_dialog_ie6.js	(revision 1229)
@@ -25,5 +25,5 @@
 	// mode). This function fixes the sizes and positions of many elements that
 	// compose the skin (this is skin specific).
-	var fixSizes = function()
+	var fixSizes = window.DoResizeFixes = function()
 	{
 		var fckDlg = window.document.body ;
Index: /FCKeditor/branches/features/floating_dialog/fckconfig.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/fckconfig.js	(revision 1228)
+++ /FCKeditor/branches/features/floating_dialog/fckconfig.js	(revision 1229)
@@ -303,5 +303,5 @@
 FCKConfig.SmileyColumns = 8 ;
 FCKConfig.SmileyWindowWidth		= 320 ;
-FCKConfig.SmileyWindowHeight	= 240 ;
+FCKConfig.SmileyWindowHeight	= 210 ;
 
 FCKConfig.BackgroundBlockerColor = '#ffffff' ;
