Index: /CKEditor/branches/features/sharedspaces/_samples/index.html
===================================================================
--- /CKEditor/branches/features/sharedspaces/_samples/index.html	(revision 4643)
+++ /CKEditor/branches/features/sharedspaces/_samples/index.html	(revision 4644)
@@ -38,4 +38,5 @@
 		<li><a href="api_dialog.html">Using the JavaScript API to customize dialogs</a></li>
 		<li><a href="enterkey.html">Using the "Enter" key in CKEditor</a></li>
+		<li><a href="sharedspaces.html">Shared toolbars</a></li>
 		<li><a href="jqueryadapter.html">jQuery adapter example</a></li>
 	</ul>
Index: /CKEditor/branches/features/sharedspaces/_samples/sharedspaces.html
===================================================================
--- /CKEditor/branches/features/sharedspaces/_samples/sharedspaces.html	(revision 4644)
+++ /CKEditor/branches/features/sharedspaces/_samples/sharedspaces.html	(revision 4644)
@@ -0,0 +1,115 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+-->
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>Replace Textarea by Code - CKEditor Sample</title>
+	<script type="text/javascript" src="sample.js"></script>
+	<style id="styles" type="text/css">
+
+#editorsForm
+{
+	height: 400px;
+	overflow: auto;
+	border: solid 1px #555;
+	margin: 10px 0;
+	padding: 0 10px;
+}
+
+	</style>
+</head>
+<body>
+	<div id="html">
+		<div id="topSpace">
+		</div>
+		<form id="editorsForm" action="sample_posteddata.php" method="post">
+			<p>
+				<label for="editor1">
+					Editor 1 (uses the shared toolbar and element path):</label><br />
+				<textarea id="editor1" name="editor1" rows="10" cols="80">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
+				<script type="text/javascript">
+				//<![CDATA[
+					CKEDITOR.replace( 'editor1',
+						{
+							sharedSpaces :
+							{
+								top : 'topSpace',
+								bottom : 'bottomSpace'
+							},
+
+							// Removes the maximize plugin as it's not usable
+							// in a shared toolbar.
+							// Removes the resizer as it's not usable in a
+							// shared elements path.
+							removePlugins : 'maximize,resize'
+						} );
+				//]]>
+				</script>
+			</p>
+			<p>
+				<label for="editor2">
+					Editor 2 (uses the shared toolbar and element path):</label><br />
+				<textarea id="editor2" name="editor2" rows="10" cols="80">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
+				<script type="text/javascript">
+				//<![CDATA[
+					CKEDITOR.replace( 'editor2',
+						{
+							sharedSpaces :
+							{
+								top : 'topSpace',
+								bottom : 'bottomSpace'
+							},
+
+							// Removes the maximize plugin as it's not usable
+							// in a shared toolbar.
+							// Removes the resizer as it's not usable in a
+							// shared elements path.
+							removePlugins : 'maximize,resize'
+						} );
+				//]]>
+				</script>
+			</p>
+			<p>
+				<label for="editor3">
+					Editor 3 (uses the shared toolbar only):</label><br />
+				<textarea id="editor3" name="editor3" rows="10" cols="80">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
+				<script type="text/javascript">
+				//<![CDATA[
+					CKEDITOR.replace( 'editor3',
+						{
+							sharedSpaces :
+							{
+								top : 'topSpace'
+							},
+							
+							// Removes the maximize plugin as it's not usable
+							// in a shared toolbar.
+							removePlugins : 'maximize'
+						} );
+				//]]>
+				</script>
+			</p>
+			<p>
+				<label for="editor4">
+					Editor 4 (no shared spaces):</label><br />
+				<textarea id="editor4" name="editor4" rows="10" cols="80">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
+				<script type="text/javascript">
+				//<![CDATA[
+					CKEDITOR.replace( 'editor4' );
+				//]]>
+				</script>
+			</p>
+			<p>
+				<input type="submit" value="Submit" />
+			</p>
+		</form>
+		<div id="bottomSpace">
+		</div>
+	</div>
+	<div id="code">
+		<pre></pre>
+	</div>
+</body>
+</html>
Index: /CKEditor/branches/features/sharedspaces/_source/core/skins.js
===================================================================
--- /CKEditor/branches/features/sharedspaces/_source/core/skins.js	(revision 4643)
+++ /CKEditor/branches/features/sharedspaces/_source/core/skins.js	(revision 4644)
@@ -21,8 +21,17 @@
 	var paths = {};
 
-	var loadPart = function( skinName, part, callback )
+	var loadPart = function( editor, skinName, part, callback )
 	{
 		// Get the skin definition.
 		var skinDefinition = loaded[ skinName ];
+
+		if ( !editor.skin )
+		{
+			editor.skin = skinDefinition;
+
+			// Trigger init function if any.
+			if ( skinDefinition.init )
+				skinDefinition.init( editor );
+		}
 
 		var appendSkinPath = function( fileNames )
@@ -56,5 +65,5 @@
 					{
 						preloaded[ skinName ] = 1;
-						loadPart( skinName, part, callback );
+						loadPart( editor, skinName, part, callback );
 					} );
 				return;
@@ -182,5 +191,5 @@
 
 			if ( loaded[ skinName ] )
-				loadPart( skinName, skinPart, callback );
+				loadPart( editor, skinName, skinPart, callback );
 			else
 			{
@@ -188,12 +197,5 @@
 				CKEDITOR.scriptLoader.load( skinPath + 'skin.js', function()
 						{
-							// Get the skin definition.
-							var skinDefinition = editor.skin = loaded[ skinName ];
-
-							// Trigger init function if any.
-							if ( skinDefinition.init )
-								skinDefinition.init( editor );
-
-							 loadPart( skinName, skinPart, callback );
+							 loadPart( editor, skinName, skinPart, callback );
 						});
 			}
Index: /CKEditor/branches/features/sharedspaces/_source/skins/kama/elementspath.css
===================================================================
--- /CKEditor/branches/features/sharedspaces/_source/skins/kama/elementspath.css	(revision 4643)
+++ /CKEditor/branches/features/sharedspaces/_source/skins/kama/elementspath.css	(revision 4644)
@@ -14,7 +14,7 @@
 .cke_skin_kama .cke_path
 {
-	padding: 0 5px;
 	display: inline-block;
 	float: left;
+	margin-top: 5px;
 }
 
@@ -24,4 +24,9 @@
 }
 
+.cke_shared .cke_skin_kama .cke_path
+{
+	margin: 0 0 5px;
+}
+
 .cke_skin_kama .cke_path a,
 .cke_skin_kama .cke_path .cke_empty
@@ -29,9 +34,5 @@
 	display: inline-block;
 	float: left;
-	padding-top: 1px;
-	padding-bottom: 1px;
-	padding-left: 4px;
-	padding-right: 4px;
-	margin-bottom : 3px;
+	padding: 1px 4px 0;
 	color: #60676a;
 }
@@ -53,8 +54,5 @@
 {
 	background-color: #dff1ff;
-	padding-top: 1px;
-	padding-bottom: 1px;
-	padding-left: 4px;
-	padding-right: 4px;
+	padding: 1px 4px 0;
 	outline: none;
 	color : #000;
Index: /CKEditor/branches/features/sharedspaces/_source/skins/kama/mainui.css
===================================================================
--- /CKEditor/branches/features/sharedspaces/_source/skins/kama/mainui.css	(revision 4643)
+++ /CKEditor/branches/features/sharedspaces/_source/skins/kama/mainui.css	(revision 4644)
@@ -30,6 +30,12 @@
 	background-position: 0 -1950px;
 	display: block;
+	padding: 5px;
 
 	/*background-color: Red;*/
+}
+
+.cke_shared .cke_skin_kama .cke_wrapper
+{
+	padding-bottom: 0;
 }
 
@@ -67,5 +73,4 @@
 {
 	margin: 5px;
-	padding: 0 5px 5px;
 }
 
@@ -138,2 +143,13 @@
 	top: 0;
 }
+
+.cke_skin_kama .cke_browser_ie7 .cke_editor
+{
+	display: inline-block;
+}
+
+.cke_shared .cke_skin_kama .cke_browser_ie7 .cke_wrapper
+{
+	padding-bottom: 5px;
+}
+
Index: /CKEditor/branches/features/sharedspaces/_source/skins/kama/skin.js
===================================================================
--- /CKEditor/branches/features/sharedspaces/_source/skins/kama/skin.js	(revision 4643)
+++ /CKEditor/branches/features/sharedspaces/_source/skins/kama/skin.js	(revision 4644)
@@ -148,5 +148,5 @@
 					var cssContent,
 						uiStyle = getStylesheet( CKEDITOR.document ),
-						cssId = '#cke_' + CKEDITOR.tools.escapeCssSelector( editor.name );
+						cssId = '.cke_editor_' + CKEDITOR.tools.escapeCssSelector( editor.name );
 
 					var cssSelectors =
Index: /CKEditor/branches/features/sharedspaces/_source/skins/kama/toolbar.css
===================================================================
--- /CKEditor/branches/features/sharedspaces/_source/skins/kama/toolbar.css	(revision 4643)
+++ /CKEditor/branches/features/sharedspaces/_source/skins/kama/toolbar.css	(revision 4644)
@@ -23,10 +23,4 @@
 {
 	clear: both;
-	padding: 5px 3px 5px 6px;
-}
-
-.cke_skin_kama .cke_rtl .cke_toolbox
-{
-	padding: 5px 6px 5px 3px;
 }
 
@@ -43,5 +37,5 @@
 	float: right;
 	border: 1px outset #D3D3D3;
-	margin: 11px 4px 2px;
+	margin: 11px 0 2px;
 	cursor: pointer;
 }
@@ -396,2 +390,12 @@
 	cursor: default;
 }
+
+.cke_skin_kama .cke_browser_ie7 .cke_toolbox
+{
+	margin-bottom: 2px;
+}
+
+.cke_shared .cke_skin_kama .cke_browser_ie7 .cke_toolbox
+{
+	margin-bottom: 0;
+}
Index: /CKEditor/branches/features/sharedspaces/_source/themes/default/theme.js
===================================================================
--- /CKEditor/branches/features/sharedspaces/_source/themes/default/theme.js	(revision 4643)
+++ /CKEditor/branches/features/sharedspaces/_source/themes/default/theme.js	(revision 4644)
@@ -6,4 +6,64 @@
 CKEDITOR.themes.add( 'default', (function()
 {
+	function checkSharedSpace( editor, spaceName )
+	{
+		var container,
+			element;
+
+		// Try to retrieve the target element from the sharedSpaces settings. 
+		element = editor.config.sharedSpaces;
+		element = element && element[ spaceName ];
+		element = element && CKEDITOR.document.getById( element );
+
+		// If the element is available, we'll then create the container for
+		// the space.			
+		if ( element )
+		{
+			// Creates an HTML structure that reproduces the editor class hierarchy.
+			var html = 
+				'<span class="cke_shared">' +
+				'<span class="' + editor.skinClass + ' cke_editor_' + editor.name + '">' +
+				'<span class="' + CKEDITOR.env.cssClass + '">' +
+				'<span class="cke_wrapper cke_' + editor.lang.dir + '">' +
+				'<span class="cke_editor">' +
+				'<div class="cke_' + spaceName + '">' +
+				'</div></span></span></span></span></span>';
+
+			var mainContainer = element.append( CKEDITOR.dom.element.createFromHtml( html, element.getDocument() ) );
+
+			// Only the first container starts visible. Others get hidden.
+			if ( element.getCustomData( 'cke_hasshared' ) )
+				mainContainer.hide();
+			else
+				element.setCustomData( 'cke_hasshared', 1 );
+			
+			// Get the deeper inner <div>.
+			container = mainContainer.getChild( [0,0,0,0] );
+
+			// When the editor gets focus, we show the space container, hiding others.
+			editor.on( 'focus', function()
+				{
+					for ( var i = 0, sibling, children = element.getChildren() ; ( sibling = children.getItem( i ) ) ; i++ )
+					{
+						if ( sibling.type == CKEDITOR.NODE_ELEMENT 
+							&& !sibling.equals( mainContainer ) 
+							&& sibling.hasClass( 'cke_shared' ) )
+						{
+							sibling.hide();
+						}
+					}
+
+					mainContainer.show();
+				});
+
+			editor.on( 'destroy', function()
+				{
+					mainContainer.remove();
+				});
+		}
+
+		return container;
+	}
+
 	return {
 		build : function( editor, themePath )
@@ -45,9 +105,15 @@
 			}
 
+			var sharedTop		= topHtml && checkSharedSpace( editor, 'top' ),
+				sharedBottoms	= checkSharedSpace( editor, 'bottom' );
+				
+			sharedTop		&& ( sharedTop.setHtml( topHtml )		, topHtml = '' );
+			sharedBottoms	&& ( sharedBottoms.setHtml( bottomHtml ), bottomHtml = '' );
+
 			var container = CKEDITOR.dom.element.createFromHtml( [
 				'<span' +
 					' id="cke_', name, '"' +
 					' onmousedown="return false;"' +
-					' class="', editor.skinClass, '"' +
+					' class="', editor.skinClass, ' cke_editor_', name, '"' +
 					' dir="', editor.lang.dir, '"' +
 					' title="', ( CKEDITOR.env.gecko ? ' ' : '' ), '"' +
@@ -99,5 +165,5 @@
 
 			var element = CKEDITOR.dom.element.createFromHtml( [
-					'<div id="cke_' + editor.name.replace('.', '\\.') + '_dialog" class="cke_skin_', editor.skinName,
+					'<div class="cke_editor_' + editor.name.replace('.', '\\.') + '_dialog cke_skin_', editor.skinName,
 						'" dir="', editor.lang.dir, '"' +
 						' lang="', editor.langCode, '"' +
@@ -234,2 +300,9 @@
 	return this.container.getChild( [ 0, 0 ] );
 };
+
+
+CKEDITOR.config.sharedSpaces =
+{
+	top : '',
+	bottom : ''
+};
