Index: /CKEditor/trunk/_source/plugins/scayt/dialogs/options.js
===================================================================
--- /CKEditor/trunk/_source/plugins/scayt/dialogs/options.js	(revision 4815)
+++ /CKEditor/trunk/_source/plugins/scayt/dialogs/options.js	(revision 4816)
@@ -12,11 +12,38 @@
 		i,
 		contents = [],
-		userDicActive = false;
-	var dic_buttons = [
-		// [0] contains buttons for creating
-		"dic_create,dic_restore",
-		// [1] contains buton for manipulation
-		"dic_rename,dic_delete"
-	];
+		userDicActive = false,
+		dic_buttons = [
+			// [0] contains buttons for creating
+			"dic_create,dic_restore",
+			// [1] contains buton for manipulation
+			"dic_rename,dic_delete"
+		],
+		optionsIds= [ 'mixedCase','mixedWithDigits','allCaps','ignoreDomainNames' ];
+
+	// common operations
+
+	function getBOMAllOptions () {
+		 return document.forms.optionsbar["options"];
+	}
+	function getBOMAllLangs () {
+		 return document.forms.languagesbar["scayt_lang"];
+	}
+
+	function setCheckedValue(radioObj, newValue) {
+		if(!radioObj)
+			return;
+		var radioLength = radioObj.length;
+		if(radioLength == undefined) {
+			radioObj.checked = (radioObj.value == newValue.toString());
+			return;
+		}
+		for(var i = 0; i < radioLength; i++) {
+			radioObj[i].checked = false;
+			if(radioObj[i].value == newValue.toString()) {
+				radioObj[i].checked = true;
+			}
+		}
+	}
+
 	var tags_contents =  [
 				{
@@ -27,23 +54,23 @@
 							type : 'html',
 							id : 'options',
-							html : 	'<div class="inner_options">' +
+							html : 	'<form name="optionsbar"><div class="inner_options">' +
 									'	<div class="messagebox"></div>' +
 									'	<div style="display:none;">' +
-									'		<input type="checkbox" value="0" id="allCaps" />' +
+									'		<input type="checkbox" name="options"  id="allCaps" />' +
 									'		<label for="allCaps" id="label_allCaps"></label>' +
 									'	</div>' +
 									'	<div style="display:none;">' +
-									'		<input type="checkbox" value="0" id="ignoreDomainNames" />' +
+									'		<input name="options" type="checkbox"  id="ignoreDomainNames" />' +
 									'		<label for="ignoreDomainNames" id="label_ignoreDomainNames"></label>' +
 									'	</div>' +
 									'	<div style="display:none;">' +
-									'	<input type="checkbox" value="0" id="mixedCase" />' +
+									'	<input name="options" type="checkbox"  id="mixedCase" />' +
 									'		<label for="mixedCase" id="label_mixedCase"></label>' +
 									'	</div>' +
 									'	<div style="display:none;">' +
-									'		<input type="checkbox" value="0" id="mixedWithDigits" />' +
+									'		<input name="options" type="checkbox"  id="mixedWithDigits" />' +
 									'		<label for="mixedWithDigits" id="label_mixedWithDigits"></label>' +
 									'	</div>' +
-									'</div>'
+									'</div></form>'
 						}
 					]
@@ -56,9 +83,9 @@
 							type : 'html',
 							id : 'langs',
-							html : 	'<div class="inner_langs">' +
+							html : 	'<form name="languagesbar"><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>'
+									'   <div style="float:left;width:45%;margin-left:5px;" id="scayt_lcol" ></div>' +
+									'   <div style="float:left;width:45%;margin-left:15px;" id="scayt_rcol"></div>' +
+									'</div></form>'
 						}
 					]
@@ -71,6 +98,6 @@
 							type : 'html',
 							style: '',
-							id : 'dic',
-							html : 	'<div class="inner_dictionary" style="text-align:left; white-space:normal;">' +
+							id : 'dictionaries',
+							html : 	'<form name="dictionarybar"><div class="inner_dictionary" style="text-align:left; white-space:normal; width:320px; overflow: hidden;">' +
 									'	<div style="margin:5px auto; width:80%;white-space:normal; overflow:hidden;" id="dic_message"> </div>' +
 									'	<div style="margin:5px auto; width:80%;white-space:normal;"> ' +
@@ -91,5 +118,5 @@
 									'		</div>' +
 									'	<div style="margin:5px auto; width:95%;white-space:normal;" id="dic_info"></div>' +
-									'</div>'
+									'</div></form>'
 						}
 					]
@@ -102,5 +129,5 @@
 							type : 'html',
 							id : 'about',
-							style : 'margin: 10px 40px;',
+							style : 'margin: 5px 5px;',
 							html : '<div id="scayt_about"></div>'
 						}
@@ -108,8 +135,9 @@
 				}
 			];
+
 	var dialogDefiniton = {
 		title : editor.lang.scayt.title,
-		minWidth : 340,
-		minHeight : 200,
+		minWidth : 360,
+		minHeight : 220,
 		onShow : function()
 		{
@@ -129,13 +157,13 @@
 			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;
-					});
+				dialog.data.scayt.getCaption( editor.langCode || 'en', function( caps )
+				{
+					if ( stop++ > 0 )	// Once only
+						return;
+					captions = caps;
+					init_with_captions.apply( dialog );
+					reload.apply( dialog );
+					firstLoad = false;
+				});
 			}
 			else
@@ -146,38 +174,28 @@
 		onOk : function()
 		{
-			var scayt_control =  this.data.scayt_control,
-				o = scayt_control.option(),
-				c = 0;
-
-			// Set up options if any was set.
-			for ( var i in this.options )
-			{
-				if (o[i] != this.options[ i ] && c === 0 )
-				{
-					scayt_control.option( this.options );
-					c++;
-				}
-			}
-
+			var scayt_control =  this.data.scayt_control;
+			scayt_control.option( this.options );
 			// 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();
+			scayt_control.setLang( csLang );
+			scayt_control.refresh();
+		},
+		onCancel: function()
+		{
+			var o = getBOMAllOptions();
+			for (i in o)
+				o[i].checked = false;
+
+			setCheckedValue(getBOMAllLangs(),"");
 		},
 		contents : contents
-        };
+	};
 
 	var scayt_control = CKEDITOR.plugins.scayt.getScayt( editor );
-	if ( scayt_control )
-	{
-		tags = scayt_control.uiTags;
-	}
-
-	for ( i in tags ) {
+
+	tags = CKEDITOR.plugins.scayt.uiTabs;
+
+	for ( i in tags )
+	{
 		if ( tags[ i ] == 1 )
 			contents[ contents.length ] = tags_contents[ i ];
@@ -186,17 +204,5 @@
 		userDicActive = true;
 
-	function onDicButtonClick()
-	{
-		var dic_name = doc.getById('dic_name').getValue();
-		if ( !dic_name )
-		{
-			dic_error_message(" Dictionary name should not be empty. ");
-			return false;
-		}
-		//apply handler
-		window.dic[ this.getId() ].apply( null, [ this, dic_name, dic_buttons ] );
-
-		return true;
-	}
+
 	var init_with_captions = function()
 	{
@@ -204,5 +210,5 @@
 			lang_list = dialog.data.scayt.getLangList(),
 			buttons = [ 'dic_create','dic_delete','dic_rename','dic_restore' ],
-			labels = [ 'mixedCase','mixedWithDigits','allCaps','ignoreDomainNames' ],
+			labels = optionsIds,
 			i;
 
@@ -220,16 +226,19 @@
 
 		// Fill options and dictionary labels.
-		for ( i in labels )
-		{
-			var label = 'label_' + labels[ i ],
-				labelElement = doc.getById( label );
-
-			if (  'undefined' != typeof labelElement
-			   && 'undefined' != typeof captions[ label ]
-			   && 'undefined' != typeof dialog.options[labels[ i ]] )
-			{
-				labelElement.setHtml( captions[ label ] );
-				var labelParent = labelElement.getParent();
-				labelParent.$.style.display = "block";
+		if (tags[0] == 1)
+		{
+			for ( i in labels )
+			{
+				var label = 'label_' + labels[ i ],
+					labelElement = doc.getById( label );
+
+				if (  'undefined' != typeof labelElement
+				   && 'undefined' != typeof captions[ label ]
+				   && 'undefined' != typeof dialog.options[labels[ i ]] )
+				{
+					labelElement.setHtml( captions[ label ] );
+					var labelParent = labelElement.getParent();
+					labelParent.$.style.display = "block";
+				}
 			}
 		}
@@ -274,21 +283,24 @@
 
 		var langList = [];
-		for ( i in lang_list.rtl )
-			langList[ langList.length ] = createOption( i, lang_list.ltr );
-
-		for ( 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 ( i=0; i < langList.length; i++ )
-		{
-			var field = ( i < langList.length / 2 ) ? fieldL : fieldR;
-			field.append( langList[ i ].radio );
+		if (tags[1] ==1 )
+		{
+			for ( i in lang_list.rtl )
+				langList[ langList.length ] = createOption( i, lang_list.ltr );
+
+			for ( 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 ( i=0; i < langList.length; i++ )
+			{
+				var field = ( i < langList.length / 2 ) ? fieldL : fieldR;
+				field.append( langList[ i ].radio );
+			}
 		}
 
@@ -296,80 +308,70 @@
 		var dic = {};
 		dic.dic_create = function( el, dic_name , dic_buttons )
-			{
-				// comma separated button's ids include repeats if exists
-				var all_buttons = dic_buttons[0] + ',' + dic_buttons[1];
-
-				var err_massage = captions["err_dic_create"];
-				var suc_massage = captions["succ_dic_create"];
-				//console.info("--plugin ");
-
-				window.scayt.createUserDictionary(dic_name,
-					function(arg)
-						{
-							//console.info( "dic_create callback called with args" , arg );
-							hide_dic_buttons ( all_buttons );
-							display_dic_buttons ( dic_buttons[1] );
-							suc_massage = suc_massage.replace("%s" , arg.dname );
-							dic_success_message (suc_massage);
-						},
-					function(arg)
-						{
-							//console.info( "dic_create errorback called with args" , arg )
-							err_massage = err_massage.replace("%s" ,arg.dname );
-							dic_error_message ( err_massage + "( "+ (arg.message || "") +")");
-						});
-
-			};
+		{
+			// comma separated button's ids include repeats if exists
+			var all_buttons = dic_buttons[0] + ',' + dic_buttons[1];
+
+			var err_massage = captions["err_dic_create"];
+			var suc_massage = captions["succ_dic_create"];
+
+			window.scayt.createUserDictionary(dic_name,
+				function(arg)
+				{
+					hide_dic_buttons ( all_buttons );
+					display_dic_buttons ( dic_buttons[1] );
+					suc_massage = suc_massage.replace("%s" , arg.dname );
+					dic_success_message (suc_massage);
+				},
+				function(arg)
+				{
+					err_massage = err_massage.replace("%s" ,arg.dname );
+					dic_error_message ( err_massage + "( "+ (arg.message || "") +")");
+				});
+
+		};
 
 		dic.dic_rename = function( el, dic_name )
-			{
-				//
-				// try to rename dictionary
-				// @TODO: rename dict
-				//console.info ( captions["err_dic_rename"] )
-				var err_massage = captions["err_dic_rename"] || "";
-				var suc_massage = captions["succ_dic_rename"] || "";
-				window.scayt.renameUserDictionary(dic_name,
-					function(arg)
-						{
-							//console.info( "dic_rename callback called with args" , arg );
-							suc_massage = suc_massage.replace("%s" , arg.dname );
-							set_dic_name( dic_name );
-							dic_success_message ( suc_massage );
-						},
-					function(arg)
-						{
-							//console.info( "dic_rename errorback called with args" , arg )
-							err_massage = err_massage.replace("%s" , arg.dname  );
-							set_dic_name( dic_name );
-							dic_error_message( err_massage + "( " + ( arg.message || "" ) + " )" );
-						});
-			};
+		{
+			//
+			// try to rename dictionary
+			var err_massage = captions["err_dic_rename"] || "";
+			var suc_massage = captions["succ_dic_rename"] || "";
+			window.scayt.renameUserDictionary(dic_name,
+				function(arg)
+					{
+						suc_massage = suc_massage.replace("%s" , arg.dname );
+						set_dic_name( dic_name );
+						dic_success_message ( suc_massage );
+					},
+				function(arg)
+					{
+						err_massage = err_massage.replace("%s" , arg.dname  );
+						set_dic_name( dic_name );
+						dic_error_message( err_massage + "( " + ( arg.message || "" ) + " )" );
+					});
+		};
 
 		dic.dic_delete = function ( el, dic_name , dic_buttons )
-			{
-				var all_buttons = dic_buttons[0] + ',' + dic_buttons[1];
-				var err_massage = captions["err_dic_delete"];
-				var suc_massage = captions["succ_dic_delete"];
-
-				// try to delete dictionary
-				// @TODO: delete dict
-				window.scayt.deleteUserDictionary(
-					function(arg)
-						{
-							//console.info( "dic_delete callback " , dic_name ,arg );
-							suc_massage = suc_massage.replace("%s" , arg.dname );
-							hide_dic_buttons ( all_buttons );
-							display_dic_buttons ( dic_buttons[0] );
-							set_dic_name( "" ); // empty input field
-							dic_success_message( suc_massage );
-						},
-					function(arg)
-						{
-							//console.info( " dic_delete errorback called with args" , arg )
-							err_massage = err_massage.replace("%s" , arg.dname );
-							dic_error_message(err_massage);
-						});
-			};
+		{
+			var all_buttons = dic_buttons[0] + ',' + dic_buttons[1];
+			var err_massage = captions["err_dic_delete"];
+			var suc_massage = captions["succ_dic_delete"];
+
+			// try to delete dictionary
+			window.scayt.deleteUserDictionary(
+				function(arg)
+				{
+					suc_massage = suc_massage.replace("%s" , arg.dname );
+					hide_dic_buttons ( all_buttons );
+					display_dic_buttons ( dic_buttons[0] );
+					set_dic_name( "" ); // empty input field
+					dic_success_message( suc_massage );
+				},
+				function(arg)
+				{
+					err_massage = err_massage.replace("%s" , arg.dname );
+					dic_error_message(err_massage);
+				});
+		};
 
 		dic.dic_restore = dialog.dic_restore || function ( el, dic_name , dic_buttons )
@@ -382,18 +384,35 @@
 				window.scayt.restoreUserDictionary(dic_name,
 					function(arg)
-						{
-							//console.info( "dic_restore callback called with args" , arg );
-							suc_massage = suc_massage.replace("%s" , arg.dname );
-							hide_dic_buttons ( all_buttons );
-							display_dic_buttons(dic_buttons[1]);
-							dic_success_message( suc_massage );
-						},
+					{
+						suc_massage = suc_massage.replace("%s" , arg.dname );
+						hide_dic_buttons ( all_buttons );
+						display_dic_buttons(dic_buttons[1]);
+						dic_success_message( suc_massage );
+					},
 					function(arg)
-						{
-							//console.info( " dic_restore errorback called with args" , arg )
-							err_massage = err_massage.replace("%s" , arg.dname );
-							dic_error_message( err_massage );
-						});
+					{
+						err_massage = err_massage.replace("%s" , arg.dname );
+						dic_error_message( err_massage );
+					});
 			};
+
+		function onDicButtonClick( ev )
+		{
+			var dic_name = doc.getById('dic_name').getValue();
+			if ( !dic_name )
+			{
+				dic_error_message(" Dictionary name should not be empty. ");
+				return false;
+			}
+			try{
+				var el = id = ev.data.getTarget().getParent();
+				var id = el.getId();
+				dic[ id ].apply( null, [ el, dic_name, dic_buttons ] );
+			}catch(err){
+				dic_error_message(" Dictionary error. ");
+			}
+
+			return true;
+		}
 
 		// ** bind event listeners
@@ -403,5 +422,5 @@
 		for ( i = 0, l = arr_buttons.length ; i < l ; i += 1 )
 		{
-		 	var dic_button = doc.getById(arr_buttons[i]);
+			var dic_button = doc.getById(arr_buttons[i]);
 			if ( dic_button )
 				dic_button.on( 'click', onDicButtonClick, this );
@@ -412,45 +431,65 @@
 	{
 		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()
+		// for enabled options tab
+		if (tags[0] == 1){
+			var opto = getBOMAllOptions();
+
+			// Animate options.
+			for ( var k=0,l = opto.length; k<l;k++ )
+			{
+
+				var i = opto[k].id;
+				var checkbox = doc.getById( i );
+
+				if ( checkbox )
+				{
+					opto[k].checked = false;
+					//alert (opto[k].removeAttribute)
+					if ( dialog.options[ i ] == 1 )
+					{
+						opto[k].checked = true;
+					}
+
+
+					// Bind events. Do it only once.
+					if ( firstLoad )
+					{
+						checkbox.on( 'click', function()
 						{
 							dialog.options[ this.getId() ] = this.$.checked ? 1 : 0 ;
-						} );
+						});
+					}
 				}
 			}
 		}
 
+		//for enabled languages tab
+		if ( tags[1] == 1 )
+		{
+			var domLang = doc.getById("cke_option"+dialog.sLang);
+			setCheckedValue(domLang.$,dialog.sLang);
+		}
+
 		// * user dictionary
-		if ( userDicActive ){
+		if ( userDicActive )
+		{
 			window.scayt.getNameUserDictionary(
-			function( o )
-			{
-				var dic_name = o.dname;
-				if ( dic_name )
-				{
-					doc.getById( 'dic_name' ).setValue(dic_name);
-					display_dic_buttons( dic_buttons[1] );
-				}
-				else
-					display_dic_buttons( dic_buttons[0] );
-
-			},
-			function ()
-			{
-				doc.getById( 'dic_name' ).setValue("");
-			});
+				function( o )
+				{
+					var dic_name = o.dname;
+					hide_dic_buttons( dic_buttons[0] + ',' + dic_buttons[1] );
+					if ( dic_name )
+					{
+						doc.getById( 'dic_name' ).setValue(dic_name);
+						display_dic_buttons( dic_buttons[1] );
+					}
+					else
+						display_dic_buttons( dic_buttons[0] );
+
+				},
+				function ()
+				{
+					doc.getById( 'dic_name' ).setValue("");
+				});
 			dic_success_message("");
 		}
@@ -459,35 +498,35 @@
 
 	function dic_error_message ( m )
-		{
-			doc.getById('dic_message').setHtml('<span style="color:red;">' + m + '</span>' );
-		}
-    function dic_success_message ( m )
-		{
-			doc.getById('dic_message').setHtml('<span style="color:blue;">' + m + '</span>') ;
-		}
+	{
+		doc.getById('dic_message').setHtml('<span style="color:red;">' + m + '</span>' );
+	}
+	function dic_success_message ( m )
+	{
+		doc.getById('dic_message').setHtml('<span style="color:blue;">' + m + '</span>') ;
+	}
 	function display_dic_buttons ( sIds )
-		{
-
-			sIds = String( sIds );
-			var aIds = sIds.split(',');
-			for ( var i=0, l = aIds.length; i < l ; i+=1)
-			{
-				doc.getById( aIds[i] ).$.style.display = "inline";
-			}
-
-		}
+	{
+
+		sIds = String( sIds );
+		var aIds = sIds.split(',');
+		for ( var i=0, l = aIds.length; i < l ; i+=1)
+		{
+			doc.getById( aIds[i] ).$.style.display = "inline";
+		}
+
+	}
 	function hide_dic_buttons ( sIds )
-		{
-			sIds = String( sIds );
-			var aIds = sIds.split(',');
-			for ( var i = 0, l = aIds.length; i < l ; i += 1 )
-			{
-				doc.getById( aIds[i] ).$.style.display = "none";
-			}
-		}
+	{
+		sIds = String( sIds );
+		var aIds = sIds.split(',');
+		for ( var i = 0, l = aIds.length; i < l ; i += 1 )
+		{
+			doc.getById( aIds[i] ).$.style.display = "none";
+		}
+	}
 	function set_dic_name ( dic_name )
-		{
-			doc.getById('dic_name').$.value= dic_name;
-		}
+	{
+		doc.getById('dic_name').$.value= dic_name;
+	}
 
 	return dialogDefiniton;
Index: /CKEditor/trunk/_source/plugins/scayt/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/scayt/plugin.js	(revision 4815)
+++ /CKEditor/trunk/_source/plugins/scayt/plugin.js	(revision 4816)
@@ -12,5 +12,21 @@
 {
 	var commandName 	= 'scaytcheck',
-		openPage		= '';
+		openPage		= '',
+		scayt_paused	= null;
+
+	// Checks if a value exists in an array
+	function in_array(needle, haystack)
+	{
+		var found = false, key;
+		for (key in haystack)
+		{
+			if ((haystack[key] === needle) || ( haystack[key] == needle))
+			{
+				found = true;
+				break;
+			}
+		}
+		return found;
+	}
 
 	var onEngineLoad = function()
@@ -25,9 +41,8 @@
 			// syntax : AppName.AppVersion@AppRevision
 			oParams.assocApp  = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision;
-
-			oParams.customerid = editor.config.scayt_customerid  || "1:11111111111111111111111111111111111111";
-			oParams.customDictionaryName = editor.config.scayt_customDictionaryName;
+			oParams.customerid = editor.config.scayt_customerid  || "1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2";
+			oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds;
 			oParams.userDictionaryName = editor.config.scayt_userDictionaryName;
-			oParams.defLang = editor.scayt_defLang;
+			oParams.sLang = editor.config.scayt_sLang || "en_US";
 
 			if ( CKEDITOR._scaytParams )
@@ -52,7 +67,17 @@
 			plugin.instances[ editor.name ] = scayt_control;
 
+			//window.scayt.uiTags
+			var menuGroup = 'scaytButton';
+			var uiTabs = window.scayt.uiTags;
+			var fTabs  = [];
+
+			for (var i = 0,l=4; i<l; i++)
+				fTabs.push( uiTabs[i] && plugin.uiTabs[i] );
+
+			plugin.uiTabs = fTabs;
 			try {
-				scayt_control.setDisabled( scayt_control.paused === false );				// I really don't know why it causes JS error in IE
+				scayt_control.setDisabled( scayt_paused === false );
 			} catch (e) {}
+
 			editor.fire( 'showScaytState' );
 		};
@@ -84,5 +109,5 @@
 					if ( scayt_instanse )
 					{
-						scayt_instanse.paused = !scayt_instanse.disabled;
+						scayt_paused = scayt_instanse.paused = !scayt_instanse.disabled;
 						scayt_instanse.destroy();
 						delete plugin.instances[ editor.name ];
@@ -91,4 +116,9 @@
 			});
 
+
+		editor.on( 'destroy', function()
+			{
+				plugin.getScayt( editor ).destroy();
+			});
 		// Listen to data manipulation to reflect scayt markup.
 		editor.on( 'afterSetData', function()
@@ -117,4 +147,23 @@
 			}, this, null, 50 );
 
+		editor.on( 'insertHtml', function()
+			{
+
+				var scayt_instance = plugin.getScayt( editor );
+				if ( plugin.isScaytEnabled( editor ) )
+				{
+					// Unlock the selection before reload, SCAYT will take
+					// care selection update.
+					if ( CKEDITOR.env.ie )
+						editor.getSelection().unlock( true );
+
+					// Swallow any SCAYT engine errors.
+					try{
+						scayt_instance.refresh();
+					}catch( er )
+					{}
+				}
+			}, this, null, 50 );
+
 		editor.on( 'scaytDialog', function( ev )	// Communication with dialog.
 			{
@@ -190,5 +239,5 @@
 			// Default to 'http' for unknown.
 			protocol = protocol.search( /https?:/) != -1? protocol : 'http:';
-			var baseUrl  = "svc.spellchecker.net/spellcheck/lf/scayt/scayt1.js";
+			var baseUrl  = "svc.spellchecker.net/spellcheck3/lf/scayt/scayt21.js";
 
 			var scaytUrl  =  editor.config.scayt_srcUrl || ( protocol + "//" + baseUrl );
@@ -301,49 +350,79 @@
 			// Add Options dialog.
 			CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) );
+			// read ui tags
+			var confuiTabs = editor.config.scayt_uiTabs || "1,1,1";
+			var uiTabs =[];
+			// string tp array convert
+			confuiTabs = confuiTabs.split(",");
+			// check array length ! allwaays must be 3 filled with 1 or 0
+			for (var i=0,l=3; i<l; i++){
+				var flag = parseInt(confuiTabs[i] || "1" ,10);
+				uiTabs.push(  flag  );
+			}
 
 			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 );
-						}
+			// combine menu items to render
+			var uiMuneItems = {};
+
+			// allways added
+			uiMuneItems.scaytToggle =
+				{
+					label : editor.lang.scayt.enable,
+					command : commandName,
+					group : menuGroup
+				};
+
+			if (uiTabs[0] == 1)
+				uiMuneItems.scaytOptions =
+				{
+					label : editor.lang.scayt.options,
+					group : menuGroup,
+					onClick : function()
+					{
+						openPage = 'options';
+						editor.openDialog( commandName );
 					}
-				});
+				};
+
+			if (uiTabs[1] == 1)
+				uiMuneItems.scaytLangs =
+				{
+					label : editor.lang.scayt.langs,
+					group : menuGroup,
+					onClick : function()
+					{
+						openPage = 'langs';
+						editor.openDialog( commandName );
+					}
+				};
+			if (uiTabs[2] == 1)
+				uiMuneItems.scaytDict =
+				{
+					label : editor.lang.scayt.dictionariesTab,
+					group : menuGroup,
+					onClick : function()
+					{
+						openPage = 'dictionaries';
+						editor.openDialog( commandName );
+					}
+				};
+			// allways added
+			uiMuneItems.scaytAbout =
+				{
+					label : editor.lang.scayt.about,
+					group : menuGroup,
+					onClick : function()
+					{
+						openPage = 'about';
+						editor.openDialog( commandName );
+					}
+				}
+			;
+
+			uiTabs[3] = 1; // about us tab is allways on
+			plugin.uiTabs = uiTabs;
+
+			editor.addMenuItems( uiMuneItems );
 
 				editor.ui.add( 'Scayt', CKEDITOR.UI_MENUBUTTON,
@@ -354,21 +433,22 @@
 						onRender: function()
 						{
-						command.on( 'state', 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' ];
+						},
+						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
+								scaytToggle  : CKEDITOR.TRISTATE_OFF,
+								scaytOptions : isEnabled && plugin.uiTabs[0] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
+								scaytLangs   : isEnabled && plugin.uiTabs[1] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
+								scaytDict    : isEnabled && plugin.uiTabs[2] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
+								scaytAbout   : isEnabled && plugin.uiTabs[3] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED
 							};
 						}
@@ -408,5 +488,13 @@
 						mainSuggestions = {};
 
-						var moreSuggestionsUnable = false;
+						var moreSuggestionsUnable = editor.config.scayt_moreSuggestions || "on";
+						var moreSuggestionsUnableAdded = false;
+
+						var maxSuggestions = editor.config.scayt_maxSuggestions;
+						( typeof maxSuggestions != 'number' ) && ( maxSuggestions = 5 );
+						!maxSuggestions && ( maxSuggestions = items_suggestion.length );
+
+						var contextCommands = editor.config.scayt_contextCommands || "all";
+						contextCommands = contextCommands.split("|");
 
 						for ( var i = 0, l = items_suggestion.length; i < l; i += 1 )
@@ -423,5 +511,5 @@
 								})( element.$, items_suggestion[i] );
 
-							if ( i < editor.config.scayt_maxSuggestions )
+							if ( i < maxSuggestions )
 							{
 								addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],
@@ -430,59 +518,61 @@
 								mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
 							}
-							else
+							else if ( moreSuggestionsUnable == "on" )
 							{
 								addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],
 									commandName, exec, 'scayt_moresuggest', i + 1 );
 								moreSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
-								moreSuggestionsUnable = true;
+								moreSuggestionsUnableAdded = true;
 							}
 						}
-						if ( moreSuggestionsUnable )
+
+						if ( moreSuggestionsUnableAdded ){
 							// Rgister the More suggestions group;
 							editor.addMenuItem( 'scayt_moresuggest',
+							{
+								label : editor.lang.scayt.moreSuggestions,
+								group : 'scayt_moresuggest',
+								order : 10,
+								getItems : function()
 								{
-									label : editor.lang.scayt.moreSuggestions,
-									group : 'scayt_moresuggest',
-									order : 10,
-									getItems : function()
-									{
-										return moreSuggestions;
-									}
-								});
-
-
-						var ignore_command =
-						{
-							exec: function()
-							{
-								scayt_control.ignore( element.$ );
-							}
-						};
-						var ignore_all_command =
-						{
-							exec: function()
-							{
-								scayt_control.ignoreAll( element.$ );
-							}
-						};
-						var addword_command =
-						{
-							exec: function()
-							{
-								window.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 moreSuggestions;
+								}
+							});
+							mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF;
+
+						}
+
+						if ( in_array( "all",contextCommands )  || in_array("ignore",contextCommands)  )
+						{
+							var ignore_command = {
+								exec: function(){
+									scayt_control.ignore(element.$);
+								}
+							};
+							addButtonCommand(editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1);
+							mainSuggestions['scayt_ignore'] = CKEDITOR.TRISTATE_OFF;
+						}
+
+						if ( in_array( "all",contextCommands )  || in_array("ignoreall",contextCommands)  )
+						{
+							var ignore_all_command = {
+								exec: function(){
+									scayt_control.ignoreAll(element.$);
+								}
+							};
+							addButtonCommand(editor, 'ignore_all', editor.lang.scayt.ignoreAll, 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2);
+							mainSuggestions['scayt_ignore_all'] = CKEDITOR.TRISTATE_OFF;
+						}
+
+						if ( in_array( "all",contextCommands )  || in_array("add",contextCommands)  )
+						{
+							var addword_command = {
+								exec: function(){
+									window.scayt.addWordToUserDictionary(element.$);
+								}
+							};
+							addButtonCommand(editor, 'add_word', editor.lang.scayt.addWord, 'scayt_add_word', addword_command, 'scayt_control', 3);
+							mainSuggestions['scayt_add_word'] = CKEDITOR.TRISTATE_OFF;
+						}
 
 						if ( scayt_control.fireOnContextMenu )
@@ -509,4 +599,5 @@
 })();
 
-CKEDITOR.config.scayt_maxSuggestions =  5;
-CKEDITOR.config.scayt_autoStartup = false;
+// TODO: Documentation
+// CKEDITOR.config.scayt_maxSuggestions
+// CKEDITOR.config.scayt_autoStartup
