Index: /CKEditor/trunk/_source/core/command.js
===================================================================
--- /CKEditor/trunk/_source/core/command.js	(revision 3515)
+++ /CKEditor/trunk/_source/core/command.js	(revision 3516)
@@ -30,4 +30,15 @@
 CKEDITOR.command.prototype =
 {
+	enable : function()
+	{
+		if ( this.state == CKEDITOR.TRISTATE_DISABLED )
+			this.setState( ( !this.preserveState || ( typeof this.previousState == 'undefined' ) ) ? CKEDITOR.TRISTATE_OFF : this.previousState );
+	},
+
+	disable : function()
+	{
+		this.setState( CKEDITOR.TRISTATE_DISABLED );
+	},
+
 	setState : function( newState )
 	{
@@ -35,4 +46,6 @@
 		if ( this.state == newState )
 			return false;
+
+		this.previousState = this.state;
 
 		// Set the new state.
Index: /CKEditor/trunk/_source/core/config.js
===================================================================
--- /CKEditor/trunk/_source/core/config.js	(revision 3515)
+++ /CKEditor/trunk/_source/core/config.js	(revision 3516)
@@ -151,5 +151,5 @@
 	 */
 
-	plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,save,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
+	plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,save,scayt,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
 
 	/**
Index: /CKEditor/trunk/_source/core/editor.js
===================================================================
--- /CKEditor/trunk/_source/core/editor.js	(revision 3515)
+++ /CKEditor/trunk/_source/core/editor.js	(revision 3516)
@@ -321,6 +321,5 @@
 		{
 			command = commands[ name ];
-
-			command.setState( command.modes[ mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
+			command[ command.modes[ mode ] ? 'enable' : 'disable' ]();
 		}
 	}
@@ -400,5 +399,5 @@
 			CKEDITOR.fire( 'instanceCreated', null, this );
 
-			this.on( 'mode', updateCommandsMode );
+			this.on( 'mode', updateCommandsMode, null, null, 1 );
 
 			initConfig( this, instanceConfig );
Index: /CKEditor/trunk/_source/lang/en.js
===================================================================
--- /CKEditor/trunk/_source/lang/en.js	(revision 3515)
+++ /CKEditor/trunk/_source/lang/en.js	(revision 3516)
@@ -621,4 +621,24 @@
 	},
 
+	scayt :
+	{
+		title : 'Spell Check As You Type',
+		enable : 'Enable SCAYT',
+		disable : 'Disable SCAYT',
+		about : 'About SCAYT',
+		toggle : 'Toggle SCAYT',
+		options : 'Options',
+		langs : 'Languages',
+		moreSuggestions : 'More suggestions',
+		ignore : 'Ignore',
+		ignoreAll : 'Ignore All',
+		addWord : 'Add Word',
+		emptyDic : 'Dictionary name should not be empty.',
+		optionsTab : 'Options',
+		languagesTab : 'Languages',
+		dictionariesTab : 'Dictionaries',
+		aboutTab : 'About'
+	},
+
 	about :
 	{
Index: /CKEditor/trunk/_source/plugins/button/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/button/plugin.js	(revision 3515)
+++ /CKEditor/trunk/_source/plugins/button/plugin.js	(revision 3516)
@@ -28,47 +28,15 @@
 CKEDITOR.ui.button = function( definition )
 {
-	/**
-	 * The button label.
-	 * @name CKEDITOR.ui.button.prototype.label
-	 * @type String
-	 * @example
-	 */
-	this.label = definition.label;
-
-	/**
-	 * The button advisory title. It is usually displayed as the button tooltip.
-	 * If not defined, the label is used.
-	 * @name CKEDITOR.ui.button.prototype.title
-	 * @type String
-	 * @example
-	 */
-	this.title = definition.title || definition.label;
-
-	/**
-	 * The command name associated to the button. If no command is defined, the
-	 * "click" event is used.
-	 * @name CKEDITOR.ui.button.prototype.command
-	 * @type String
-	 * @example
-	 */
-	this.command = definition.command;
-
-	this.className = definition.className || ( definition.command && 'cke_button_' + definition.command ) || '';
-
-	this.icon = definition.icon;
-	this.iconOffset = definition.iconOffset;
-
-	/**
-	 * The function to be called when the user clicks the button. If not
-	 * defined, the "command" property is required, and the command gets
-	 * executed on click.
-	 * @function
-	 * @name CKEDITOR.ui.button.prototype.click
-	 * @example
-	 */
-	this.click = definition.click || function( editor )
-		{
-			editor.execCommand( definition.command );
-		};
+	// Copy all definition properties to this object.
+	CKEDITOR.tools.extend( this, definition,
+		// Set defaults.
+		{
+			title		: definition.label,
+			className	: definition.className || ( definition.command && 'cke_button_' + definition.command ) || '',
+			click		: definition.click || function( editor )
+				{
+					editor.execCommand( definition.command );
+				}
+		});
 
 	this._ = {};
@@ -119,4 +87,6 @@
 			}
 		};
+		
+		var clickFn = CKEDITOR.tools.addFunction( instance.execute, instance );
 
 		var index = CKEDITOR.ui.button._.instances.push( instance ) - 1;
@@ -139,5 +109,5 @@
 					}, this);
 
-				classes += ' cke_' + (
+				classes += 'cke_' + (
 					command.state == CKEDITOR.TRISTATE_ON ? 'on' :
 					command.state == CKEDITOR.TRISTATE_DISABLED ? 'disabled' :
@@ -145,4 +115,7 @@
 			}
 		}
+		
+		if ( !command )
+			classes	+= 'cke_off';
 
 		if ( this.className )
@@ -177,5 +150,5 @@
 				' onkeydown="return CKEDITOR.ui.button._.keydown(', index, ', event);"' +
 				' onfocus="return CKEDITOR.ui.button._.focus(', index, ', event);"' +
-				' onclick="return CKEDITOR.ui.button._.click(', index, ', event);">' +
+				' onclick="CKEDITOR.tools.callFunction(', clickFn, ', this); return false;">' +
 					'<span class="cke_icon"' );
 
@@ -188,8 +161,19 @@
 		output.push(
 					'></span>' +
-					'<span class="cke_label">', this.label, '</span>' +
+					'<span class="cke_label">', this.label, '</span>' );
+
+		if ( this.hasArrow )
+		{
+			output.push(
+					'<span class="cke_buttonarrow"></span>' );
+		}
+
+		output.push(
 			'</a>',
 			'</span>' );
 
+		if ( this.onRender )
+			this.onRender();
+
 		return instance;
 	},
@@ -213,10 +197,4 @@
 {
 	instances : [],
-
-	click : function( index )
-	{
-		CKEDITOR.ui.button._.instances[ index ].execute();
-		return false;
-	},
 
 	keydown : function( index, ev )
Index: /CKEditor/trunk/_source/plugins/contextmenu/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/contextmenu/plugin.js	(revision 3515)
+++ /CKEditor/trunk/_source/plugins/contextmenu/plugin.js	(revision 3516)
@@ -40,5 +40,5 @@
 	_ :
 	{
-		onMenu : function( offsetParent, offsetX, offsetY )
+		onMenu : function( offsetParent, corner, offsetX, offsetY )
 		{
 			var menu = this._.menu,
@@ -55,6 +55,4 @@
 				menu.onClick = CKEDITOR.tools.bind( function( item )
 				{
-					menu.onHide = null;
-
 					var noUnlock = true;
 					menu.hide();
@@ -89,11 +87,16 @@
 			// menu.
 			if ( CKEDITOR.env.ie )
-			{
 				selection.lock();
-				menu.onHide = function()
+
+			menu.onHide = CKEDITOR.tools.bind( function()
 				{
-					editor.getSelection().unlock();
-				};
-			}
+					menu.onHide = null;
+
+					if ( CKEDITOR.env.ie )
+						editor.getSelection().unlock();
+					
+					this.onHide && this.onHide();
+				},
+				this );
 
 			// Call all listeners, filling the list of items to be displayed.
@@ -117,5 +120,5 @@
 			}
 
-			menu.show( offsetParent, editor.lang.dir == 'rtl' ? 2 : 1, offsetX, offsetY );
+			menu.show( offsetParent, corner || ( editor.lang.dir == 'rtl' ? 2 : 1 ), offsetX, offsetY );
 		}
 	},
@@ -138,5 +141,5 @@
 					CKEDITOR.tools.setTimeout( function()
 						{
-							this._.onMenu( offsetParent, offsetX, offsetY );
+							this._.onMenu( offsetParent, null, offsetX, offsetY );
 						},
 						0, this );
@@ -150,8 +153,8 @@
 		},
 
-		show : function()
+		show : function( offsetParent, corner, offsetX, offsetY )
 		{
 			this.editor.focus();
-			this._.onMenu( CKEDITOR.document.getDocumentElement(), 0, 0 );
+			this._.onMenu( offsetParent || CKEDITOR.document.getDocumentElement(), corner, offsetX || 0, offsetY || 0 );
 		}
 	}
Index: /CKEditor/trunk/_source/plugins/menu/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/menu/plugin.js	(revision 3515)
+++ /CKEditor/trunk/_source/plugins/menu/plugin.js	(revision 3516)
@@ -21,4 +21,9 @@
 CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
 {
+	addMenuGroup : function( name, order )
+	{
+		this._.menuGroups[ name ] = order || 100;
+	},
+
 	addMenuItem : function( name, definition )
 	{
@@ -172,4 +177,10 @@
 							var item = this.items[ index ];
 
+							if ( item.state == CKEDITOR.TRISTATE_DISABLED )
+							{
+								this.hide();
+								return;
+							}
+
 							if ( item.getItems )
 								this._.showSubMenu( index );
@@ -259,5 +270,5 @@
 		{
 			var id = menu.id + String( index ),
-				state = this.state || CKEDITOR.TRISTATE_OFF;
+				state = ( typeof this.state == 'undefined' ) ? CKEDITOR.TRISTATE_OFF : this.state;
 
 			var classes = ' cke_' + (
Index: /CKEditor/trunk/_source/plugins/menubutton/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/menubutton/plugin.js	(revision 3516)
+++ /CKEditor/trunk/_source/plugins/menubutton/plugin.js	(revision 3516)
@@ -0,0 +1,93 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+CKEDITOR.plugins.add( 'menubutton',
+{
+	requires : [ 'button' ],
+	beforeInit : function( editor )
+	{
+		editor.ui.addHandler( CKEDITOR.UI_MENUBUTTON, CKEDITOR.ui.menuButton.handler );
+	}
+});
+
+/**
+ * Button UI element.
+ * @constant
+ * @example
+ */
+CKEDITOR.UI_MENUBUTTON = 5;
+
+(function()
+{
+	var clickFn = function( editor )
+	{
+		var _ = this._;
+
+		// Do nothing if this button is disabled.
+		if ( _.state === CKEDITOR.TRISTATE_DISABLED )
+			return;
+		
+		_.previousState = _.state;
+
+		// Check if we already have a menu for it, otherwise just create it.
+		var menu = _.menu;
+		if ( !menu )
+		{
+			menu = _.menu = new CKEDITOR.plugins.contextMenu( editor );
+
+			menu.onHide = CKEDITOR.tools.bind( function()
+				{
+					this.setState( _.previousState );
+				},
+				this );
+
+			// Initialize the menu items at this point.
+			if ( this.onMenu )
+			{
+				menu.addListener( this.onMenu );
+			}
+		}
+
+		if ( _.on )
+		{
+			menu.hide();
+			return;
+		}
+
+		this.setState( CKEDITOR.TRISTATE_ON );
+
+		menu.show( CKEDITOR.document.getById( this._.id ), 4 );
+	};
+
+
+	CKEDITOR.ui.menuButton = CKEDITOR.tools.createClass(
+	{
+		base : CKEDITOR.ui.button,
+
+		$ : function( definition )
+		{
+			// We don't want the panel definition in this object.
+			var panelDefinition = definition.panel;
+			delete definition.panel;
+
+			this.base( definition );
+			
+			this.hasArrow = true;
+
+			this.click = clickFn;
+		},
+
+		statics :
+		{
+			handler :
+			{
+				create : function( definition )
+				{
+					return new CKEDITOR.ui.menuButton( definition );
+				}
+			}
+		}
+	});
+})();
Index: /CKEditor/trunk/_source/plugins/panelbutton/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/panelbutton/plugin.js	(revision 3515)
+++ /CKEditor/trunk/_source/plugins/panelbutton/plugin.js	(revision 3516)
@@ -20,201 +20,116 @@
 CKEDITOR.UI_PANELBUTTON = 4;
 
-CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass(
+(function()
 {
-	$ : function( definition )
+	var clickFn = function( editor )
 	{
-		// Copy all definition properties to this object.
-		CKEDITOR.tools.extend( this, definition,
-			// Set defaults.
+		var _ = this._;
+
+		if ( _.state == CKEDITOR.TRISTATE_DISABLED )
+			return;
+
+		this.createPanel( editor );
+
+		if ( _.on )
+		{
+			_.panel.hide();
+			return;
+		}
+
+		_.panel.showBlock( this._.id, this.document.getById( this._.id ), 4 );
+	};
+
+
+	CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass(
+	{
+		base : CKEDITOR.ui.button,
+
+		$ : function( definition )
+		{
+			// We don't want the panel definition in this object.
+			var panelDefinition = definition.panel;
+			delete definition.panel;
+
+			this.base( definition );
+
+			this.document = ( panelDefinition
+								&& panelDefinition.parent
+								&& panelDefinition.parent.getDocument() )
+							|| CKEDITOR.document;
+			
+			this.hasArrow = true;
+
+			this.click = clickFn;
+
+			this._ =
 			{
-				title : definition.label,
-				modes : { wysiwyg : 1 }
-			});
+				panelDefinition : panelDefinition
+			};
+		},
 
-		// We don't want the panel definition in this object.
-		var panelDefinition = this.panel;
-		delete this.panel;
+		statics :
+		{
+			handler :
+			{
+				create : function( definition )
+				{
+					return new CKEDITOR.ui.panelButton( definition );
+				}
+			}
+		},
 
-		this.document = ( panelDefinition
-							&& panelDefinition.parent
-							&& panelDefinition.parent.getDocument() )
-						|| CKEDITOR.document;
-		this._ =
+		proto :
 		{
-			panelDefinition : panelDefinition
-		};
-	},
+			createPanel : function( editor )
+			{
+				var _ = this._;
 
-	statics :
-	{
-		handler :
-		{
-			create : function( definition )
-			{
-				return new CKEDITOR.ui.panelButton( definition );
+				if ( _.panel )
+					return;
+
+				var panelDefinition = this._.panelDefinition || {},
+					panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
+					panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),
+					me = this;
+
+				panel.onShow = function()
+					{
+						if ( me.className )
+							this.element.getFirst().addClass( me.className + '_panel' );
+
+						_.oldState = me._.state;
+						me.setState( CKEDITOR.TRISTATE_ON );
+
+						_.on = 1;
+
+						if ( me.onOpen )
+							me.onOpen();
+					};
+
+				panel.onHide = function()
+					{
+						if ( me.className )
+							this.element.getFirst().removeClass( me.className + '_panel' );
+
+						me.setState( _.oldState );
+
+						_.on = 0;
+
+						if ( me.onClose )
+							me.onClose();
+					};
+
+				panel.onEscape = function()
+					{
+						panel.hide();
+						me.document.getById( _.id ).focus();
+					};
+
+
+				if ( this.onBlock )
+					this.onBlock( panel, _.id );
 			}
 		}
-	},
+	});
 
-	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._;
-
-					if ( _.state == CKEDITOR.TRISTATE_DISABLED )
-						return;
-
-					this.createPanel( editor );
-
-					if ( _.on )
-					{
-						_.panel.hide();
-						return;
-					}
-
-					_.panel.showBlock( this._.id, new CKEDITOR.dom.element( $element ), 4 );
-				},
-				this );
-			var keyDownFn = CKEDITOR.tools.addFunction( function( ev, element ){
-
-				ev = new CKEDITOR.dom.event( ev );
-
-				var keystroke = ev.getKeystroke();
-				switch ( keystroke )
-				{
-					case 13 :	// ENTER
-					case 32 :	// SPACE
-					case 40 :	// ARROW-DOWN
-						// Show panel
-						CKEDITOR.tools.callFunction( clickFn, element );
-						break;
-					default :
-						// Delegate the default behavior to toolbar button key handling.
-						instance.onkey( instance,  keystroke );
-				}
-
-				// Avoid subsequent focus grab on editor document.
-				ev.preventDefault();
-			});
-
-			var label = this.label || '';
-
-			var classes = 'cke_off';
-
-			if ( this.className )
-				classes += ' ' + this.className;
-
-			editor.on( 'mode', function()
-				{
-					this.setState( this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
-				},
-				this );
-
-			output.push(
-				'<span class="cke_button">',
-				'<a id="', id, '"' +
-					' class="', classes, '" href="javascript:void(\'', ( this.title || '' ).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="CKEDITOR.tools.callFunction( ', keyDownFn, ', event, this );"' +
-					' onclick="CKEDITOR.tools.callFunction(', clickFn, ', this); return false;">' +
-						'<span class="cke_icon"></span>' +
-						'<span class="cke_label">', this.label, '</span>' +
-						'<span class="cke_buttonarrow"></span>' +
-				'</a>' +
-				'</span>' );
-
-			return instance;
-		},
-
-		createPanel : function( editor )
-		{
-			var _ = this._;
-
-			if ( _.panel )
-				return;
-
-			var panelDefinition = this._.panelDefinition || {},
-				panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
-				panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),
-				me = this;
-
-			panel.onShow = function()
-				{
-					if ( me.className )
-						this.element.getFirst().addClass( me.className + '_panel' );
-
-					me.setState( CKEDITOR.TRISTATE_ON );
-
-					_.on = 1;
-
-					if ( me.onOpen )
-						me.onOpen();
-				};
-
-			panel.onHide = function()
-				{
-					if ( me.className )
-						this.element.getFirst().removeClass( me.className + '_panel' );
-
-					me.setState( CKEDITOR.TRISTATE_OFF );
-
-					_.on = 0;
-
-					if ( me.onClose )
-						me.onClose();
-				};
-
-			panel.onEscape = function()
-				{
-					panel.hide();
-					me.document.getById( _.id ).focus();
-				};
-
-
-			if ( this.onBlock )
-				this.onBlock( panel, _.id );
-		},
-
-		setState : CKEDITOR.ui.button.prototype.setState
-	}
-});
+})();
Index: /CKEditor/trunk/_source/plugins/scayt/dialogs/options.js
===================================================================
--- /CKEditor/trunk/_source/plugins/scayt/dialogs/options.js	(revision 3516)
+++ /CKEditor/trunk/_source/plugins/scayt/dialogs/options.js	(revision 3516)
@@ -0,0 +1,313 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/ 
+
+CKEDITOR.dialog.add( 'scaytcheck', function( editor )
+{
+	var firstLoad = true,
+		captions,
+		doc = CKEDITOR.document,
+		fckLang = "en";
+
+	var init_with_captions = function()
+	{
+		var dialog = this,
+			lang_list = dialog.data.scayt.getLangList(),
+			buttons = [ 'dic_create','dic_delete','dic_rename','dic_restore' ],
+			labels = [ 'mixedCase','mixedWithDigits','allCaps','ignoreDomainNames' ];
+
+/*
+		// Add buttons titles
+		for ( var i in buttons )
+		{
+			var button = buttons[ i ];
+			doc.getById( button ).setHtml( captions[ "button_" + button] );
+		}
+		doc.getById( "dic_info" ).setHtml( captions[ "dic_info" ] );
+*/
+
+		// Fill options and dictionary labels.
+		for ( var i in labels )
+		{
+			var label = "label_" + labels[ i ];
+			var labelElement = doc.getById( label );
+			if ( labelElement )
+				labelElement.setHtml( captions[ label ] );
+		}
+		
+		var about = '<p>' + captions[ "about_throwt_image" ] + '</p>'+
+					'<p>' + captions[ "version" ]  + dialog.data.scayt.version.toString() + '</p>' +
+					'<p>' + captions[ "about_throwt_copy" ] + '</p>';
+
+		doc.getById( "scayt_about" ).setHtml( about );
+
+		// Create languages tab.
+		var createOption = function( option, list )
+		{
+			var label = doc.createElement( 'label' );
+			label.setAttribute( 'for', 'cke_option' + option );
+			label.setHtml( list[ option ] ); 
+
+			if ( dialog.sLang == option )	// Current.
+				dialog.chosed_lang = option;
+
+			var div = doc.createElement( 'div' );
+				radio = CKEDITOR.dom.element.createFromHtml( '<input id="cke_option' + 
+					option + '" type="radio" ' + 
+					( dialog.sLang == option ? 'checked="checked"' : '' ) +
+					' value="' + option + '" name="scayt_lang" />' );
+
+			radio.on( 'click', function()
+				{
+					this.$.checked = true;
+					dialog.chosed_lang = option;
+				});
+
+			div.append( radio );
+			div.append( label );
+
+			return {
+				lang : list[ option ],
+				code : option,
+				radio : div
+			}
+		};
+
+		var langList = [];
+		for ( var i in lang_list.rtl )
+			langList[ langList.length ] = createOption( i, lang_list.ltr )
+
+		for ( var i in lang_list.ltr )
+			langList[ langList.length  ] = createOption( i, lang_list.ltr )
+
+		langList.sort( 	function( lang1, lang2 )
+			{
+				return ( lang2.lang > lang1.lang ) ? -1 : 1 ;
+			});
+
+		var fieldL = doc.getById( 'scayt_lcol' ),
+			fieldR = doc.getById( 'scayt_rcol' );
+		for ( var i=0; i < langList.length; i++ )
+		{
+			var field = ( i < langList.length / 2 ) ? fieldL : fieldR;
+			field.append( langList[ i ].radio );
+		}
+	};
+	var reload = function()
+	{
+		var dialog = this;
+
+		// Animate options.
+		for ( var i in dialog.options )
+		{
+			var checkbox = doc.getById( i );
+			if ( checkbox )
+			{
+				checkbox.removeAttribute( 'checked' );
+				if ( dialog.options[ i ] == 1 )
+					checkbox.setAttribute( 'checked', "checked" );
+
+				// Bind events. Do it only once.
+				if ( firstLoad )
+				{
+					checkbox.on( 'click', function()
+						{
+							dialog.options[ this.getId() ] = this.$.checked ? 1 : 0 ;
+						} )
+				}
+			}
+		}
+
+		// * user dictionary    
+		var dic_buttons = [
+			// [0] contains buttons for creating
+			"dic_create,dic_restore",
+			// [1] contains buton for manipulation 
+			"dic_rename,dic_delete,dic_restore"
+		];
+		scayt.getNameUserDictionary(
+			function( o )
+			{
+				var dic_name = o.dname;
+				if ( dic_name )
+				{
+					dojo.byId( 'dic_name' ).value = dic_name;
+					display_dic_buttons( dic_buttons[1] );
+				}
+				else
+					display_dic_buttons( dic_buttons[0] );
+				
+			},
+			function () {
+			});
+
+		var dic_flag = 0; 
+		 // ** bind event listeners
+		dojo.query("div.dic_buttons a.button").onclick(function( ev )
+			{
+				if (typeof window[this.id] == 'function'  ){
+					// get dic name
+					var dic_name = dojo.trim ( dojo.byId('dic_name').value );
+					// check common dictionary rules
+					if (!dic_name)
+					{
+						dic_error_message( editor.lang.scayt.emptyDic );
+						return false;
+					}
+					//apply handler
+					window[this.id].apply( window, [this,ev , dic_name, dic_buttons ] );
+				}
+				//console.info( typeof window[this.id], window[this.id].calle )
+				return false;
+			});
+	};
+
+    return {
+           title : editor.lang.scayt.title,
+           minWidth : 340,
+           minHeight : 200,
+           onShow : function()
+		   {
+				var dialog = this;
+				dialog.data = editor.fire( "scaytDialog", {} );
+				dialog.options = dialog.data.scayt_control.option();
+				dialog.sLang = dialog.data.scayt_control.sLang;
+
+				if ( !dialog.data || !dialog.data.scayt || !dialog.data.scayt_control ) 
+				{
+					alert( "Error loading application service" );
+					dialog.hide();
+					return;
+				}
+
+				var stop = 0;
+				if ( firstLoad )
+				{
+					dialog.data.scayt.getCaption( 'en', function( caps )
+						{
+							if ( stop++ > 0 )	// Once only
+								return;
+							captions = caps;
+							init_with_captions.apply( dialog );
+							reload.apply( dialog );
+							firstLoad = false;
+						});
+				}
+				else
+					reload.apply( dialog );
+
+				dialog.selectPage( dialog.data.tab );
+			},
+			onOk : function()
+			{
+				var scayt_control =  this.data.scayt_control;
+					o = scayt_control.option();
+					c = 0;
+
+				// Set upp options if any was set.
+				for ( var oN in this.options ) 
+				{
+					if (o[oN] != this.options[ oN ] && c == 0 )
+					{
+						scayt_control.option( this.options );
+						c++;
+					}
+				}
+
+				// Setup languge if it was changed.
+				var csLang = this.chosed_lang;
+				if ( csLang && this.data.sLang != csLang )
+				{
+					scayt_control.setLang( csLang );
+					c++;
+				}
+				if ( c > 0 )
+					scayt_control.refresh();
+			},
+			contents : [
+				{
+					id : 'options',
+					label : editor.lang.scayt.optionsTab,
+					elements : [
+						{
+							type : 'html',
+							id : 'options',
+							html : 	'<div class="inner_options">' +
+									'	<div class="messagebox"></div>' +
+									'	<div>' +
+									'		<input type="checkbox" value="0" id="allCaps" />' +
+									'		<label for="allCaps" id="label_allCaps"></label>' +
+									'	</div>' +
+									'	<div>' +
+									'		<input type="checkbox" value="0" id="ignoreDomainNames" />' +
+									'		<label for="ignoreDomainNames" id="label_ignoreDomainNames"></label>' +
+									'	</div>' +
+									'	<div>' +
+									'	<input type="checkbox" value="0" id="mixedCase" />' +
+									'		<label for="mixedCase" id="label_mixedCase"></label>' +
+									'	</div>' +
+									'	<div>' +
+									'		<input type="checkbox" value="0" id="mixedWithDigits" />' +
+									'		<label for="mixedWithDigits" id="label_mixedWithDigits"></label>' +
+									'	</div>' +
+									'</div>'
+						}
+					]
+				},
+				{
+					id : 'langs',
+					label : editor.lang.scayt.languagesTab,
+					elements : [
+						{
+							type : 'html',
+							id : 'langs',
+							html : 	'<div class="inner_langs">' +
+									'	<div class="messagebox"></div>	' +
+									'   <div style="float:left;width:47%;margin-left:5px;" id="scayt_lcol" ></div>' +
+									'   <div style="float:left;width:47%;margin-left:15px;" id="scayt_rcol"></div>' +
+									'</div>'
+						}
+					]
+				},
+				/*
+				{
+					id : 'dictionaries',
+					label : editor.lang.scayt.dictionariesTab,
+					elements : [
+						{
+							type : 'html',
+							style: '',
+							id : 'dic',
+							html : 	'<div class="inner_dictionary">' +
+									'	<div class="messagebox" id="dic_message"></div>' +
+									'	<div class="dictionary" > ' +
+									'		<label for="dname" id="dname"></label>' +
+									'		<input type="text" size="14" maxlength="15" value="" id="dic_name" name="dic_name"/>' +
+									'		<div class="dic_buttons">' +
+									'			<a href="javascript:void(0)" id="dic_create" class="button"></a>' +
+									'			<a href="javascript:void(0)" id="dic_delete" class="button"></a>' +
+									'			<a href="javascript:void(0)" id="dic_rename" class="button"></a>' +
+									'			<a href="javascript:void(0)" id="dic_restore" class="button"></a>' +
+									'		</div>' +
+									'	</div><p id="dic_info"></p>' +
+									'</div>'
+						}
+					]
+				},
+				*/
+				{
+					id : 'about',
+					label : editor.lang.scayt.aboutTab,
+					elements : [
+						{
+							type : 'html',
+							id : 'about',
+							style : "margin: 10px 40px;",
+							html : '<div id="scayt_about"></div>'
+						}
+					]
+				}
+			]
+        };
+});
Index: /CKEditor/trunk/_source/plugins/scayt/dialogs/toolbar.css
===================================================================
--- /CKEditor/trunk/_source/plugins/scayt/dialogs/toolbar.css	(revision 3516)
+++ /CKEditor/trunk/_source/plugins/scayt/dialogs/toolbar.css	(revision 3516)
@@ -0,0 +1,71 @@
+a
+{
+	text-decoration:none;
+	padding: 2px 4px 4px 6px;
+	display : block;
+	border-width: 1px;
+	border-style: solid;
+	margin : 0px;
+}
+
+a.cke_scayt_toogle:hover,
+a.cke_scayt_toogle:focus,
+a.cke_scayt_toogle:active
+{
+	border-color: #316ac5;
+	background-color: #dff1ff;
+	color : #000;
+	cursor: pointer;
+	margin : 0px;
+}
+a.cke_scayt_toogle {
+	color : #316ac5;
+	border-color: #fff;
+}
+.scayt_enabled a.cke_scayt_item {
+	color : #316ac5;
+	border-color: #fff;
+	margin : 0px;
+}
+.scayt_disabled a.cke_scayt_item {
+	color : gray;
+	border-color : #fff;
+}
+.scayt_enabled a.cke_scayt_item:hover,
+.scayt_enabled a.cke_scayt_item:focus,
+.scayt_enabled a.cke_scayt_item:active
+{
+	border-color: #316ac5;
+	background-color: #dff1ff;
+	color : #000;
+	cursor: pointer;
+}
+.scayt_disabled a.cke_scayt_item:hover,
+.scayt_disabled a.cke_scayt_item:focus,
+.scayt_disabled a.cke_scayt_item:active
+{
+	border-color: gray;
+	background-color: #dff1ff;
+	color : gray;
+	cursor: no-drop;
+}
+.cke_scayt_set_on, .cke_scayt_set_off
+{
+	display: none;
+}
+.scayt_enabled .cke_scayt_set_on
+{
+	display: none;
+}
+.scayt_disabled .cke_scayt_set_on
+{
+	display: inline;
+}
+.scayt_disabled .cke_scayt_set_off
+{
+	display: none;
+}
+.scayt_enabled  .cke_scayt_set_off
+{
+	display: inline;
+}
Index: /CKEditor/trunk/_source/plugins/scayt/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/scayt/plugin.js	(revision 3516)
+++ /CKEditor/trunk/_source/plugins/scayt/plugin.js	(revision 3516)
@@ -0,0 +1,447 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Spell Check As You Type (SCAYT).
+ * Button name : Scayt.
+ */
+
+(function()
+{
+	var commandName 	= "scaytcheck",
+		sc_on_cssclass 	= "scayt_enabled",
+		sc_off_cssclass = 'scayt_disabled',
+		openPage		= '';
+
+	var onEngineLoad = function()
+	{
+		var editor = this;
+		dojo.requireLocalization( 'scayt', 'caption', '', "ROOT" );
+
+		var createInstnce = function()	// Create new instance every time Document is created.
+		{
+			// Initialise Scayt instance.
+			var scayt_control = new scayt(
+				{
+					srcNodeRef: editor.document.getWindow().$.frameElement
+				});
+
+			// Copy config.
+			var	lastInstance = plugin.instances[ editor.name ]
+			if ( lastInstance )
+			{
+				scayt_control.sLang = lastInstance.sLang;
+				scayt_control.option( lastInstance.option() );
+				scayt_control.paused = lastInstance.paused;
+			}
+
+			plugin.instances[ editor.name ] = scayt_control;
+
+			try {
+				scayt_control.setDisabled( scayt_control.paused === false );				// I really don't know why it couse JS error in IE
+			} catch (e) {}
+		};
+
+		editor.on( 'contentDom', createInstnce )		// Get the iframe somehow.
+		editor.on( 'contentDomUnload', function()
+			{
+				// Remove scripts.
+				var scripts = CKEDITOR.document.getElementsByTag( 'script' );
+				scaytIdRegex =  /^dojoIoScript(\d+)$/i;
+				scaytSrcRegex =  /^http:\/\/demo\.spellchecker\.net\/spellcheck3\/script\/ssrv\.cgi/i;
+
+				for ( var i=0; i < scripts.count(); i++ )
+				{
+					var script = scripts.getItem( i ),
+						id = script.getId(),
+						src = script.getAttribute( 'src' );
+
+					if ( id && src && id.match( scaytIdRegex ) && src.match( scaytSrcRegex ))
+						script.remove();
+				}
+			})
+
+		editor.on( 'beforeCommandExec', function( ev )		// Disable SCAYT before Source command execution.
+			{
+				if ( ev.data.name == 'source' && editor.mode == 'wysiwyg' )
+				{
+					var scayt = plugin.getScayt( editor )
+					if ( scayt )
+					{
+						scayt.paused = !scayt.disabled;
+						scayt.setDisabled( true );
+					}
+				}
+			});
+
+		// Listen to data manipulation to reflect scayt markup.
+		editor.on( 'beforeGetData', function()
+			{
+				if ( plugin.isScaytEnabled( editor ) )
+					plugin.getScayt( editor ).refresh();
+			});
+
+		editor.on( 'afterSetData', function()
+			{
+				if ( plugin.isScaytEnabled( editor ) )
+					plugin.getScayt( editor ).refresh();
+			});
+
+		editor.on( 'scaytDialog', function( ev )	// Communication with dialog.
+			{
+				ev.data.djConfig = djConfig;
+				ev.data.scayt_control = plugin.getScayt( editor );
+				ev.data.tab = openPage;
+				ev.data.scayt = scayt;
+			});
+
+		if ( editor.document )
+		{
+			createInstnce();
+			editor.fire( 'showScaytState' );
+		}
+	};
+
+	CKEDITOR.plugins.scayt =
+	{
+		engineLoaded : false,
+		instances : {},
+		getScayt : function( editor )
+		{
+			var instance = this.instances[ editor.name ];
+			return instance;
+		},
+		isScaytReady : function( editor )
+		{
+			return this.engineLoaded === true &&
+				'undefined' !== typeof scayt && this.getScayt( editor );
+		},
+		isScaytEnabled : function( editor ) 
+		{
+			var scayt = this.getScayt( editor );
+			return ( scayt ) ? scayt.disabled === false : false;
+		},
+		loadEngine : function( editor )
+		{
+			if ( this.engineLoaded === true )
+				return onEngineLoad.apply( editor );	// Add new instance.
+			else if ( this.engineLoaded == -1 )			// We are waiting.
+				return CKEDITOR.on( "scaytReady", function(){ onEngineLoad.apply( editor )} );	// Use function(){} to avoid rejection as duplicate.
+
+			CKEDITOR.on( "scaytReady", onEngineLoad, editor );
+			CKEDITOR.on( "scaytReady", function()
+				{
+					this.engineLoaded = true;
+				},
+				this, 
+				null, 
+				0 );	// First to run.
+
+			this.engineLoaded = -1;	// Loading in progress.
+			djConfig = 
+			{
+				baseUrl: "./",
+				blankGif: "http://demo.spellchecker.net/spellcheck3/lf/scayt/blank.gif",
+				parseOnLoad: true,
+				afterOnLoad: true,
+				useXDomain: true,
+				locale: 'en',
+				xdWaitSeconds: 10,
+				preventCache: false,
+				scaytNodes: document.getElementById('foo'),
+				require: [
+					"dojo.i18n",
+					"scayt._base"
+				],
+				modulePaths:
+				{
+					"scayt": "http://demo.spellchecker.net/spellcheck3/lf/scayt"
+				},
+				addOnLoad: 
+				[
+					function()
+					{
+						CKEDITOR.fireOnce( "scaytReady" );
+					}
+				],
+				isDebug: false
+			};
+
+			// Append javascrip code.
+			CKEDITOR.document.getHead().append( 
+				CKEDITOR.document.createElement( 'script',
+					{
+						attributes :
+							{
+								type : 'text/javascript',
+								src : "http://demo.spellchecker.net/spellcheck3/lf/dojo/dojo/dojo.xd.js"
+							}
+					})
+			);
+		}
+	};
+
+	var plugin = CKEDITOR.plugins.scayt;
+
+	// Context menu constructing.
+	var addButtonCommand = function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder )
+	{
+		editor.addCommand( commandName, command );
+
+		// If the "menu" plugin is loaded, register the menu item.
+		editor.addMenuItem( commandName,
+			{
+				label : buttonLabel,
+				command : commandName,
+				group : menugroup,
+				order : menuOrder
+			});
+	};
+
+	var commandDefinition = 
+	{
+		preserveState : true,
+
+		exec: function( editor )
+		{
+			if ( plugin.isScaytReady( editor ) )
+			{
+				var isEnabled = plugin.isScaytEnabled( editor );
+				
+				this.setState( isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_ON );
+
+				var scayt_control = plugin.getScayt( editor );
+				scayt_control.setDisabled( isEnabled );
+			}
+			else if ( !editor.config.scayt_autoStartup && plugin.engineLoaded >= 0 )	// Load first time
+			{
+				this.setState( CKEDITOR.TRISTATE_DISABLED );
+				
+				editor.on( 'showScaytState', function()
+					{
+						this.removeListener();
+						this.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );
+					},
+					this);
+				
+				plugin.loadEngine( editor );
+			}
+		}
+	};
+	
+	// Add scayt plugin.
+	CKEDITOR.plugins.add( 'scayt',
+	{
+		requires : [ 'menubutton' ],
+
+		beforeInit : function( editor )
+		{
+			// Register own rbc menu group.
+			editor.config.menu_groups = 'scayt_suggest,scayt_moresuggest,scayt_control,' + editor.config.menu_groups;
+		},
+
+		init : function( editor )
+		{
+			var moreSuggestions = {};
+			var mainSuggestions = {};
+
+			// Scayt command.
+			var command = editor.addCommand( commandName, commandDefinition );
+
+			// Add Options dialog.
+			CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) );
+
+			var menuGroup = 'scaytButton';
+			editor.addMenuGroup( menuGroup );
+			editor.addMenuItems(
+				{
+					scaytToggle : 
+					{
+						label : editor.lang.scayt.enable,
+						command : commandName,
+						group : menuGroup
+					},
+					
+					scaytOptions : 
+					{
+						label : editor.lang.scayt.options,
+						group : menuGroup,
+						onClick : function()
+						{
+							openPage = 'options';
+							editor.openDialog( commandName );
+						}
+					},
+					
+					scaytLangs : 
+					{
+						label : editor.lang.scayt.langs,
+						group : menuGroup,
+						onClick : function()
+						{
+							openPage = 'langs';
+							editor.openDialog( commandName );
+						}
+					},
+					
+					scaytAbout :
+					{
+						label : editor.lang.scayt.about,
+						group : menuGroup,
+						onClick : function()
+						{
+							openPage = 'about';
+							editor.openDialog( commandName );
+						}
+					}
+				});
+
+			editor.ui.add( "Scayt", CKEDITOR.UI_MENUBUTTON,
+				{
+					label : editor.lang.scayt.title,
+					title : editor.lang.scayt.title,
+					className : 'cke_button_scayt',
+					onRender: function()
+					{
+						command.on( 'state', function()
+							{
+								this.setState( command.state );
+							},
+							this);
+					},
+					onMenu : function()
+					{
+						var isEnabled = plugin.isScaytEnabled( editor );
+
+						editor.getMenuItem( 'scaytToggle' ).label = editor.lang.scayt[ isEnabled ? 'disable' : 'enable' ];
+
+						return {
+							scaytToggle : CKEDITOR.TRISTATE_OFF,
+							scaytOptions : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
+							scaytLangs : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
+							scaytAbout : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED 
+						};
+					}
+				});
+
+			// If the "contextmenu" plugin is loaded, register the listeners.
+			if ( editor.contextMenu && editor.addMenuItems )
+			{
+				editor.contextMenu.addListener( function( element, selection )
+					{
+						var scayt_control = plugin.getScayt( editor );
+						if ( !plugin.isScaytEnabled( editor ) || !element || !element.$ )
+							return null;
+
+						var word = scayt_control.getWord( element.$ );
+
+						if ( !word ) 
+							return null;
+
+						var sLang = scayt_control.getLang(),
+							_r = {},
+							items_suggestion = scayt.getSuggestion( word, sLang );
+
+						// Remove unused commands and menuitems
+						for ( i in moreSuggestions )
+						{
+							delete editor._.menuItems[ i ];
+							delete editor._.commands[ i ];
+						}
+						for ( i in mainSuggestions )
+						{
+							delete editor._.menuItems[ i ];
+							delete editor._.commands[ i ];
+						}
+						moreSuggestions = {};		// Reset items.
+						mainSuggestions = {};
+
+						// Rgister the More suggestions group;
+						editor.addMenuItem( 'scayt_moresuggest',
+							{
+								label : editor.lang.scayt.moreSuggestions,
+								group : 'scayt_moresuggest',
+								order : 10,
+								getItems : function()
+								{
+									return moreSuggestions;
+								}
+							});
+
+						for ( var i = 0, l = items_suggestion.length; i < l; i += 1 )
+						{
+							var commandName = 'scayt_suggestion_' + items_suggestion[i].replace( " ", "_" );
+							var exec = ( function( el, s )
+								{
+									return {
+										exec: function( editor )
+										{
+											scayt_control.replace(el, s);
+										}
+									};
+								})( element.$, items_suggestion[i] );
+
+							if ( i < editor.config.scayt_maxSuggestions )
+							{
+								addButtonCommand( editor, "button_" + commandName, items_suggestion[i], 
+									commandName, exec, 'scayt_suggest', i + 1 );
+								_r[ commandName ] = CKEDITOR.TRISTATE_OFF;
+								mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
+							}
+							else
+							{
+								addButtonCommand( editor, "button_" + commandName, items_suggestion[i], 
+									commandName, exec, 'scayt_moresuggest', i + 1 );
+								moreSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
+							}
+						}
+
+						var ignore_command =
+						{
+							exec: function()
+							{
+								scayt_control.ignore( element.$ );
+							}
+						};
+						var ignore_all_command =
+						{
+							exec: function()
+							{
+								scayt_control.ignoreAll( element.$ );
+							}
+						};
+						var addword_command =
+						{
+							exec: function()
+							{
+								scayt.addWordToUserDictionary( element.$ );
+							}
+						};
+
+						addButtonCommand( editor, "ignore", editor.lang.scayt.ignore, 
+							'scayt_ignore', ignore_command, 'scayt_control', 1);
+						addButtonCommand( editor, "ignore_all", editor.lang.scayt.ignoreAll, 
+							'scayt_ignore_all', ignore_all_command, 'scayt_control', 2);
+						addButtonCommand( editor, "add_word", editor.lang.scayt.addWord, 
+							'scayt_add_word', addword_command, 'scayt_control', 3);
+
+						mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF;
+						mainSuggestions[ 'scayt_ignore' ] = CKEDITOR.TRISTATE_OFF;
+						mainSuggestions[ 'scayt_ignore_all' ] = CKEDITOR.TRISTATE_OFF;
+						mainSuggestions[ 'scayt_add_word' ] = CKEDITOR.TRISTATE_OFF;
+
+						return mainSuggestions;
+					});
+			}
+
+			// Start plugin
+			if ( editor.config.scayt_autoStartup )
+				plugin.loadEngine( editor );
+		}
+	});
+})();
+
+CKEDITOR.config.scayt_maxSuggestions = 5;
+CKEDITOR.config.scayt_autoStartup = false;
Index: /CKEditor/trunk/_source/plugins/showblocks/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/showblocks/plugin.js	(revision 3515)
+++ /CKEditor/trunk/_source/plugins/showblocks/plugin.js	(revision 3516)
@@ -89,12 +89,16 @@
 	var commandDefinition =
 	{
+		preserveState : true,
+
 		exec : function ( editor )
 		{
-			var isOn = ( this.state == CKEDITOR.TRISTATE_ON );
-			var funcName = isOn ? 'removeClass' : 'addClass';
+			this.toggleState();
+			this.refresh( editor );
+		},
+		
+		refresh : function( editor )
+		{
+			var funcName = ( this.state == CKEDITOR.TRISTATE_ON ) ? 'addClass' : 'removeClass';
 			editor.document.getBody()[funcName]( 'cke_show_blocks' );
-
-			this.toggleState();
-			editor._.showBlocks = !isOn;
 		}
 	};
@@ -108,11 +112,10 @@
 			var command = editor.addCommand( 'showblocks', commandDefinition );
 
+			if ( editor.config.startupOutlineBlocks )
+				command.setState( CKEDITOR.TRISTATE_ON );
+
 			editor.addCss( cssTemplate
 				.replace( cssTemplateRegex, 'background-image: url(' + CKEDITOR.getUrl( this.path ) + 'images/block_' )
-				   .replace( cssClassRegex, 'cke_show_blocks ' ) );
-
-			// Set a flag in the editor object for remembering the show block state on
-			// mode switches.
-			editor._.showBlocks = editor.config.startupOutlineBlocks;
+				.replace( cssClassRegex, 'cke_show_blocks ' ) );
 
 			editor.ui.addButton( 'ShowBlocks',
@@ -120,12 +123,12 @@
 					label : editor.lang.showBlocks,
 					command : 'showblocks'
-				} );
+				});
 
-			// Restore the command state after mode change.
+			// Refresh the command on mode changes.
 			editor.on( 'mode', function()
-			{
-				if ( editor.mode == 'wysiwyg' && this._.showBlocks )
-					command.exec();
-			}, null, null, 100 );
+				{
+					if ( command.state != CKEDITOR.TRISTATE_DISABLED )
+						command.refresh( editor );
+				});
 		}
 	});
Index: /CKEditor/trunk/_source/plugins/toolbar/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/toolbar/plugin.js	(revision 3515)
+++ /CKEditor/trunk/_source/plugins/toolbar/plugin.js	(revision 3516)
@@ -278,5 +278,5 @@
 [
 	['Source','-','Save','NewPage','Preview','-','Templates'],
-	['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker'],
+	['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
 	['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
 	['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
Index: /CKEditor/trunk/_source/skins/office2003/icons.css
===================================================================
--- /CKEditor/trunk/_source/skins/office2003/icons.css	(revision 3515)
+++ /CKEditor/trunk/_source/skins/office2003/icons.css	(revision 3516)
@@ -144,5 +144,6 @@
 }
 
-.cke_skin_office2003 .cke_button_checkspell .cke_icon
+.cke_skin_office2003 .cke_button_checkspell .cke_icon,
+.cke_skin_office2003 .cke_button_scayt .cke_icon
 {
 	background-position: 0 -192px;
Index: /CKEditor/trunk/_source/skins/v2/icons.css
===================================================================
--- /CKEditor/trunk/_source/skins/v2/icons.css	(revision 3515)
+++ /CKEditor/trunk/_source/skins/v2/icons.css	(revision 3516)
@@ -144,5 +144,6 @@
 }
 
-.cke_skin_v2 .cke_button_checkspell .cke_icon
+.cke_skin_v2 .cke_button_checkspell .cke_icon,
+.cke_skin_v2 .cke_button_scayt .cke_icon
 {
 	background-position: 0 -192px;
