Index: /FCKeditor/branches/features/div_container/editor/_source/classes/fckdomrange.js
===================================================================
--- /FCKeditor/branches/features/div_container/editor/_source/classes/fckdomrange.js	(revision 2206)
+++ /FCKeditor/branches/features/div_container/editor/_source/classes/fckdomrange.js	(revision 2207)
@@ -43,5 +43,4 @@
 			// For text nodes, the node itself is the StartNode.
 			var eStart	= innerRange.startContainer ;
-			var eEnd	= innerRange.endContainer ;
 
 			var oElementPath = new FCKElementPath( eStart ) ;
@@ -51,31 +50,38 @@
 			this.StartBlockLimit	= oElementPath.BlockLimit ;
 
-			if ( eStart != eEnd )
-				oElementPath = new FCKElementPath( eEnd ) ;
-
-			// The innerRange.endContainer[ innerRange.endOffset ] is not
-			// usually part of the range, but the marker for the range end. So,
-			// let's get the previous available node as the real end.
-			var eEndNode = eEnd ;
-			if ( innerRange.endOffset == 0 )
+			if ( innerRange.collapsed )
 			{
-				while ( eEndNode && !eEndNode.previousSibling )
-					eEndNode = eEndNode.parentNode ;
-
-				if ( eEndNode )
-					eEndNode = eEndNode.previousSibling ;
+				this.EndNode		= this.StartNode ;
+				this.EndContainer	= this.StartContainer ;
+				this.EndBlock		= this.StartBlock ;
+				this.EndBlockLimit	= this.StartBlockLimit ;
 			}
-			else if ( eEndNode.nodeType == 1 )
+			else
 			{
-				if ( innerRange.endContainer != innerRange.startContainer || innerRange.endOffset != innerRange.startOffset )
+				var eEnd	= innerRange.endContainer ;
+
+				if ( eStart != eEnd )
+					oElementPath = new FCKElementPath( eEnd ) ;
+
+				// The innerRange.endContainer[ innerRange.endOffset ] is not
+				// usually part of the range, but the marker for the range end. So,
+				// let's get the previous available node as the real end.
+				var eEndNode = eEnd ;
+				if ( innerRange.endOffset == 0 )
+				{
+					while ( eEndNode && !eEndNode.previousSibling )
+						eEndNode = eEndNode.parentNode ;
+
+					if ( eEndNode )
+						eEndNode = eEndNode.previousSibling ;
+				}
+				else if ( eEndNode.nodeType == 1 )
 					eEndNode = eEndNode.childNodes[ innerRange.endOffset - 1 ] ;
-				else
-					eEndNode = eEndNode.childNodes[ innerRange.endOffset ] ;
+
+				this.EndNode			= eEndNode ;
+				this.EndContainer		= eEnd ;
+				this.EndBlock			= oElementPath.Block ;
+				this.EndBlockLimit		= oElementPath.BlockLimit ;
 			}
-
-			this.EndNode			= eEndNode ;
-			this.EndContainer		= eEnd ;
-			this.EndBlock			= oElementPath.Block ;
-			this.EndBlockLimit		= oElementPath.BlockLimit ;
 		}
 
Index: /FCKeditor/branches/features/div_container/editor/_source/internals/fckdomtools.js
===================================================================
--- /FCKeditor/branches/features/div_container/editor/_source/internals/fckdomtools.js	(revision 2206)
+++ /FCKeditor/branches/features/div_container/editor/_source/internals/fckdomtools.js	(revision 2207)
@@ -1029,6 +1029,6 @@
 		range.MoveToSelection() ;
 
-		var startNode = range.StartNode ;
-		var endNode = range.EndNode ;
+		var startNode = range.GetTouchedStartNode() ;
+		var endNode = range.GetTouchedEndNode() ;
 		var currentNode = startNode ;
 
@@ -1037,8 +1037,8 @@
 			while ( endNode.nodeType == 1 && endNode.lastChild )
 				endNode = endNode.lastChild ;
-			endNode = FCKDomTools.GetNextSourceElement( endNode ) ;
-		}
-
-		while ( currentNode && currentNode != endNode && currentNode != endNode.parentNode )
+			endNode = FCKDomTools.GetNextSourceNode( endNode ) ;
+		}
+
+		while ( currentNode && currentNode != endNode )
 		{
 			var path = new FCKElementPath( currentNode ) ;
@@ -1047,5 +1047,5 @@
 				currentBlocks.push( blockLimit ) ;
 
-			currentNode = FCKDomTools.GetNextSourceElement( currentNode ) ;
+			currentNode = FCKDomTools.GetNextSourceNode( currentNode ) ;
 		}
 
Index: /FCKeditor/branches/features/div_container/editor/dialog/fck_div.html
===================================================================
--- /FCKeditor/branches/features/div_container/editor/dialog/fck_div.html	(revision 2206)
+++ /FCKeditor/branches/features/div_container/editor/dialog/fck_div.html	(revision 2207)
@@ -111,17 +111,18 @@
 	// Popuplate the style menu
 	var styles = FCKStyles.GetStyles() ;
-	var match = null ;
 	var selectableStyles = {} ;
+	for ( var i in styles )
+	{
+		if ( ! /^_FCK_/.test( i ) && styles[i].Element == 'div' )
+			selectableStyles[i] = styles[i] ;
+	}
 	if ( CurrentContainers.length <= 1 )
 	{
 		var target = CurrentContainers[0] ;
-		for ( var i in styles )
-		{
-			if ( ! /^_FCK_/.test( i ) && styles[i].Element == 'div' )
-			{
-				if ( target && styles[i].CheckElementRemovable( target, true ) )
-					match = i ;
-				selectableStyles[i] = styles[i] ;
-			}
+		var match = null ;
+		for ( var i in selectableStyles )
+		{
+			if ( target && styles[i].CheckElementRemovable( target, true ) )
+				match = i ;
 		}
 		if ( !match )
@@ -145,5 +146,8 @@
 	else
 	{
-		GetE( 'txtId' ).disabled = GetE( 'selStyle' ).disabled = true  ;
+		GetE( 'txtId' ).disabled = true ;
+		AddStyleOption( "" ) ;
+		for ( var i in selectableStyles )
+			AddStyleOption( i ) ;
 	}
 }
