Index: branches/2.2/filemanager/js/handler.js
===================================================================
--- branches/2.2/filemanager/js/handler.js	(revision 3897)
+++ branches/2.2/filemanager/js/handler.js	(revision 3913)
@@ -4,5 +4,5 @@
 	{
 		var returnVal = data.split('|');
-		
+
 		if (returnVal[0] == 'False')
 		{
@@ -10,14 +10,14 @@
 		}
 		else
-		
+
 		if (returnVal[0] == 'wpasswd')
-		{
-			write_error(get_lang('Wrong password'));
-			return;
-		}
-		else
-			 write_msg(get_lang('Your operation was successfully executed'));
-		
-		toolbar.control('reload');
+	{
+		write_error(get_lang('Wrong password'));
+		return;
+	}
+	else
+		write_msg(get_lang('Your operation was successfully executed'));
+
+	toolbar.control('reload');
 	}
 
@@ -25,5 +25,5 @@
 	{
 		var returnVal = data.split('|');
-		
+
 		if (returnVal[0] == 'NODIR')
 			write_error(get_lang('Could not copy file because no destination directory is given'));
@@ -149,46 +149,48 @@
 	}
 
-	function rename(data) 
-	{
-		if ( data == null )
-		{
-			var returnVal = new Array ("True",oldValue,oldValue);
-		}
-		else
-			var returnVal = data.split('|');
-		
-		if ( returnVal[0] == "True" )
-		{
-			if ( returnVal[1] != returnVal[2] ) 
-				write_msg(get_lang('Renamed %1 to %2',returnVal[1],returnVal[2]));
-			
-			var nameLink = document.createElement('A');
-			var inputName = document.getElementById('input_'+returnVal[1]);
-			var trFile = inputName.parentNode.parentNode.parentNode;
-
-			nameLink.innerHTML = returnVal[2];
-			nameLink.href="./index.php?menuaction=filemanager.uifilemanager.view&file="
-					+ base64_encode(returnVal[2])+"&path="+base64_encode(currentPath);
-			nameLink.target = "_blank";
-			nameLink.id = "name_"+returnVal[2];
-
-			inputName.parentNode.appendChild(nameLink);
-			inputName.parentNode.removeChild(inputName);
-			trFile.innerHTML = trFile.innerHTML.replace(returnVal[1],returnVal[2]);
-			trFile.id = trFile.id.replace(returnVal[1],returnVal[2]);
-			toolbar.control('reload');
-		}
-		else
-		{
-			if ( returnVal[1] == "badchar" )
-				write_error(get_lang('File names cannot contain "%1"',returnVal[2]));
-			else if (returnVal[1] == "slashes")
-				write_error(get_lang('File names cannot contain \\ or /'));
-			else if (returnVal[1] == "editing")
-				write_error(get_lang('This file is being edited right now'));
-			else
-				write_error(get_lang('Could not rename %1 to %2', returnVal[1], returnVal[2]));
-		}
-
+	function rename() 
+	{
+		var _handlerRename =  function(data)
+		{
+			var _data = unserialize( data );
+
+			for( var i = 0 ; i < _data.length; i++ )
+			{	
+				if( _data[i]['error'] )
+					write_msg(_data[i]['error'] );
+
+				if( _data[i]['true'] )
+					write_msg(_data[i]['true'] );
+			}
+		}
+
+		if( arguments.length > 1 )
+		{	
+			var _input	= arguments[0];
+			var _span	= arguments[1]	;
+			var _parent	= _input.parentNode;
+
+			_input.style.height = ( parseInt(_input.style.height) - 4 );
+
+			_span.style.className	= "fileLink";
+			_span.innerHTML = _input.value;
+
+			if( _parent != null )
+			{	
+				// Remove Input
+				if( _input != null )
+					_parent.removeChild( _input );
+
+				// Add Span
+				if( _span != null ) 
+					_parent.appendChild( _span );
+
+				var url		= './index.php?menuaction=filemanager.vfs_functions.rename';
+				var params	= 'file='+base64_encode(_input.id.substr(6))+'&to='+base64_encode(_input.value)+'&path='+base64_encode(currentPath);
+
+				cExecute_(  url,  _handlerRename , params );
+			}
+
+		}
 	}
 	
@@ -197,6 +199,6 @@
 		if (data.indexOf("True") == 0)
 		{
-				returnVal = data.split('|');
-				var img_lock = document.getElementById('restrict_'+returnVal[1]);
+			returnVal = data.split('|');
+			var img_lock = document.getElementById('restrict_'+returnVal[1]);
 
 			if (img_lock.style.backgroundImage.indexOf('button_unlock') > 0)
@@ -243,5 +245,5 @@
 			 * response['max_postsize] = diretiva do PHP para POST_MAX_SIZE;
 			 */ 
-			
+
 			write_msg( get_lang("ERROR: Use the advanced file sending!") );
 			return false;
@@ -257,9 +259,9 @@
 					{	
 						var _indexOf = response[i]['file'].toUpperCase().indexOf(_inputs[j].value.toUpperCase() );
-						
+
 						if( response[i]['file'].toUpperCase() === _inputs[j].value.toUpperCase() && _indexOf > -1 )
 						{	
 							_inputs[j].parentNode.setAttribute("erroUpload", "true");
-							
+
 							var _parent	= _inputs[j].parentNode;
 							var _div = _parent.firstChild;	
@@ -271,9 +273,9 @@
 							_div.style.cursor			= "pointer";
 							_div.onclick	= function(){this.style.display = 'none';} ;
-							
+
 							if( response[i]['size_max'] )
 							{
 								_div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: Tamanho do arquivo " 
-											  + borkb( response[i]['size'] ) + "  - Permitido  " + borkb( response[i]['size_max'] );
+									+ borkb( response[i]['size'] ) + "  - Permitido  " + borkb( response[i]['size_max'] );
 							}
 							else if( response[i]['badchar'] )
@@ -291,5 +293,5 @@
 							else if( response[i]['undefined'] )
 							{
-								_div.innerHTML = "<span style='font-weight:bold' >Arquivo Duplicado </span>:: "  + response[i]['file'];	
+								_div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: "  + response[i]['undefined'];	
 							}
 							else if( response[i]['filesize'] )
@@ -298,8 +300,13 @@
 							}
 						}
+						else
+						{
+							write_msg( response[i]['undefined'] );
+							_winBuild( "dwindownewUpload" , "remove" );	
+						}
 					}
 				}	
 			}
-			
+
 			for( var j = 0 ; j < _inputs.length ; j++ )
 			{	
@@ -335,4 +342,4 @@
 
 	window.handler = new handler;
-	
+
 })();
