Index: /CKEditor/branches/prototype/_source/core/editor.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/editor.js	(revision 2482)
+++ /CKEditor/branches/prototype/_source/core/editor.js	(revision 2483)
@@ -205,16 +205,20 @@
 						}
 
-						// Load the editor skin and theme.
-						loadSkinTheme( editor );
+						// Load the editor skin.
+						loadSkin( editor );
 					});
 			});
 	};
 
-	var loadSkinTheme = function( editor )
-	{
-		// Load the skin.
-		CKEDITOR.skins.load( editor.config.skin, 'editor' );
-
-		// Load the theme.
+	var loadSkin = function( editor )
+	{
+		CKEDITOR.skins.load( editor.config.skin, 'editor', function()
+			{
+				loadTheme( editor );
+			});
+	};
+
+	var loadTheme = function( editor )
+	{
 		var theme = editor.config.theme;
 		CKEDITOR.themes.load( theme, function()
Index: /CKEditor/branches/prototype/_source/core/imagecacher.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/imagecacher.js	(revision 2483)
+++ /CKEditor/branches/prototype/_source/core/imagecacher.js	(revision 2483)
@@ -0,0 +1,74 @@
+﻿/*
+ * CKEditor - The text editor for Internet - http://ckeditor.com
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+
+(function()
+{
+	var loaded = {};
+
+	var loadImage = function( image, callback )
+	{
+		var doCallback = function()
+			{
+				loaded[ image ] = 1;
+				callback();
+			};
+
+		var img = new CKEDITOR.dom.element( 'img' );
+		img.on( 'load', doCallback );
+		img.on( 'error', doCallback );
+		img.setAttribute( 'src', image );
+	};
+
+	/**
+	 * Load images into the browser cache.
+	 * @namespace
+	 * @example
+	 */
+ 	CKEDITOR.imageCacher =
+	{
+		/**
+		 * Loads one or more images.
+		 * @param {Array} images The URLs for the images to be loaded.
+		 * @param {Function} callback The function to be called once all images
+		 *		are loaded.
+		 */
+		load : function( images, callback )
+		{
+			var pendingCount = images.length;
+
+			var checkPending = function()
+			{
+				if ( --pendingCount === 0 )
+					callback();
+			};
+
+			for ( var i = 0 ; i < images.length ; i++ )
+			{
+				var image = images[ i ];
+
+				if ( loaded[ image ] )
+					checkPending();
+				else
+					loadImage( image, checkPending );
+			}
+		}
+	};
+})();
Index: /CKEditor/branches/prototype/_source/core/loader.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/loader.js	(revision 2482)
+++ /CKEditor/branches/prototype/_source/core/loader.js	(revision 2483)
@@ -65,9 +65,10 @@
 			'core/htmlparser/fragment'	: [ 'core/htmlparser', 'core/htmlparser/comment', 'core/htmlparser/text' ],
 			'core/htmlparser/text'		: [ 'core/htmlparser' ],
+			'core/imagecacher'		: [ 'core/dom/element' ],
 			'core/lang'				: [],
 			'core/plugins'			: [ 'core/resourcemanager' ],
 			'core/resourcemanager'	: [ 'core/scriptloader', 'core/tools' ],
 			'core/scriptloader'		: [ 'core/dom/element', 'core/env' ],
-			'core/skins'			: [],
+			'core/skins'			: [ 'core/imagecacher', 'core/scriptloader' ],
 			'core/themes'			: [ 'core/resourcemanager' ],
 			'core/tools'			: [ 'core/env' ],
Index: /CKEditor/branches/prototype/_source/core/skins.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/skins.js	(revision 2482)
+++ /CKEditor/branches/prototype/_source/core/skins.js	(revision 2483)
@@ -34,20 +34,124 @@
 	// Holds the list of loaded skins.
 	var loaded = {};
+	var preloaded = {};
 
-	var loadFile = function( url, type )
+	var loadedPart = function( skinName, part, callback )
 	{
-		// Ignore it if already loaded.
-		if ( loaded[ url ] )
-			return;
+		// Get the skin definition.
+		var skinDefinition = loaded[ skinName ];
 
-		loaded[ url ] = 1;
+		var appendSkinPath = function( fileNames )
+		{
+			for ( var n = 0 ; n < fileNames.length ; n++ )
+			{
+				fileNames[ n ] = CKEDITOR.getUrl(
+					'_source/' +	// TODO: Add @-Packager.RemoveLine to the final build process.
+					'skins/' + skinName + '/' + fileNames[ n ] );
+			}
+		};
 
-		if ( type == 'css' )
-			CKEDITOR.document.appendStyleSheet( url );
+		// Check if we need to preload images from it.
+		if ( !preloaded[ skinName ] )
+		{
+			var preload = skinDefinition.preload;
+			if ( preload && preload.length > 0 )
+			{
+				appendSkinPath( preload );
+				CKEDITOR.imageCacher.load( preload, function()
+					{
+						preloaded[ skinName ] = 1;
+						loadedPart( skinName, part, callback );
+					} );
+				return;
+			}
+
+			// Mark it as preloaded.
+			preloaded[ skinName ] = 1;
+		}
+
+		// Get the part definition.
+		part = skinDefinition[ part ];
+		var partIsLoaded = !part || !!part._isLoaded;
+
+		// Call the callback immediately if already loaded.
+		if ( partIsLoaded )
+			callback();
 		else
-			CKEDITOR.scriptLoader.load( url, function(){} ) ;		// TODO: how to properly load a JavaScript file?
+		{
+			// Put the callback in a queue.
+			var pending = part._pending || ( part._pending = [] );
+			pending.push( callback );
+
+			// We may have more than one skin part load request. Just the first
+			// one must do the loading job.
+			if ( pending.length > 1 )
+				return;
+
+			// Check whether the "css" and "js" properties have been defined
+			// for that part.
+			var cssIsLoaded = !part.css || !part.css.length;
+			var jsIsLoaded = !part.js || !part.js.length;
+
+			// This is the function that will trigger the callback calls on
+			// load.
+			var checkIsLoaded = function()
+			{
+				if ( cssIsLoaded && jsIsLoaded )
+				{
+					// Mark the part as loaded.
+					part._isLoaded = 1;
+
+					// Call all pending callbacks.
+					for ( var i = 0 ; i < pending.length ; i++ )
+					{
+						if ( pending[ i ] )
+							pending[ i ]();
+					}
+				}
+			};
+
+			// Load the "css" pieces.
+			if ( !cssIsLoaded )
+			{
+				appendSkinPath( part.css );
+
+				for ( var c = 0 ; c < part.css.length ; c++ )
+					CKEDITOR.document.appendStyleSheet( part.css[ c ] );
+
+				cssIsLoaded = 1;
+			}
+
+			// Load the "js" pieces.
+			if ( !jsIsLoaded )
+			{
+				appendSkinPath( part.js );
+				CKEDITOR.scriptLoader.load( part.js, function()
+					{
+						jsIsLoaded = 1;
+						checkIsLoaded();
+					});
+			}
+
+			// We may have nothing to load, so check it immediately.
+			checkIsLoaded();
+		}
 	};
 
 	return /** @lends CKEDITOR.skins */ {
+
+		/**
+		 * Registers a skin definition.
+		 * @param {String} skinName The skin name.
+		 * @param {Object} skinDefinition The skin definition.
+		 * @example
+		 */
+		add : function( skinName, skinDefinition )
+		{
+			loaded[ skinName ] = skinDefinition;
+
+			skinDefinition.skinPath = CKEDITOR.getUrl(
+					'_source/' +	// TODO: Add @-Packager.RemoveLine to the final build process.
+					'skins/' + skinName + '/' );
+		},
 
 		/**
@@ -58,11 +162,21 @@
 		 * @param {String} skinPart The skin part to be loaded. Common skin parts
 		 *		are "editor" and "dialog".
+		 * @param {Function} [callback] A function to be called once the skin
+		 *		part files are loaded.
 		 * @example
 		 */
-		load : function( skinName, skinPart )
+		load : function( skinName, skinPart, callback )
 		{
-			loadFile( CKEDITOR.getUrl(
-				'_source/' +	// TODO: Add @-Packager.RemoveLine to the final build process.
-				'skins/' + skinName + '/' + skinPart + '.css' ), 'css' );
+			if ( loaded[ skinName ] )
+				loadedPart( skinName, skinPart, callback );
+			else
+			{
+				CKEDITOR.scriptLoader.load( CKEDITOR.getUrl(
+					'_source/' +	// TODO: Add @-Packager.RemoveLine to the final build process.
+					'skins/' + skinName + '/skin.js' ), function()
+						{
+							loadedPart( skinName, skinPart, callback );
+						} );
+			}
 		}
 	 };
Index: /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2482)
+++ /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2483)
@@ -1,3 +1,3 @@
-/*
+﻿/*
  * CKEditor - The text editor for Internet - http://ckeditor.com
  * Copyright (C) 2003-2008 Frederico Caldeira Knabben
@@ -110,4 +110,6 @@
 				this.selectPage( id );
 			}, this );
+
+	CKEDITOR.skins.load( editor.config.skin, 'dialog' );
 }
 
Index: /CKEditor/branches/prototype/_source/skins/default/dialog_ie6.js
===================================================================
--- /CKEditor/branches/prototype/_source/skins/default/dialog_ie6.js	(revision 2483)
+++ /CKEditor/branches/prototype/_source/skins/default/dialog_ie6.js	(revision 2483)
@@ -0,0 +1,1 @@
+﻿
Index: /CKEditor/branches/prototype/_source/skins/default/editor.css
===================================================================
--- /CKEditor/branches/prototype/_source/skins/default/editor.css	(revision 2482)
+++ /CKEditor/branches/prototype/_source/skins/default/editor.css	(revision 2483)
@@ -24,3 +24,2 @@
 @import url("toolbar.css");
 @import url("elementspath.css");
-@import url("dialog.css");
Index: /CKEditor/branches/prototype/_source/skins/default/skin.js
===================================================================
--- /CKEditor/branches/prototype/_source/skins/default/skin.js	(revision 2483)
+++ /CKEditor/branches/prototype/_source/skins/default/skin.js	(revision 2483)
@@ -0,0 +1,43 @@
+﻿/*
+ * CKEditor - The text editor for Internet - http://ckeditor.com
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+
+CKEDITOR.skins.add( 'default', (function()
+{
+	var preload = [];
+	var dialogJs = [];
+
+	if ( CKEDITOR.env.ie && CKEDITOR.env.version <= 6 )
+	{
+		// For IE6, we need to preload some images, otherwhise they will be
+		// downloaded several times (CSS background bug).
+		preload.push( 'icons.gif', 'images/sprites.gif', 'images/dialog.sides.gif' );
+
+		// The dialog must be fixed by code in IE6, as it doesn't support
+		// several CSS features (absolute positioning).
+		dialogJs.push( 'dialog_ie6.js' );
+	}
+
+	return {
+		preload : preload,
+		editor : { css : [ 'editor.css' ] },
+		dialog : { css : [ 'dialog.css' ],  js : dialogJs }
+	};
+})() );
Index: /CKEditor/branches/prototype/_source/tests/core/ckeditor2.html
===================================================================
--- /CKEditor/branches/prototype/_source/tests/core/ckeditor2.html	(revision 2482)
+++ /CKEditor/branches/prototype/_source/tests/core/ckeditor2.html	(revision 2483)
@@ -39,5 +39,5 @@
 						});
 				});
-			
+
 			this.wait();
 		},
Index: /CKEditor/branches/prototype/ckeditor.pack
===================================================================
--- /CKEditor/branches/prototype/ckeditor.pack	(revision 2482)
+++ /CKEditor/branches/prototype/ckeditor.pack	(revision 2483)
@@ -24,4 +24,8 @@
 		'CKEDITOR.NODE_COMMENT' : 8,
 		'CKEDITOR.UI_BUTTON' : 1,
+		'CKEDITOR.DIALOG_RESIZE_NONE' : 0,
+		'CKEDITOR.DIALOG_RESIZE_RESIZE_WIDTH' : 1,
+		'CKEDITOR.DIALOG_RESIZE_RESIZE_HEIGHT' : 2,
+		'CKEDITOR.DIALOG_RESIZE_RESIZE_BOTH' : 3,
 		'CKEDITOR.SELECTION_NONE' : 1,
 		'CKEDITOR.SELECTION_TEXT' : 2,
@@ -71,4 +75,5 @@
 					'_source/core/resourcemanager.js',
 					'_source/core/plugins.js',
+					'_source/core/imagecacher.js',
 					'_source/core/skins.js',
 					'_source/core/themes.js',
@@ -86,4 +91,6 @@
 					'_source/plugins/basicstyles/plugin.js',
 					'_source/plugins/button/plugin.js',
+					'_source/plugins/dialog/plugin.js',
+					'_source/plugins/dialogui/plugin.js',
 					'_source/plugins/elementspath/plugin.js',
 					'_source/plugins/htmldataprocessor/plugin.js',
@@ -96,4 +103,5 @@
 					'_source/plugins/htmlwriter/plugin.js',
 					'_source/plugins/editingblock/plugin.js',
+					'_source/skins/default/skin.js',
 					'_source/themes/default/theme.js'
 				]
