Index: /CKEditor/branches/prototype/_source/core/dom/document.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/dom/document.js	(revision 2515)
+++ /CKEditor/branches/prototype/_source/core/dom/document.js	(revision 2516)
@@ -123,5 +123,5 @@
 
 		/**
-		 * Get's the window object that holds this document.
+		 * Gets the window object that holds this document.
 		 * @returns {CKEDITOR.dom.window} The window object.
 		 * @example
Index: /CKEditor/branches/prototype/_source/core/dom/window.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/dom/window.js	(revision 2515)
+++ /CKEditor/branches/prototype/_source/core/dom/window.js	(revision 2516)
@@ -66,21 +66,10 @@
 		getViewPaneSize : function()
 		{
-			var $ = this.$;
-
-			if ( 'innerWidth' in $ )
-			{
-				return {
-					width : $.innerWidth || 0,
-					height : $.innerHeight || 0
-				};
-			}
-			else
-			{
-				var doc = $.document;
-				return {
-					width : doc.documentElement.clientWidth || doc.body.clientWidth || 0,
-					height : doc.documentElement.clientHeight || doc.body.clientHeight || 0
-				};
-			}
+			var doc = this.$.document,
+				stdMode = doc.compatMode == 'CSS1Compat';
+			return {
+				width : ( stdMode ? doc.documentElement.clientWidth : doc.body.clientWidth ) || 0,
+				height : ( stdMode ? doc.documentElement.clientHeight : doc.body.clientHeight ) || 0
+			};
 		},
 
Index: /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2515)
+++ /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2516)
@@ -438,5 +438,10 @@
 		},
 
-		storedDialogs : {}
+		storedDialogs : {},
+
+		setMargins : function( top, right, bottom, left )
+		{
+			this._.margins = [ top, right, bottom, left ];
+		}
 	});
 
@@ -711,15 +716,15 @@
 				abstractDialogCoords.y += dy;
 
-				if ( abstractDialogCoords.x < magnetDistance )
-					realX = 0;
-				else if ( abstractDialogCoords.x > viewPaneSize.width - dialogSize.width - magnetDistance )
-					realX = viewPaneSize.width - dialogSize.width;
+				if ( abstractDialogCoords.x + CKEDITOR.dialog._.margins[3] < magnetDistance )
+					realX = - CKEDITOR.dialog._.margins[3];
+				else if ( abstractDialogCoords.x - CKEDITOR.dialog._.margins[1] > viewPaneSize.width - dialogSize.width - magnetDistance )
+					realX = viewPaneSize.width - dialogSize.width + CKEDITOR.dialog._.margins[1];
 				else
 					realX = abstractDialogCoords.x;
 
-				if ( abstractDialogCoords.y < magnetDistance )
-					realY = 0;
-				else if ( abstractDialogCoords.y > viewPaneSize.height - dialogSize.height - magnetDistance )
-					realY = viewPaneSize.height - dialogSize.height;
+				if ( abstractDialogCoords.y + CKEDITOR.dialog._.margins[0] < magnetDistance )
+					realY = - CKEDITOR.dialog._.margins[0];
+				else if ( abstractDialogCoords.y - CKEDITOR.dialog._.margins[2] > viewPaneSize.height - dialogSize.height - magnetDistance )
+					realY = viewPaneSize.height - dialogSize.height + CKEDITOR.dialog._.margins[2];
 				else
 					realY = abstractDialogCoords.y;
@@ -759,5 +764,7 @@
 	currentTop : null,
 
-	currentZIndex : CKEDITOR.config.basePopupZIndex
+	currentZIndex : CKEDITOR.config.basePopupZIndex,
+
+	margins : [0, 0, 0, 0]
 };
 
Index: /CKEditor/branches/prototype/_source/skins/default/dialog_ie6.js
===================================================================
--- /CKEditor/branches/prototype/_source/skins/default/dialog_ie6.js	(revision 2515)
+++ /CKEditor/branches/prototype/_source/skins/default/dialog_ie6.js	(revision 2516)
Index: /CKEditor/branches/prototype/_source/skins/default/skin.js
===================================================================
--- /CKEditor/branches/prototype/_source/skins/default/skin.js	(revision 2515)
+++ /CKEditor/branches/prototype/_source/skins/default/skin.js	(revision 2516)
@@ -42,2 +42,4 @@
 	};
 })() );
+
+CKEDITOR.dialog.setMargins( 0, 14, 18, 14 );
