Index: CKEditor/trunk/CHANGES.html
===================================================================
--- CKEditor/trunk/CHANGES.html	(revision 4667)
+++ CKEditor/trunk/CHANGES.html	(revision 4668)
@@ -159,4 +159,5 @@
 		<li><a href="http://dev.fckeditor.net/ticket/4543">#4543</a> : Fixed unable to move cursor between table and hr.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/4764">#4764</a> : Fixed wrong exception message when CKEDITOR.editor::append to non-existence element.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/4521">#4521</a> : Fixed dialog layout in IE6/7 may have scroll-bar and other weird effects.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.fckeditor.net/ticket/3947">#3947</a> : Arabic;</li>
Index: CKEditor/trunk/_source/plugins/dialog/plugin.js
===================================================================
--- CKEditor/trunk/_source/plugins/dialog/plugin.js	(revision 4667)
+++ CKEditor/trunk/_source/plugins/dialog/plugin.js	(revision 4668)
@@ -810,5 +810,5 @@
 							expand : !!contents.expand,
 							padding : contents.padding,
-							style : contents.style || 'width: 100%; height: 100%;'
+							style : contents.style || 'width: 100%;'
 						}, pageHtml );
 
Index: CKEditor/trunk/_source/plugins/image/dialogs/image.js
===================================================================
--- CKEditor/trunk/_source/plugins/image/dialogs/image.js	(revision 4667)
+++ CKEditor/trunk/_source/plugins/image/dialogs/image.js	(revision 4668)
@@ -443,13 +443,8 @@
 													this.getDialog().dontResetSize = true;
 
-													// In IE7 the dialog is being rendered improperly when loading
-													// an image with a long URL. So we need to delay it a bit. (#4122)
-													setTimeout( function()
-														{
-															field.setValue( url );		// And call this.onChange()
-															// Manually set the initial value.(#4191)
-															field.setInitValue();
-															field.focus();
-														}, 0 );
+													field.setValue( url );		// And call this.onChange()
+													// Manually set the initial value.(#4191)
+													field.setInitValue();
+													field.focus();
 												}
 											},
Index: CKEditor/trunk/_source/skins/kama/dialog.css
===================================================================
--- CKEditor/trunk/_source/skins/kama/dialog.css	(revision 4667)
+++ CKEditor/trunk/_source/skins/kama/dialog.css	(revision 4668)
@@ -8,4 +8,10 @@
 {
 	visibility: visible;
+}
+
+/* Force Gecko to consider table as positioned */
+.cke_skin_kama table.cke_dialog.cke_browser_gecko
+{
+	display:block;
 }
 
@@ -19,4 +25,9 @@
 	-webkit-border-radius: 5px;
 	border-radius: 5px;
+
+	/* 'cke_dialog' element has been fixed positioned in all but IE6, while we
+		need it to be positioned to hold e.g. close button. */
+	position: relative;
+	_position: static;
 }
 
Index: CKEditor/trunk/_source/skins/kama/mainui.css
===================================================================
--- CKEditor/trunk/_source/skins/kama/mainui.css	(revision 4667)
+++ CKEditor/trunk/_source/skins/kama/mainui.css	(revision 4668)
@@ -7,5 +7,4 @@
 {
 	display: block;
-	_display: inline-block;
 }
 
Index: CKEditor/trunk/_source/skins/kama/skin.js
===================================================================
--- CKEditor/trunk/_source/skins/kama/skin.js	(revision 4667)
+++ CKEditor/trunk/_source/skins/kama/skin.js	(revision 4668)
@@ -212,6 +212,5 @@
 				height = data.height,
 				dialog = data.dialog,
-				contents = dialog.parts.contents,
-				standardsMode = !CKEDITOR.env.quirks;
+				contents = dialog.parts.contents;
 
 			if ( data.skin != 'kama' )
@@ -219,26 +218,14 @@
 
 			contents.setStyles(
-				( CKEDITOR.env.ie || ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) ) ?		// IE && FF2
-					{
-						width : width + 'px',
-						height : height + 'px'
-					}
-				:
-					{
-						// To avoid having scrollbars in the dialogs, we're
-						// (for now) using the "min-xxx" properties, for
-						// browsers which well support it (#3878).
-						'min-width' : width + 'px',
-						'min-height' : height + 'px'
-					});
-
-			if ( !CKEDITOR.env.ie )
-				return;
+				{
+					width : width + 'px',
+					height : height + 'px'
+				});
 
 			// Fix the size of the elements which have flexible lengths.
 			setTimeout( function()
 				{
-					var body = contents.getParent(),
-						innerDialog = body.getParent();
+					var innerDialog = dialog.parts.dialog.getChild( [ 0, 0, 0 ] ),
+						body = innerDialog.getChild( 0 );
 
 					// tc
Index: CKEditor/trunk/_source/skins/office2003/dialog.css
===================================================================
--- CKEditor/trunk/_source/skins/office2003/dialog.css	(revision 4667)
+++ CKEditor/trunk/_source/skins/office2003/dialog.css	(revision 4668)
@@ -10,4 +10,10 @@
 }
 
+/* Force Gecko to consider table as positioned */
+.cke_skin_office2003 table.cke_dialog.cke_browser_gecko
+{
+	display:block;
+}
+
 .cke_skin_office2003 .cke_dialog_body
 {
@@ -16,6 +22,10 @@
 	margin-top: 2px;
 	margin-bottom: 20px;
+	z-index: 1;
+
+	/* 'cke_dialog' element has been fixed positioned in all but IE6, while we 
+		need it to be positioned to hold e.g. close button. */
 	position: relative;
-	z-index: 1;
+	_position: static;
 }
 
Index: CKEditor/trunk/_source/skins/office2003/skin.js
===================================================================
--- CKEditor/trunk/_source/skins/office2003/skin.js	(revision 4667)
+++ CKEditor/trunk/_source/skins/office2003/skin.js	(revision 4668)
@@ -32,10 +32,10 @@
 				height = data.height,
 				dialog = data.dialog,
-				standardsMode = !CKEDITOR.env.quirk;
+				contents = dialog.parts.contents;
 
 			if ( data.skin != 'office2003' )
 				return;
 
-			dialog.parts.contents.setStyles(
+			contents.setStyles(
 				{
 					width : width + 'px',
@@ -49,7 +49,6 @@
 			var fixSize = function()
 				{
-					var content = dialog.parts.contents,
-						body = content.getParent(),
-						innerDialog = body.getParent();
+					var innerDialog = dialog.parts.dialog.getChild( [ 0, 0, 0 ] ),
+						body = innerDialog.getChild( 0 );
 
 					// tc
Index: CKEditor/trunk/_source/skins/v2/dialog.css
===================================================================
--- CKEditor/trunk/_source/skins/v2/dialog.css	(revision 4667)
+++ CKEditor/trunk/_source/skins/v2/dialog.css	(revision 4668)
@@ -10,4 +10,10 @@
 }
 
+/* Force Gecko to consider table as positioned */
+.cke_skin_v2 table.cke_dialog.cke_browser_gecko
+{
+	display:block;
+}
+
 .cke_skin_v2 .cke_dialog_body
 {
@@ -16,6 +22,11 @@
 	margin-top: 2px;
 	margin-bottom: 20px;
+	z-index: 1;
+
+	/* 'cke_dialog' element has been fixed positioned in all but IE6, while we
+		need it to be positioned to hold e.g. close button. */
 	position: relative;
-	z-index: 1;
+	_position: static;
+	
 }
 
Index: CKEditor/trunk/_source/skins/v2/skin.js
===================================================================
--- CKEditor/trunk/_source/skins/v2/skin.js	(revision 4667)
+++ CKEditor/trunk/_source/skins/v2/skin.js	(revision 4668)
@@ -32,10 +32,10 @@
 				height = data.height,
 				dialog = data.dialog,
-				standardsMode = !CKEDITOR.env.quirk;
+				contents = dialog.parts.contents;
 
 			if ( data.skin != 'v2' )
 				return;
 
-			dialog.parts.contents.setStyles(
+			contents.setStyles(
 				{
 					width : width + 'px',
@@ -49,7 +49,6 @@
 			setTimeout( function()
 				{
-					var content = dialog.parts.contents,
-						body = content.getParent(),
-						innerDialog = body.getParent();
+					var innerDialog = dialog.parts.dialog.getChild( [ 0, 0, 0 ] ),
+						body = innerDialog.getChild( 0 );
 
 					// tc
Index: CKEditor/trunk/_source/themes/default/theme.js
===================================================================
--- CKEditor/trunk/_source/themes/default/theme.js	(revision 4667)
+++ CKEditor/trunk/_source/themes/default/theme.js	(revision 4668)
@@ -103,7 +103,7 @@
 						' lang="', editor.langCode, '"' +
 						'>' +
-
-						'<div class="cke_dialog', ' ' + CKEDITOR.env.cssClass,
+						'<table class="cke_dialog', ' ' + CKEDITOR.env.cssClass,
 							' cke_', editor.lang.dir, '" style="position:absolute">' +
+							'<tr><td>' +
 							'<div class="%body">' +
 								'<div id="%title#" class="%title"></div>' +
@@ -112,5 +112,7 @@
 								'</div>' +
 								'<div id="%tabs#" class="%tabs"></div>' +
-								'<div id="%contents#" class="%contents"></div>' +
+								  '<table class="%contents"><tr>' +
+								  '<td id="%contents#" class="%contents"></td>' +
+								  '</tr></table>' +
 								'<div id="%footer#" class="%footer"></div>' +
 							'</div>' +
@@ -123,5 +125,6 @@
 							'<div id="%bc#" class="%bc"></div>' +
 							'<div id="%br#" class="%br"></div>' +
-						'</div>',
+							'</td></tr>' +
+						'</table>',
 
 						//Hide the container when loading skins, later restored by skin css.
@@ -133,9 +136,11 @@
 					.replace( /%/g, 'cke_dialog_' ) );
 
-			var body = element.getChild( [ 0, 0 ] );
+			var body = element.getChild( [ 0, 0, 0, 0, 0 ] ),
+				title = body.getChild( 0 ),
+				close = body.getChild( 1 );
 
 			// Make the Title and Close Button unselectable.
-			body.getChild( 0 ).unselectable();
-			body.getChild( 1 ).unselectable();
+			title.unselectable();
+			close.unselectable();
 
 
@@ -145,8 +150,8 @@
 				{
 					dialog		: element.getChild( 0 ),
-					title		: body.getChild( 0 ),
-					close		: body.getChild( 1 ),
+					title		: title,
+					close		: close,
 					tabs		: body.getChild( 2 ),
-					contents	: body.getChild( 3 ),
+					contents	: body.getChild( [ 3, 0, 0, 0 ] ),
 					footer		: body.getChild( 4 )
 				}
