Index: FCKeditor/trunk/editor/_source/internals/fck.js
===================================================================
--- FCKeditor/trunk/editor/_source/internals/fck.js	(revision 4254)
+++ FCKeditor/trunk/editor/_source/internals/fck.js	(revision 4267)
@@ -236,4 +236,6 @@
 	GetData : function( format )
 	{
+		FCK.Events.FireEvent("OnBeforeGetData") ;
+
 		// We assume that if the user is in source editing, the editor value must
 		// represent the exact contents of the source, as the user wanted it to be.
@@ -271,5 +273,9 @@
 		}
 
-		return FCKConfig.ProtectedSource.Revert( data ) ;
+		data = FCKConfig.ProtectedSource.Revert( data ) ;
+
+		setTimeout( function() { FCK.Events.FireEvent("OnAfterGetData") ; }, 0 ) ;
+
+		return data ;
 	},
 
Index: FCKeditor/trunk/editor/_source/internals/fckscayt.js
===================================================================
--- FCKeditor/trunk/editor/_source/internals/fckscayt.js	(revision 4254)
+++ FCKeditor/trunk/editor/_source/internals/fckscayt.js	(revision 4267)
@@ -25,6 +25,8 @@
 {
 	var scaytOnLoad = [] ;
-	var isEngineLoaded = (top.scayt) ? true : false ;
-	var scaytEnable, scaytReady ;
+	var isEngineLoaded = ( FCK && FCK.EditorWindow && FCK.EditorWindow.parent.parent.scayt)
+						? true : false ;
+	var scaytEnable = false;
+	var scaytReady  = false;
 
 	function ScaytEngineLoad( callback )
@@ -38,8 +40,8 @@
 		var init = function ()
 		{
-			scayt = top.scayt ;
+			window.scayt = top.scayt ;
 			InitScayt() ;
 			var ScaytCombobox =  FCKToolbarItems.LoadedItems[ 'ScaytCombobox' ] ;
-			ScaytCombobox && ScaytCombobox.SetEnabled( scyt_control && scyt_control.disabled) ;
+			ScaytCombobox && ScaytCombobox.SetEnabled( scyt_control && scyt_control.disabled ) ;
 			InitSetup() ;
 		};
@@ -102,5 +104,5 @@
 	}
 
-	function InitScayt()
+	function createScaytControl ()
 	{
 		// Get public scayt params.
@@ -117,4 +119,11 @@
 		var scayt = top.scayt;
 		var scayt_control = window.scayt_control = new scayt( oParams ) ;
+	}
+
+	function InitScayt()
+	{
+		createScaytControl();
+		
+		var scayt_control = window.scayt_control ;
 
 		if ( scayt_control )
@@ -203,5 +212,4 @@
 		window.scayt_control.setDisabled( false ) ;
 		scaytEnable = true;
-
 	}
 
@@ -232,5 +240,5 @@
 		var combo = FCKToolbarItems.GetItem( 'SpellCheck' ) ;
 
-		if ( !combo )
+		if ( !combo || !combo._Combo || !combo._Combo._OuterTable )
 			return;
 
@@ -321,5 +329,6 @@
 					break ;
 				case 'Add Word' :
-					scayt.addWordToUserDictionary( node ) ;
+					var top = FCK.EditorWindow.parent.parent ;
+					top.scayt.addWordToUserDictionary( node ) ;
 					break ;
 			}
@@ -334,5 +343,8 @@
 				AddItems : function( menu )
 				{
-					var scayt_control = window.scayt_control;
+					var top = FCK.EditorWindow.parent.parent;
+
+					var scayt_control = window.scayt_control,
+						scayt = top.scayt;
 
 					if ( !scayt_control )
@@ -358,8 +370,8 @@
 						if ( suggestions[i] )
 						{
-							menu.AddItem('ScaytContext', suggestions[i], null, false, {
-								action: 'Suggestion',
-								node: node,
-								suggestion: suggestions[i] } ) ;
+							menu.AddItem( 'ScaytContext', suggestions[i], null, false, {
+								'action' : 'Suggestion',
+								'node' : node,
+								'suggestion' : suggestions[i] } ) ;
 						}
 					}
@@ -367,7 +379,7 @@
 					menu.AddSeparator() ;
 
-					menu.AddItem( 'ScaytContext', 'Ignore', null, false, { action : 'Ignore', node : node } );
-					menu.AddItem( 'ScaytContext', 'Ignore All', null, false, { action : 'Ignore All', node : node } );
-					menu.AddItem( 'ScaytContext', 'Add Word', null, false, { action : 'Add Word', node : node } );
+					menu.AddItem( 'ScaytContext', 'Ignore', null, false, { 'action' : 'Ignore', 'node' : node } );
+					menu.AddItem( 'ScaytContext', 'Ignore All', null, false, { 'action' : 'Ignore All', 'node' : node } );
+					menu.AddItem( 'ScaytContext', 'Add Word', null, false, { 'action' : 'Add Word', 'node' : node } );
 					try
 					{
@@ -389,10 +401,14 @@
 	// ##
 	// Register event listeners.
-	FCK.Events.AttachEvent( 'OnAfterSetHTML', function()
+
+ 	FCK.Events.AttachEvent( 'OnAfterSetHTML', function()
 		{
 			if ( FCKConfig.SpellChecker == 'SCAYT' )
 			{
-				if ( FCK.Config.ScaytAutoStartup )
+				if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup )
 					ScaytEngineLoad() ;
+
+				if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady )
+					createScaytControl();
 
 				ShowScaytState() ;
@@ -400,4 +416,14 @@
 		} ) ;
 
+	FCK.Events.AttachEvent( 'OnBeforeGetData', function()
+		{
+			scaytReady && window.scayt_control.reset();
+		} ) ;
+
+	FCK.Events.AttachEvent( 'OnAfterGetData', function()
+		{
+			scaytReady && window.scayt_control.refresh();
+		} ) ;
+
 	// ###
 	// The main object that holds the SCAYT interaction in the code.
