Index: /CKEditor/trunk/_source/core/config.js
===================================================================
--- /CKEditor/trunk/_source/core/config.js	(revision 3122)
+++ /CKEditor/trunk/_source/core/config.js	(revision 3123)
@@ -148,5 +148,5 @@
 	 */
 
-	plugins : 'basicstyles,blockquote,button,clipboard,elementspath,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,smiley,showblocks,sourcearea,stylescombo,table,specialchar,tab,templates,toolbar,undo,wysiwygarea',
+	plugins : 'basicstyles,blockquote,button,clipboard,colorbutton,elementspath,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,smiley,showblocks,sourcearea,stylescombo,table,specialchar,tab,templates,toolbar,undo,wysiwygarea',
 
 	/**
Index: /CKEditor/trunk/_source/lang/en.js
===================================================================
--- /CKEditor/trunk/_source/lang/en.js	(revision 3122)
+++ /CKEditor/trunk/_source/lang/en.js	(revision 3123)
@@ -474,4 +474,10 @@
 		label : 'Size',
 		panelTitle : 'Font Size'
+	},
+
+	colorButton :
+	{
+		auto : 'Automatic',
+		more : 'More Colors...'
 	}
 };
Index: /CKEditor/trunk/_source/plugins/button/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/button/plugin.js	(revision 3122)
+++ /CKEditor/trunk/_source/plugins/button/plugin.js	(revision 3123)
@@ -185,4 +185,7 @@
 	{
 		var element = CKEDITOR.document.getById( this._.id );
+
+		if ( this._.currentState == state )
+			return;
 
 		switch ( state )
@@ -204,4 +207,6 @@
 				break;
 		}
+
+		this._.currentState = state;
 	}
 };
Index: /CKEditor/trunk/_source/plugins/colorbutton/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/colorbutton/plugin.js	(revision 3123)
+++ /CKEditor/trunk/_source/plugins/colorbutton/plugin.js	(revision 3123)
@@ -0,0 +1,171 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+CKEDITOR.plugins.add( 'colorbutton',
+{
+	requires : [ 'panelbutton', 'floatpanel', 'styles' ],
+
+	init : function( editor )
+	{
+		var config = editor.config,
+			lang = editor.lang.colorButton;
+
+		var saveRanges,
+			clickFn;
+
+		addButton( 'TextColor', 'fore' );
+		addButton( 'BGColor', 'back' );
+
+		function addButton( name, type )
+		{
+			editor.ui.add( name, CKEDITOR.UI_PANELBUTTON,
+				{
+					label : lang.label,
+					title : lang.panelTitle,
+					className : 'cke_button_' + name.toLowerCase(),
+
+					panel :
+					{
+						css : [ config.contentsCss, CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ],
+						className : 'cke_skin_default'
+					},
+
+					onBlock : function( panel, blockName )
+					{
+						var block = panel.addBlock( blockName );
+						block.autoSize = true;
+						block.element.addClass( 'cke_colorblock' );
+						block.element.setHtml( renderColors( panel, type ) );
+					},
+
+					onOpen : function()
+					{
+						if ( CKEDITOR.env.ie )
+						{
+							editor.focus();
+							saveRanges = editor.getSelection().getRanges();
+						}
+					},
+
+					onClose : function()
+					{
+						saveRanges = null;
+					}
+				});
+		}
+
+
+		function renderColors( panel, type )
+		{
+			var output = [],
+				colors = CKEDITOR.config.colorButton_colors.split( ',' );
+
+			if ( !clickFn )
+			{
+				clickFn = CKEDITOR.tools.addFunction( function( color, type )
+					{
+						if ( color == '?' )
+						{
+							// TODO : Implement the colors dialog.
+							// editor.openDialog( '' );
+							return;
+						}
+
+						editor.focus();
+
+						if ( saveRanges )
+						{
+							editor.getSelection().selectRanges( saveRanges );
+							saveRanges = false;
+						}
+
+						panel.hide();
+
+						var style = new CKEDITOR.style( config['colorButton_' + type + 'Style'], { color : color || '#000' } );
+
+						if ( color )
+							style.apply( editor.document );
+						else
+							style.remove( editor.document );
+					});
+			}
+
+			// Render the "Automatic" button.
+			output.push(
+				'<a class="cke_colorauto"' +
+					' onclick="CKEDITOR.tools.callFunction(', clickFn, ',null,\'', type, '\');"' +
+					' href="javascript:void(\'', lang.auto, '\')">' +
+					'<table cellspacing=0 cellpadding=0 width="100%">' +
+						'<tr>' +
+							'<td>' +
+								'<span class="cke_colorbox" style="background-color:#000"></span>' +
+							'</td>' +
+							'<td colspan=7 align=center>',
+								lang.auto,
+							'</td>' +
+						'</tr>' +
+					'</table>' +
+				'</a>' +
+				'<table cellspacing=0 cellpadding=0 width="100%">' );
+
+			// Render the color boxes.
+			for ( var i = 0 ; i < colors.length ; i++ )
+			{
+				if ( ( i % 8 ) == 0 )
+					output.push( '</tr><tr>' );
+
+				var color = colors[ i ];
+				output.push(
+					'<td>' +
+						'<a class="cke_colorbox"' +
+							' onclick="CKEDITOR.tools.callFunction(', clickFn, ',\'#', color, '\',\'', type, '\');"' +
+							' href="javascript:void(\'', color, '\')">' +
+							'<span class="cke_colorbox" style="background-color:#', color, '"></span>' +
+						'</a>' +
+					'</td>' );
+			}
+
+			// Render the "More Colors" button.
+			if ( config.colorButton_enableMore )
+			{
+				output.push(
+					'</tr>' +
+					'<tr>' +
+						'<td colspan=8 align=center>' +
+							'<a class="cke_colormore"' +
+								' onclick="CKEDITOR.tools.callFunction(', clickFn, ',\'?\',\'', type, '\');"' +
+								' href="javascript:void(\'', lang.more, '\')">',
+								lang.more,
+							'</a>' +
+						'</td>' );	// It is later in the code.
+			}
+
+			output.push( '</tr></table>' );
+
+			return output.join( '' );
+		}
+	}
+});
+
+CKEDITOR.config.colorButton_enableMore = false;
+CKEDITOR.config.colorButton_colors =
+	'000,930,330,030,036,000080,339,333,' +
+	'800000,F60,808000,808080,008080,00F,669,808080,' +
+	'F00,F90,9C0,396,3CC,36F,800080,999,' +
+	'F0F,FC0,FF0,0F0,0FF,0CF,936,C0C0C0,' +
+	'F9C,FC9,FF9,CFC,CFF,9CF,C9F,FFF';
+
+CKEDITOR.config.colorButton_foreStyle =
+	{
+		element		: 'span',
+		styles		: { 'color' : '#(color)' },
+		overrides	: [ { element : 'font', attributes : { 'color' : null } } ]
+	};
+
+CKEDITOR.config.colorButton_backStyle =
+	{
+		element		: 'span',
+		styles		: { 'background-color' : '#(color)' }
+	};
Index: /CKEditor/trunk/_source/plugins/floatpanel/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/floatpanel/plugin.js	(revision 3122)
+++ /CKEditor/trunk/_source/plugins/floatpanel/plugin.js	(revision 3123)
@@ -74,5 +74,6 @@
 			showBlock : function( name, offsetParent, corner, offsetX, offsetY )
 			{
-				this._.panel.showBlock( name );
+				var panel = this._.panel,
+					block = panel.showBlock( name );
 
 				var element = this.element,
@@ -95,4 +96,19 @@
 						display	: ''
 					});
+
+				if ( block.autoSize )
+				{
+					function setHeight()
+					{
+						element.setStyle( 'height', block.element.$.scrollHeight + 'px' );
+					}
+					
+					if ( !CKEDITOR.env.gecko || panel.isLoaded )
+						setHeight();
+					else
+						panel.onLoad = setHeight;
+				}
+				else
+					element.removeStyle( 'height' );
 
 				// Configure the IFrame blur event. Do that only once.
Index: /CKEditor/trunk/_source/plugins/panel/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/panel/plugin.js	(revision 3122)
+++ /CKEditor/trunk/_source/plugins/panel/plugin.js	(revision 3123)
@@ -124,7 +124,17 @@
 					'<\/html>' );
 				doc.$.close();
+				
+				var win = doc.getWindow();
 
 				// Register the CKEDITOR global.
-				doc.getWindow().$.CKEDITOR = CKEDITOR;
+				win.$.CKEDITOR = CKEDITOR;
+
+				win.on( 'load', function( ev )
+					{
+						this.isLoaded = true;
+						if ( this.onLoad )
+							this.onLoad();
+					},
+					this);
 
 				holder = doc.getBody();
@@ -161,4 +171,6 @@
 
 		block.show();
+		
+		return block;
 	}
 };
Index: /CKEditor/trunk/_source/plugins/panelbutton/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/panelbutton/plugin.js	(revision 3123)
+++ /CKEditor/trunk/_source/plugins/panelbutton/plugin.js	(revision 3123)
@@ -0,0 +1,183 @@
+﻿/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+CKEDITOR.plugins.add( 'panelbutton',
+{
+	requires : [ 'button' ],
+	beforeInit : function( editor )
+	{
+		editor.ui.addHandler( CKEDITOR.UI_PANELBUTTON, CKEDITOR.ui.panelButton.handler );
+	}
+});
+
+/**
+ * Button UI element.
+ * @constant
+ * @example
+ */
+CKEDITOR.UI_PANELBUTTON = 4;
+
+CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass(
+{
+	$ : function( definition )
+	{
+		// Copy all definition properties to this object.
+		CKEDITOR.tools.extend( this, definition,
+			// Set defaults.
+			{
+				title : definition.label
+			});
+
+		// We don't want the panel definition in this object.
+		var panelDefinition = this.panel;
+		delete this.panel;
+
+		this.document = ( panelDefinition
+							&& panelDefinition.parent
+							&& panelDefinition.parent.getDocument() )
+						|| CKEDITOR.document;
+		this._ =
+		{
+			panelDefinition : panelDefinition
+		};
+	},
+	
+	statics :
+	{
+		handler :
+		{
+			create : function( definition )
+			{
+				return new CKEDITOR.ui.panelButton( definition );
+			}
+		}
+	},
+	
+	proto :
+	{
+		render : function( editor, output )
+		{
+			var id = this._.id = 'cke_' + CKEDITOR.tools.getNextNumber();
+
+			var instance =
+			{
+				id : id,
+				focus : function()
+				{
+					var element = CKEDITOR.document.getById( id );
+					element.focus();
+				},
+				execute : function()
+				{
+					this.button.click( editor );
+				}
+			};
+
+			var clickFn = CKEDITOR.tools.addFunction( function( $element )
+				{
+					var _ = this._;
+
+					this.createPanel();
+
+					if ( _.on )
+					{
+						_.panel.hide();
+						return;
+					}
+
+					_.panel.showBlock( this._.id, new CKEDITOR.dom.element( $element ), 4 );
+				},
+				this );
+
+			var label = this.label || '';
+
+			var classes = 'cke_button cke_off';
+
+			if ( this.className )
+				classes += ' ' + this.className;
+
+			if ( CKEDITOR.env.ie )
+				label += '\ufeff';
+
+			output.push(
+				'<a id="', id, '"' +
+					' class="', classes, '" href="javascript:void(\'', ( this.label || '' ).replace( "'", '' ), '\')"' +
+					' title="', this.title, '"' +
+					' tabindex="-1"' +
+					' hidefocus="true"' );
+
+			// Some browsers don't cancel key events in the keydown but in the
+			// keypress.
+			// TODO: Check if really needed for Gecko+Mac.
+			if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
+			{
+				output.push(
+					' onkeypress="return false;"' );
+			}
+
+			// With Firefox, we need to force the button to redraw, otherwise it
+			// will remain in the focus state.
+			if ( CKEDITOR.env.gecko )
+			{
+				output.push(
+					' onblur="this.style.cssText = this.style.cssText;"' );
+			}
+
+			output.push(
+//					' onkeydown="return CKEDITOR.ui.button._.keydown(', index, ', event);"' +
+					' onclick="CKEDITOR.tools.callFunction(', clickFn, ', this);">' +
+						'<span class="cke_icon"></span>' +
+						'<span class="cke_label">', label, '</span>' +
+						'<span class="cke_buttonarrow"></span>' +
+				'</a>' );
+
+			return instance;
+		},
+		
+		createPanel : function()
+		{
+			var _ = this._;
+
+			if ( _.panel )
+				return;
+			
+			var panelDefinition = this._.panelDefinition || {},
+				panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
+				panel = this._.panel = new CKEDITOR.ui.floatPanel( panelParentElement, panelDefinition ),
+				me = this;			
+
+			panel.onShow = function()
+				{
+					if ( me.className )
+						this.element.addClass( me.className );
+
+					me.document.getById( _.id ).addClass( 'cke_on');
+
+					_.on = 1;
+
+					if ( me.onOpen )
+						me.onOpen();
+				};
+
+			panel.onHide = function()
+				{
+					if ( me.className )
+						this.element.removeClass( me.className );
+
+					me.document.getById( _.id ).removeClass( 'cke_on');
+
+					_.on = 0;
+
+					if ( me.onClose )
+						me.onClose();
+				};
+			
+			if ( this.onBlock )
+				this.onBlock( panel, _.id );
+		},
+
+		setState : CKEDITOR.ui.button.prototype.setState
+	}
+});
Index: /CKEditor/trunk/_source/plugins/toolbar/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/toolbar/plugin.js	(revision 3122)
+++ /CKEditor/trunk/_source/plugins/toolbar/plugin.js	(revision 3123)
@@ -223,4 +223,5 @@
 	'/',
 	['Styles','Format','Font','FontSize'],
+	['TextColor','BGColor'],
 	['ShowBlocks']
 ];
Index: /CKEditor/trunk/_source/skins/default/panel.css
===================================================================
--- /CKEditor/trunk/_source/skins/default/panel.css	(revision 3122)
+++ /CKEditor/trunk/_source/skins/default/panel.css	(revision 3123)
@@ -255,2 +255,60 @@
 	margin-bottom: 3px;
 }
+
+.cke_skin_default.cke_panel.cke_button_textcolor,
+.cke_skin_default.cke_panel.cke_button_bgcolor
+{
+	width: 150px;
+	height: 135px;
+}
+
+.cke_colorblock
+{
+	padding: 3px;
+    font-size: 11px;
+    font-family: 'Microsoft Sans Serif', Tahoma, Arial, Verdana, Sans-Serif;
+}
+
+.cke_colorblock,
+.cke_colorblock a
+{
+	text-decoration: none;
+	color: #000;
+}
+
+span.cke_colorbox
+{
+	width: 10px;
+	height: 10px;
+    border: #808080 1px solid;
+	float: left;
+}
+
+a.cke_colorbox
+{
+    border: #fff 1px solid;
+    padding: 2px;
+    float: left;
+}
+
+a:hover.cke_colorbox
+{
+    border: #316ac5 1px solid;
+    background-color: #dff1ff;
+}
+
+a.cke_colorauto,
+a.cke_colormore
+{
+    border: #fff 1px solid;
+    padding: 2px;
+    display: block;
+}
+
+a:hover.cke_colorauto,
+a:hover.cke_colormore
+{
+    border: #316ac5 1px solid;
+    background-color: #dff1ff;
+}
+
Index: /CKEditor/trunk/_source/skins/default/toolbar.css
===================================================================
--- /CKEditor/trunk/_source/skins/default/toolbar.css	(revision 3122)
+++ /CKEditor/trunk/_source/skins/default/toolbar.css	(revision 3123)
@@ -145,4 +145,14 @@
 }
 
+.cke_skin_default a.cke_button .cke_buttonarrow
+{
+	float: left;
+	height: 18px;
+	width: 8px;
+	background-position: right center;
+	background-image: url(images/toolbar.buttonarrow.gif);
+	background-repeat: no-repeat;
+}
+
 .cke_skin_default.cke_rtl a.cke_button .cke_label
 {
@@ -300,4 +310,14 @@
 }
 
+.cke_skin_default a.cke_button_textcolor .cke_icon
+{
+	background-position: 0 -704px;
+}
+
+.cke_skin_default a.cke_button_bgcolor .cke_icon
+{
+	background-position: 0 -720px;
+}
+
 .cke_skin_default a.cke_button_form .cke_icon
 {
Index: /CKEditor/trunk/ckeditor.pack
===================================================================
--- /CKEditor/trunk/ckeditor.pack	(revision 3122)
+++ /CKEditor/trunk/ckeditor.pack	(revision 3123)
@@ -44,4 +44,5 @@
 		'CKEDITOR.STYLE_INLINE' : 2,
 		'CKEDITOR.STYLE_OBJECT' : 3,
+		'CKEDITOR.UI_PANELBUTTON' : 4,
 		'CKEDITOR.SELECTION_NONE' : 1,
 		'CKEDITOR.SELECTION_TEXT' : 2,
@@ -121,8 +122,11 @@
 					'_source/plugins/button/plugin.js',
 					'_source/plugins/clipboard/plugin.js',
+					'_source/plugins/colorbutton/plugin.js',
 					'_source/plugins/elementspath/plugin.js',
 					'_source/plugins/find/plugin.js',
 					'_source/plugins/flash/plugin.js',
+					'_source/plugins/font/plugin.js',
 					'_source/plugins/format/plugin.js',
+					'_source/plugins/forms/plugin.js',
 					'_source/plugins/horizontalrule/plugin.js',
 					'_source/plugins/htmldataprocessor/plugin.js',
@@ -143,4 +147,5 @@
 					'_source/plugins/showblocks/plugin.js',
 					'_source/plugins/sourcearea/plugin.js',
+					'_source/plugins/stylescombo/plugin.js',
 					'_source/plugins/table/plugin.js',
 					'_source/plugins/specialchar/plugin.js',
@@ -152,4 +157,6 @@
 					'_source/plugins/styles/plugin.js',
 					'_source/plugins/domiterator/plugin.js',
+					'_source/plugins/panelbutton/plugin.js',
+					'_source/plugins/floatpanel/plugin.js',
 					'_source/plugins/selection/plugin.js',
 					'_source/plugins/fakeobjects/plugin.js',
@@ -158,8 +165,7 @@
 					'_source/plugins/dialog/plugin.js',
 					'_source/plugins/editingblock/plugin.js',
-					'_source/plugins/floatpanel/plugin.js',
+					'_source/plugins/panel/plugin.js',
 					'_source/plugins/listblock/plugin.js',
 					'_source/plugins/dialogui/plugin.js',
-					'_source/plugins/panel/plugin.js',
 					'_source/skins/default/skin.js',
 					'_source/themes/default/theme.js'
