Index: /FCKeditor/trunk/editor/_source/commandclasses/fckshowblocks.js
===================================================================
--- /FCKeditor/trunk/editor/_source/commandclasses/fckshowblocks.js	(revision 705)
+++ /FCKeditor/trunk/editor/_source/commandclasses/fckshowblocks.js	(revision 706)
@@ -25,106 +25,37 @@
 {
 	this.Name = name ;
-	this.CSSText = this._GetCSSText( ['p', 'div', 'pre', 'address', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'] ) ;
-	this.StyleSheetObj = null ;
 }
+
 FCKShowBlockCommand.prototype.Execute = function()
 {
-	if ( this._IsVisible() )
-		this._SetInvisible() ;
+	var state = this.GetState() ;
+
+	if ( state == FCK_TRISTATE_DISABLED )
+		return false ;
+
+	var body = FCK.EditorDocument.body ;
+
+	if ( state == FCK_TRISTATE_ON )
+		body.className = body.className.replace( /(^| )FCK__ShowBlocks/g, '' ) ;
 	else
-		this._SetVisible() ;
+		body.className += ' FCK__ShowBlocks' ;
+
 	FCK.Events.FireEvent( 'OnSelectionChange' ) ;
 }
+
 FCKShowBlockCommand.prototype.GetState = function()
 {
 	if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
 		return FCK_TRISTATE_DISABLED ;
-	return this._IsVisible() ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ;
-}
-FCKShowBlockCommand.prototype._IsVisible = function()
-{
-	// The try.. catch... statements are here because accessing a stylesheet object of an inactive 
-	// document would raise access denied error in IE.
-	// In such a case, we should clear the reference to prevent further errors, before returning false.
+
+	// On some cases FCK.EditorDocument.body is not yet available, so try/catch.
 	try
 	{
-		if ( ! this.StyleSheetObj )
-			return false ;
+		if ( /FCK__ShowBlocks(?:\s|$)/.test( FCK.EditorDocument.body.className ) )
+			return FCK_TRISTATE_ON ;
 	}
-	catch ( e )
-	{
-		this.StyleSheetObj = null ;
-		return false ;
-	}
-	if ( FCKBrowserInfo.IsIE )
-	{
-		try
-		{
-			if ( this.StyleSheetObj.cssText == '' 
-					|| ! this.StyleSheetObj.owningElement 
-					|| this.StyleSheetObj.owningElement.ownerDocument != FCK.EditorDocument )
-				return false ;
-			else
-				return true ;
-		}
-		catch ( e )
-		{
-			this.StyleSheetObj = null ;
-			return false ;
-		}
-	}
-	else
-	{
-		if ( this.StyleSheetObj.parentNode && this.StyleSheetObj.ownerDocument == FCK.EditorDocument )
-			return true ;
-		else
-			return false ;
-	}
+	catch (e)
+	{}
+
+	return FCK_TRISTATE_OFF ;
 }
-FCKShowBlockCommand.prototype._SetVisible = function()
-{
-	if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
-		return ;
-	if ( ! this.StyleSheetObj )
-	{
-		this.StyleSheetObj = FCKTools._AppendStyleString( FCK.EditorDocument, this.CSSText ) ;
-		return ;
-	}
-
-	if ( FCKBrowserInfo.IsIE )
-		this.StyleSheetObj.cssText = this.CSSText ;
-	else
-		FCK.EditorDocument.getElementsByTagName( 'head' )[0].appendChild( this.StyleSheetObj ) ;
-}
-FCKShowBlockCommand.prototype._SetInvisible = function()
-{
-	if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
-		return ;
-	if ( ! this.StyleSheetObj )
-		return ;
-
-	if ( FCKBrowserInfo.IsIE )
-		this.StyleSheetObj.cssText = '' ;
-	else
-	{
-		if ( this.StyleSheetObj.parentNode )
-			this.StyleSheetObj.parentNode.removeChild( this.StyleSheetObj ) ;
-	}
-}
-FCKShowBlockCommand.prototype._GetCSSText = function( tags )
-{
-	var template = '$TAG'
-			+ '{'
-			+ 'background-image: url($BASEPATHimages/block_$TAG.png);' 
-			+ 'background-repeat: no-repeat;' 
-			+ 'border: 1px dotted gray;'
-			+ 'padding-top: 8px;'
-			+ 'padding-left: 8px;'
-			+ '}\n';
-
-	var retval = '' ;
-	for ( var i = 0 ; i < tags.length ; i++ )
-		retval += template.replace( new RegExp( '\\$TAG', 'g' ), tags[i] ) ;
-	retval = retval.replace( new RegExp( '\\$BASEPATH', 'g' ), FCKConfig.BasePath ) ;
-	return retval ;
-}
Index: /FCKeditor/trunk/editor/_source/internals/fckregexlib.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckregexlib.js	(revision 705)
+++ /FCKeditor/trunk/editor/_source/internals/fckregexlib.js	(revision 706)
@@ -50,5 +50,5 @@
 
 // Temporary classes (Tables without border, Anchors with content) used in IE
-FCK_Class		: /FCK__[^ ]*\s*/ ,
+FCK_Class		: /\s*FCK__[^ ]*(?=\s+|$)/ ,
 
 // Validate element names (it must be in lowercase).
Index: /FCKeditor/trunk/editor/_source/internals/fckxhtml.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckxhtml.js	(revision 705)
+++ /FCKeditor/trunk/editor/_source/internals/fckxhtml.js	(revision 706)
@@ -325,20 +325,4 @@
 }
 
-// Remove part of an attribute from a node according to a regExp
-FCKXHtml._RemoveAttribute = function( xmlNode, regX, sAttribute )
-{
-	var oAtt = xmlNode.attributes.getNamedItem( sAttribute ) ;
-
-	if ( oAtt && regX.test( oAtt.nodeValue ) )
-	{
-		var sValue = oAtt.nodeValue.replace( regX, '' ) ;
-
-		if ( sValue.length == 0 )
-			xmlNode.attributes.removeNamedItem( sAttribute ) ;
-		else
-			oAtt.nodeValue = sValue ;
-	}
-}
-
 // An object that hold tag specific operations.
 FCKXHtml.TagProcessors =
@@ -371,6 +355,4 @@
 		if ( FCKBrowserInfo.IsIE )
 		{
-			FCKXHtml._RemoveAttribute( node, FCKRegexLib.FCK_Class, 'class' ) ;
-
 			// Buggy IE, doesn't copy the name of changed anchors.
 			if ( htmlNode.name )
@@ -426,17 +408,4 @@
 	},
 
-	table : function( node, htmlNode )
-	{
-		// There is a trick to show table borders when border=0. We add to the
-		// table class the FCK__ShowTableBorders rule. So now we must remove it.
-
-		if ( FCKBrowserInfo.IsIE )
-			FCKXHtml._RemoveAttribute( node, FCKRegexLib.FCK_Class, 'class' ) ;
-
-		node = FCKXHtml._AppendChildNodes( node, htmlNode, false ) ;
-
-		return node ;
-	},
-
 	// Fix nested <ul> and <ol>.
 	ol : function( node, htmlNode, targetNode )
Index: /FCKeditor/trunk/editor/_source/internals/fckxhtml_gecko.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckxhtml_gecko.js	(revision 705)
+++ /FCKeditor/trunk/editor/_source/internals/fckxhtml_gecko.js	(revision 706)
@@ -54,5 +54,9 @@
 			//		- for the "class" attribute
 			else if ( sAttName == 'class' )
-				sAttValue = oAttribute.nodeValue ;
+			{
+				sAttValue = oAttribute.nodeValue.replace( FCKRegexLib.FCK_Class, '' ) ;
+				if ( sAttValue.length == 0 )
+					continue ;
+			}
 			// XHTML doens't support attribute minimization like "CHECKED". It must be transformed to checked="checked".
 			else if ( oAttribute.nodeValue === true )
Index: /FCKeditor/trunk/editor/_source/internals/fckxhtml_ie.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckxhtml_ie.js	(revision 705)
+++ /FCKeditor/trunk/editor/_source/internals/fckxhtml_ie.js	(revision 706)
@@ -55,5 +55,11 @@
 			//		- for the "class" attribute
 			//		- for events attributes (on IE only).
-			else if ( sAttName == 'class' || sAttName.indexOf('on') == 0 )
+			else if ( sAttName == 'class' )
+			{
+				sAttValue = oAttribute.nodeValue.replace( FCKRegexLib.FCK_Class, '' ) ;
+				if ( sAttValue.length == 0 )
+					continue ;
+			}
+			else if ( sAttName.indexOf('on') == 0 )
 				sAttValue = oAttribute.nodeValue ;
 			else if ( nodeName == 'body' && sAttName == 'contenteditable' )
Index: /FCKeditor/trunk/editor/css/fck_internal.css
===================================================================
--- /FCKeditor/trunk/editor/css/fck_internal.css	(revision 705)
+++ /FCKeditor/trunk/editor/css/fck_internal.css	(revision 706)
@@ -22,11 +22,10 @@
  */
 
-/* Fix to allow putting the caret at the end of the
-content in Firefox if clicking below the content */
+/* Fix to allow putting the caret at the end of the content in Firefox if
+   clicking below the content. */
 html
 {
 	min-height: 100%;
 }
-
 
 table.FCK__ShowTableBorders, table.FCK__ShowTableBorders td, table.FCK__ShowTableBorders th
@@ -73,6 +72,5 @@
 }
 
-/* Any anchor for non-IE, if we combine it
-   with the previous rule IE ignores all. */
+/* Any anchor for non-IE, if we combine it with the previous rule IE ignores all. */
 a[name]
 {
@@ -110,2 +108,69 @@
 	background-position: center center;
 }
+
+.FCK__ShowBlocks p,
+.FCK__ShowBlocks div,
+.FCK__ShowBlocks pre,
+.FCK__ShowBlocks address,
+.FCK__ShowBlocks h1,
+.FCK__ShowBlocks h2,
+.FCK__ShowBlocks h3,
+.FCK__ShowBlocks h4,
+.FCK__ShowBlocks h5,
+.FCK__ShowBlocks h6
+{
+	background-repeat: no-repeat;
+	border: 1px dotted gray;
+	padding-top: 8px;
+	padding-left: 8px;
+}
+
+.FCK__ShowBlocks p
+{
+	background-image: url(images/block_p.png);
+}
+
+.FCK__ShowBlocks div
+{
+	background-image: url(images/block_div.png);
+}
+
+.FCK__ShowBlocks pre
+{
+	background-image: url(images/block_pre.png);
+}
+
+.FCK__ShowBlocks address
+{
+	background-image: url(images/block_address.png);
+}
+
+.FCK__ShowBlocks h1
+{
+	background-image: url(images/block_h1.png);
+}
+
+.FCK__ShowBlocks h2
+{
+	background-image: url(images/block_h2.png);
+}
+
+.FCK__ShowBlocks h3
+{
+	background-image: url(images/block_h3.png);
+}
+
+.FCK__ShowBlocks h4
+{
+	background-image: url(images/block_h4.png);
+}
+
+.FCK__ShowBlocks h5
+{
+	background-image: url(images/block_h5.png);
+}
+
+.FCK__ShowBlocks h6
+{
+	background-image: url(images/block_h6.png);
+}
