Index: /FCKeditor/branches/features/div_container/editor/_source/internals/fck_contextmenu.js
===================================================================
--- /FCKeditor/branches/features/div_container/editor/_source/internals/fck_contextmenu.js	(revision 2170)
+++ /FCKeditor/branches/features/div_container/editor/_source/internals/fck_contextmenu.js	(revision 2171)
@@ -298,5 +298,5 @@
 			AddItems : function( menu, tag, tagName )
 			{
-				var path = new FCKElementPath( FCKSelection.GetParentElement() ) ;
+				var path = new FCKElementPath( FCKSelection.GetSelectedElement() || FCKSelection.GetParentElement() ) ;
 				if ( path.BlockLimit && path.BlockLimit.nodeName.IEquals( 'div' ) )
 				{
Index: /FCKeditor/branches/features/div_container/editor/_source/internals/fckselection_gecko.js
===================================================================
--- /FCKeditor/branches/features/div_container/editor/_source/internals/fckselection_gecko.js	(revision 2170)
+++ /FCKeditor/branches/features/div_container/editor/_source/internals/fckselection_gecko.js	(revision 2171)
@@ -76,7 +76,15 @@
 		if ( oSel )
 		{
-			// make the common case fast - for collapsed/nearly collapsed selections just return anchor.parent.
+			// if anchorNode == focusNode, see if the selection is text only or including nodes.
+			// if text only, return the parent node.
+			// if the selection includes DOM nodes, then the anchorNode is the nearest container.
 			if ( oSel.anchorNode && oSel.anchorNode == oSel.focusNode )
-				return oSel.anchorNode.parentNode ;
+			{
+				var oRange = oSel.getRangeAt( 0 ) ;
+				if ( oRange.collapsed || oRange.startContainer.nodeType == 3 )
+					return oSel.anchorNode.parentNode ;
+				else
+					return oSel.anchorNode ;
+			}
 
 			// looks like we're having a large selection here. To make the behavior same as IE's TextRange.parentElement(),
Index: /FCKeditor/branches/features/div_container/editor/dialog/fck_div.html
===================================================================
--- /FCKeditor/branches/features/div_container/editor/dialog/fck_div.html	(revision 2170)
+++ /FCKeditor/branches/features/div_container/editor/dialog/fck_div.html	(revision 2171)
@@ -38,8 +38,9 @@
 var AlwaysCreate = dialog.Args().CustomValue ;
 
-var ActiveEl = !AlwaysCreate ? dialog.Selection.GetSelection().MoveToAncestorNode( 'DIV' ) : null ;
-if ( ActiveEl )
-{
-	ActiveEl = ( new FCKElementPath( ActiveEl ) ).BlockLimit ;
+var ActiveEl = null ;
+if ( !AlwaysCreate )
+{
+	var oSelection = dialog.Selection.GetSelection() ;
+	ActiveEl = ( new FCKElementPath( oSelection.GetSelectedElement() || oSelection.GetParentElement() ) ).BlockLimit ;
 	if ( ActiveEl && ActiveEl.nodeName.toLowerCase() != 'div' )
 		ActiveEl = null ;
