Index: /FCKeditor/branches/developers/martinkou/editor/plugins/dragresizetable/fckplugin.js
===================================================================
--- /FCKeditor/branches/developers/martinkou/editor/plugins/dragresizetable/fckplugin.js	(revision 455)
+++ /FCKeditor/branches/developers/martinkou/editor/plugins/dragresizetable/fckplugin.js	(revision 456)
@@ -4,10 +4,9 @@
 	"_LeftCell" : null,
 	"_RightCell" : null,
-	"_OldCursor" : null,
 	"_MouseMoveMode" : 0,	// 0 - find candidate cells for resizing, 1 - drag to resize
 	"_ResizeBar" : null,
 	"_GetWindowScrollX" : function( w )
 	{
-		var scrollX = 0;
+		var scrollX = 0 ;
 		if ( w.document.documentElement && w.document.documentElement.scrollLeft ) 
 			scrollX = w.document.documentElement.scrollLeft ;
@@ -20,12 +19,12 @@
 	"_GetWindowScrollY" : function( w )
 	{
-		var scrollY = 0;
+		var scrollY = 0 ;
 		if ( w.document.documentElement && w.document.documentElement.scrollTop )
-			scrollY = w.document.documentElement.scrollTop;
+			scrollY = w.document.documentElement.scrollTop ;
 		else if ( w.document.body && w.document.body.scrollTop )
-			scrollY = w.document.body.scrollTop;
+			scrollY = w.document.body.scrollTop ;
 		else if ( w.scrollY )
-			scrollY = w.scrollY;
-		return scrollY;
+			scrollY = w.scrollY ;
+		return scrollY ;
 	},
 	"_GetDocumentPosition" : function( w, node )
@@ -76,5 +75,5 @@
 		// Get the cells whose right or left border is nearest to the mouse cursor's x coordinate.
 		var minRxDist = null ;
-		var minLxDist = null ;
+		var lxDist = null ;
 		var minYDist = null ;
 		var rbCell = null ;
@@ -83,7 +82,7 @@
 		{
 			var pos = FCKDragTableHandler._GetWindowPosition( w, cells[i] ) ;
-			var rightX = pos.x + parseInt( cells[i].offsetWidth ) ;
+			var rightX = pos.x + parseInt( cells[i].clientWidth ) ;
 			var rxDist = evt.clientX - rightX ;
-			var yDist = evt.clientY - ( pos.y + ( cells[i].offsetHeight /2 ) ) ;
+			var yDist = evt.clientY - ( pos.y + ( cells[i].clientHeight / 2 ) ) ;
 			if ( minRxDist == null || 
 					( Math.abs( rxDist ) <= Math.abs( minRxDist ) &&
@@ -95,5 +94,4 @@
 			}
 		}
-		minYDist = null ;
 		var rowNode = FCKTools.GetElementAscensor( rbCell, "tr" ) ;
 		var cellIndex = rbCell.cellIndex + 1 ;
@@ -103,20 +101,16 @@
 
 		// Abort if too far from the border.
-		if ( minLxDist < 0 && minRxDist < 0 && minLxDist < -3 )
+		lxDist = evt.clientX - FCKDragTableHandler._GetWindowPosition( w, lbCell ).x ;
+		if ( lxDist < 0 && minRxDist < 0 && lxDist < -3 )
 			return null ; 
-		if ( minLxDist > 0 && minRxDist > 0 && minRxDist > 3 )
+		if ( lxDist > 0 && minRxDist > 0 && minRxDist > 3 )
 			return null ;
 
-		return { "leftCell" : lbCell, "rightCell" : rbCell } ;
+		return { "leftCell" : rbCell, "rightCell" : lbCell } ;
 	},
 	"MouseDownListener" : function( FCK, evt )
 	{
 		if ( FCKDragTableHandler._LeftCell )
-		{
 			FCKDragTableHandler._MouseMoveMode = 1 ;
-			FCKDragTableHandler._CreateResizeBar( FCK.EditorWindow, 
-					FCKTools.GetElementAscensor( FCKDragTableHandler._LeftCell, "table" ),
-					evt ) ;
-		}
 	},
 	"MouseUpListener" : function( FCK, evt )
@@ -190,6 +184,5 @@
 			if ( ! node || node.nodeType != 1 )
 			{
-				FCK.EditorDocument.body.style.cursor = FCK.EditorDocument._OldCursor ;
-				FCK.EditorDocument._OldCursor = null ;
+				FCKDragTableHandler._HideResizeBar() ;
 				return ;
 			}
@@ -197,13 +190,40 @@
 		catch ( e )
 		{
-			FCK.EditorDocument.body.style.cursor = FCK.EditorDocument._OldCursor ;
-			FCK.EditorDocument._OldCursor = null ;
+			FCKDragTableHandler._HideResizeBar() ;
 			return ;
 		}
+
+		if ( FCKDragTableHandler._ResizeBar && FCKDragTableHandler._LeftCell )
+		{
+			var leftPos = FCKDragTableHandler._GetWindowPosition( FCK.EditorWindow, FCKDragTableHandler._LeftCell ) ;
+			var rightPos = FCKDragTableHandler._GetWindowPosition( FCK.EditorWindow, FCKDragTableHandler._RightCell ) ; 
+			var lxDist = evt.clientX - ( leftPos.x + FCKDragTableHandler._LeftCell.clientWidth ) ;
+			var rxDist = evt.clientX - rightPos.x ;
+			var inRangeFlag = false ;
+			if ( lxDist > 0 && rxDist < 0 )
+				inRangeFlag = true ;
+			else if ( rxDist > 0 && rxDist < 3 )
+				inRangeFlag = true ;
+			else if ( lxDist < 0 && lxDist > -3 )
+				inRangeFlag = true ;
+			if ( inRangeFlag )
+			{
+				FCKDragTableHandler._ShowResizeBar( FCK.EditorWindow, 
+					FCKTools.GetElementAscensor( FCKDragTableHandler._LeftCell, "table" ),
+					evt ) ;
+				return ;
+			}
+		}
+
 		var tagName = node.tagName.toLowerCase() ;
 		if ( tagName != "table" && tagName != "td" && tagName != "th" )
 		{
-			FCK.EditorDocument.body.style.cursor = FCK.EditorDocument._OldCursor ;
-			FCK.EditorDocument._OldCursor = null ;
+			if ( FCKDragTableHandler._LeftCell )
+			{
+				FCKDragTableHandler._LeftCell.style.backgroundColor = "transparent";
+				FCKDragTableHandler._RightCell.style.backgroundColor = "transparent";
+				FCKDragTableHandler._LeftCell = FCKDragTableHandler._RightCell = null ;
+			}
+			FCKDragTableHandler._HideResizeBar() ;
 			return ;
 		}
@@ -214,14 +234,25 @@
 		{
 			if ( FCKDragTableHandler._LeftCell )
+			{
+				FCKDragTableHandler._LeftCell.style.backgroundColor = "transparent";
+				FCKDragTableHandler._RightCell.style.backgroundColor = "transparent";
 				FCKDragTableHandler._LeftCell = FCKDragTableHandler._RightCell = null ;
-			FCK.EditorDocument.body.style.cursor = FCK.EditorDocument._OldCursor ;
-			FCK.EditorDocument._OldCursor = null ;
+			}
+			FCKDragTableHandler._HideResizeBar() ;
 		}
 		else
 		{
-			FCKDragTableHandler._OldCursor = FCK.EditorDocument.body.style.cursor ;
-			FCK.EditorDocument.body.style.cursor = "e-resize" ;
+			if (FCKDragTableHandler._LeftCell && FCKDragTableHandler._LeftCell != cellTuple["leftCell"])
+			{
+				FCKDragTableHandler._LeftCell.style.backgroundColor = "transparent";
+				FCKDragTableHandler._RightCell.style.backgroundColor = "transparent";
+			}
 			FCKDragTableHandler._LeftCell = cellTuple["leftCell"] ;
 			FCKDragTableHandler._RightCell = cellTuple["rightCell"] ;
+			cellTuple["leftCell"].style.backgroundColor = "red";
+			cellTuple["rightCell"].style.backgroundColor = "green";
+			FCKDragTableHandler._ShowResizeBar( FCK.EditorWindow, 
+					FCKTools.GetElementAscensor( FCKDragTableHandler._LeftCell, "table" ),
+					evt ) ;
 		}
 	},
@@ -229,5 +260,5 @@
 	{
 	},
-	"_CreateResizeBar" : function( w, table, evt )
+	"_ShowResizeBar" : function( w, table, evt )
 	{
 		if ( FCKDragTableHandler._ResizeBar == null )
@@ -237,11 +268,14 @@
 			rb.style.position = "absolute" ;
 			rb.style.backgroundColor = "blue" ;
+			rb.style.cursor = "e-resize" ;
+			if ( FCKBrowserInfo.IsIE )
+				rb.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=25,enabled=true)" ;
+			else
+				rb.style.opacity = 0.25 ;
 			w.document.body.appendChild( rb ) ;
 		}
 
 		var rb = FCKDragTableHandler._ResizeBar ;
-		rb.style.display = "" ;
 		rb.style.top = FCKDragTableHandler._GetDocumentPosition( w, table ).y + "px" ;
-		rb.style.left = evt.clientX + FCKDragTableHandler._GetWindowScrollX( w ) + "px" ;
 		rb.style.height = table.offsetHeight + "px" ;
 		var bw = parseInt( table.border ) ;
@@ -253,4 +287,15 @@
 		var barWidth = Math.max( bw, cs, 2 ) ;
 		rb.style.width = barWidth + "px" ;
+		rb.style.left = ( evt.clientX + FCKDragTableHandler._GetWindowScrollX( w ) - barWidth / 2 ) +  "px" ;
+	},
+	"_HideResizeBar" : function()
+	{
+		if ( FCKDragTableHandler._ResizeBar )
+		{
+			// IE bug: display : none does not hide the resize bar for some reason.
+			// so set the position to somewhere invisible.
+			FCKDragTableHandler._ResizeBar.style.top = "-100000px" ;
+			FCKDragTableHandler._ResizeBar.style.left = "-100000px" ;
+		}
 	}
 };
