Index: FCKeditor/trunk/_whatsnew.html
===================================================================
--- FCKeditor/trunk/_whatsnew.html	(revision 1799)
+++ FCKeditor/trunk/_whatsnew.html	(revision 1803)
@@ -139,4 +139,8 @@
 			dialogs using API calls which deals with the selection, like InsertHtml now can
 			be sure the selection will be placed in the correct position.</li>
+		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1997">#1997</a>] With
+			IE, the first character of table captions where being lost on table creation.</li>
+		<li>The selection and cursor position was not being properly handled when creating some
+			elements like forms and tables.</li>
 	</ul>
 	<h3>
Index: FCKeditor/trunk/editor/_source/classes/fckdomrange.js
===================================================================
--- FCKeditor/trunk/editor/_source/classes/fckdomrange.js	(revision 1799)
+++ FCKeditor/trunk/editor/_source/classes/fckdomrange.js	(revision 1803)
@@ -150,10 +150,18 @@
 	MoveToElementEditStart : function( targetElement )
 	{
-		var child ;
-
-		while ( ( child = targetElement.firstChild ) && child.nodeType == 1 && FCKListsLib.InlineNonEmptyElements[ child.nodeName.toLowerCase() ] )
-			targetElement = child ;
-
-		this.MoveToElementStart( targetElement ) ;
+		var editableElement ;
+
+		while ( targetElement && targetElement.nodeType == 1 )
+		{
+			if ( FCKDomTools.CheckIsEditable( targetElement ) )
+				editableElement = targetElement ;
+			else if ( editableElement )
+				break ;		// If we already found an editable element, stop the loop.
+
+			targetElement = targetElement.firstChild ;
+		}
+
+		if ( editableElement )
+			this.MoveToElementStart( editableElement ) ;
 	},
 
Index: FCKeditor/trunk/editor/_source/internals/fck.js
===================================================================
--- FCKeditor/trunk/editor/_source/internals/fck.js	(revision 1799)
+++ FCKeditor/trunk/editor/_source/internals/fck.js	(revision 1803)
@@ -672,5 +672,5 @@
 			range.InsertNode( element ) ;
 
-			var next = FCKDomTools.GetNextSourceElement( element, false, null, [ 'hr','br','param','img','area','input' ] ) ;
+			var next = FCKDomTools.GetNextSourceElement( element, false, null, [ 'hr','br','param','img','area','input' ], true ) ;
 
 			// Be sure that we have something after the new element, so we can move the cursor there.
Index: FCKeditor/trunk/editor/_source/internals/fckdomtools.js
===================================================================
--- FCKeditor/trunk/editor/_source/internals/fckdomtools.js	(revision 1799)
+++ FCKeditor/trunk/editor/_source/internals/fckdomtools.js	(revision 1803)
@@ -1006,4 +1006,19 @@
 		if ( offset > 0 && offset > currentScroll )
 			window.scrollTo( 0, offset ) ;
+	},
+
+	/**
+	 * Check if the element can be edited inside the browser.
+	 */
+	CheckIsEditable : function( element )
+	{
+		// Get the element name.
+		var nodeName = element.nodeName.toLowerCase() ;
+
+		// Get the element DTD (defaults to span for unknown elements).
+		var childDTD = FCK.DTD[ nodeName ] || FCK.DTD.span ;
+
+		// In the DTD # == text node.
+		return ( childDTD['#'] && !FCKListsLib.NonEditableElements[ nodeName ] ) ;
 	}
 } ;
Index: FCKeditor/trunk/editor/_source/internals/fcklistslib.js
===================================================================
--- FCKeditor/trunk/editor/_source/internals/fcklistslib.js	(revision 1799)
+++ FCKeditor/trunk/editor/_source/internals/fcklistslib.js	(revision 1803)
@@ -55,4 +55,7 @@
 	StyleObjectElements : { img:1,hr:1,li:1,table:1,tr:1,td:1,embed:1,object:1,ol:1,ul:1 },
 
+	// Elements that accept text nodes, but are not possible to edit in the browser.
+	NonEditableElements : { button:1,option:1,script:1,iframe:1,textarea:1,object:1,embed:1,map:1,applet:1 },
+
 	// Elements used to separate block contents.
 	BlockBoundaries : { p:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,address:1,pre:1,ol:1,ul:1,li:1,dt:1,de:1,table:1,thead:1,tbody:1,tfoot:1,tr:1,th:1,td:1,caption:1,col:1,colgroup:1,blockquote:1,body:1 },
Index: FCKeditor/trunk/editor/dtd/fck_dtd_test.html
===================================================================
--- FCKeditor/trunk/editor/dtd/fck_dtd_test.html	(revision 1799)
+++ FCKeditor/trunk/editor/dtd/fck_dtd_test.html	(revision 1803)
@@ -17,6 +17,4 @@
 	<table border="1">
 		<script type="text/javascript">
-
-    alert(FCK.DTD);
 
 for ( var p in FCK.DTD )
Index: FCKeditor/trunk/editor/fckdialog.html
===================================================================
--- FCKeditor/trunk/editor/fckdialog.html	(revision 1799)
+++ FCKeditor/trunk/editor/fckdialog.html	(revision 1803)
@@ -673,4 +673,5 @@
 	window.Cancel = function( dontFireChange )
 	{
+		Selection.EnsureSelection() ;
 		return CloseDialog( dontFireChange ) ;
 	} ;
@@ -679,6 +680,4 @@
 	{
 		Throbber.Hide() ;
-
-		Selection.EnsureSelection() ;
 
 		// Points the src to a non-existent location to avoid loading errors later, in case the dialog
