Index: /FCKeditor/trunk/_whatsnew.html
===================================================================
--- /FCKeditor/trunk/_whatsnew.html	(revision 2792)
+++ /FCKeditor/trunk/_whatsnew.html	(revision 2793)
@@ -123,4 +123,6 @@
 		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2612">#2612</a>] The 'ForcePasteAsPlainText' 
 			configuration option didn't work correctly in Safari and Chrome.</li>
+		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2696">#2696</a>] Fixed non-working
+			autogrow plugin.</li>
 	</ul>
 	<p>
Index: /FCKeditor/trunk/editor/plugins/autogrow/fckplugin.js
===================================================================
--- /FCKeditor/trunk/editor/plugins/autogrow/fckplugin.js	(revision 2792)
+++ /FCKeditor/trunk/editor/plugins/autogrow/fckplugin.js	(revision 2793)
@@ -23,77 +23,89 @@
  */
 
-var FCKAutoGrow_Min = window.frameElement.offsetHeight ;
+var FCKAutoGrow = {
+	MIN_HEIGHT : window.frameElement.offsetHeight,
 
-function FCKAutoGrow_Check()
-{
-	var oInnerDoc = FCK.EditorDocument ;
+	Check : function()
+	{
+		var delta = FCKAutoGrow.GetHeightDelta() ;
+		if ( delta != 0 )
+		{
+			var newHeight = window.frameElement.offsetHeight + delta ;
+			
+			newHeight = FCKAutoGrow.GetEffectiveHeight( newHeight ) ;
+			
+			if ( newHeight != window.frameElement.height )
+			{
+				window.frameElement.style.height = newHeight + "px" ;
 
-	var iFrameHeight, iInnerHeight ;
+				// Gecko browsers use an onresize handler to update the innermost
+				// IFRAME's height. If the document is modified before the onresize
+				// is triggered, the plugin will miscalculate the new height. Thus,
+				// forcibly trigger onresize. #1336
+				if ( typeof window.onresize == 'function' )
+				{
+					window.onresize() ;
+				}
+			}
+		}
+	},
 
-	if ( FCKBrowserInfo.IsIE )
+	CheckEditorStatus : function( sender, status )
 	{
-		iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
-		iInnerHeight = oInnerDoc.body.scrollHeight ;
-	}
-	else
+		if ( status == FCK_STATUS_COMPLETE )
+			FCKAutoGrow.Check() ;
+	},
+
+	GetEffectiveHeight : function( height )
 	{
-		iFrameHeight = FCK.EditorWindow.innerHeight ;
-		iInnerHeight = oInnerDoc.body.offsetHeight ;
-	}
+		if ( height < FCKAutoGrow.MIN_HEIGHT )
+			height = FCKAutoGrow.MIN_HEIGHT;
+		else
+		{
+			var max = FCKConfig.AutoGrowMax;
+			if ( max && max > 0 && height > max )
+				height = max;
+		}
+		
+		return height;
+	},
 
-	var iDiff = iInnerHeight - iFrameHeight ;
+	GetHeightDelta : function()
+	{
+		var oInnerDoc = FCK.EditorDocument ;
 
-	if ( iDiff != 0 )
-	{
-		var iMainFrameSize = window.frameElement.offsetHeight ;
+		var iFrameHeight ;
+		var iInnerHeight ;
 
-		if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
+		if ( FCKBrowserInfo.IsIE )
 		{
-			iMainFrameSize += iDiff ;
-			if ( iMainFrameSize > FCKConfig.AutoGrowMax )
-				iMainFrameSize = FCKConfig.AutoGrowMax ;
-		}
-		else if ( iDiff < 0 && iMainFrameSize > FCKAutoGrow_Min )
-		{
-			iMainFrameSize += iDiff ;
-			if ( iMainFrameSize < FCKAutoGrow_Min )
-				iMainFrameSize = FCKAutoGrow_Min ;
+			iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
+			iInnerHeight = oInnerDoc.body.scrollHeight ;
 		}
 		else
+		{
+			iFrameHeight = FCK.EditorWindow.innerHeight ;
+			iInnerHeight = oInnerDoc.body.offsetHeight +
+				( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-top' ) ) || 0 ) +
+				( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-bottom' ) ) || 0 ) ;
+		}
+
+		return iInnerHeight - iFrameHeight ;
+	},
+
+	SetListeners : function()
+	{
+		if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
 			return ;
 
-		window.frameElement.height = iMainFrameSize ;
+		FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow.Check ) ;
+		FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow.Check ) ;
+	}
+};
 
-		// Gecko browsers use an onresize handler to update the innermost
-		// IFRAME's height. If the document is modified before the onresize
-		// is triggered, the plugin will miscalculate the new height. Thus,
-		// forcibly trigger onresize. #1336
-		if ( typeof window.onresize == 'function' )
-			window.onresize() ;
-	}
-}
-
-FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
-
-function FCKAutoGrow_SetListeners()
-{
-	if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
-		return ;
-
-	FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow_Check ) ;
-	FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow_Check ) ;
-}
+FCK.AttachToOnSelectionChange( FCKAutoGrow.Check ) ;
 
 if ( FCKBrowserInfo.IsIE )
-{
-//	FCKAutoGrow_SetListeners() ;
-	FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow_SetListeners ) ;
-}
+	FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow.SetListeners ) ;
 
-function FCKAutoGrow_CheckEditorStatus( sender, status )
-{
-	if ( status == FCK_STATUS_COMPLETE )
-		FCKAutoGrow_Check() ;
-}
-
-FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow_CheckEditorStatus ) ;
+FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow.CheckEditorStatus ) ;
