Index: trunk/expressoMail1_2/js/TreeShow.js
===================================================================
--- trunk/expressoMail1_2/js/TreeShow.js	(revision 1360)
+++ trunk/expressoMail1_2/js/TreeShow.js	(revision 1368)
@@ -87,18 +87,13 @@
 		var aux = ttree.FOLDER.split(cyrus_delimiter);
 		var aux2;
-
 		if(ttree.FOLDER != ""){
-			if(aux.length > 1){aux2 = aux[1];}
+			if(aux.length[1] > 1){aux2 = aux[1];}
 			else{aux2 = aux[0];}
-			if(this.verify_names(aux2)){
-				if(func == "newpast")
-                   alert(get_lang("It's not possible create inside: ") + (get_lang(special_folders[aux2])));
-				if(func == "rename")
-                   alert(get_lang("It's not possible rename the folder: ") + (get_lang(special_folders[aux2])));
-				return false;
-			}else{
-				if(func == "newpast"){
-                    var button = prompt(get_lang('Enter the name of the new folder:'),"");
-					
+			if(func == "rename" && this.verify_names(aux2)){
+			       alert(get_lang("It's not possible rename the folder: ") + (get_lang(special_folders[aux2])));
+			       return false;
+			}else{
+			if(func == "newpast"){
+	                    var button = prompt(get_lang('Enter the name of the new folder:'),"");
 					if (button.indexOf("local_") != -1  || button.toUpperCase() == "INBOX") {
 						alert(get_lang("cannot create folder. try other folder name"));
@@ -138,35 +133,30 @@
 		}
 	}
- 	
- 	// Para criar a nova pasta;
- 	Tree_Box.prototype.new_past = function(newp){
-
-	var aux   = ttree.FOLDER.split(cyrus_delimiter);
-	var newp2 = "";
-		
-		if(aux.length == 1 && aux[0] != "root"){
-            alert(get_lang("It's not possible create inside: ") + aux[0]);
-			newp = "";
-		}else{
-			if( aux[0] == "root"){
-				if(!this.verify(newp)){
-                    alert(get_lang("Type without spaces, dots or special characters!"));
-					newp = "";
-					return false;
-				}else{
-					newp2 = newp;
-					newp = "INBOX" + cyrus_delimiter + newp;
-				}
-			}else{
-				if(!this.verify(newp)){
-                    alert(get_lang("Type without spaces, dots or special characters!"));
-					newp = "";
-					return false;
-				}else{
-					newp2 = newp;
-					newp = ttree.FOLDER + cyrus_delimiter + newp;
-				}
-			}
-		}
+
+// Para criar a nova pasta;
+	Tree_Box.prototype.new_past = function(newp){
+
+		var aux   = ttree.FOLDER.split(cyrus_delimiter);
+		var newp2 = "";
+		if( aux[0] == "root"){
+			if(!this.verify(newp)){
+				alert(get_lang("Type without spaces, dots or special characters!"));
+				newp = "";
+				return false;
+			}else{
+				newp2 = newp;
+				newp = "INBOX" + cyrus_delimiter + newp;
+			}
+		}else{
+			if(!this.verify(newp)){
+				alert(get_lang("Type without spaces, dots or special characters!"));
+				newp = "";
+				return false;
+			}else{
+				newp2 = newp;
+				newp = ttree.FOLDER + cyrus_delimiter + newp;
+			}
+		}
+
 		if(newp != ""){
 			var handler_return = function(data){		
@@ -251,5 +241,5 @@
 	// Função para deletar a pasta;
 	Tree_Box.prototype.del = function(){
-	
+		var folder_name = ttree.FOLDER;
 		var aux = ttree.FOLDER.split(cyrus_delimiter);
 
@@ -263,9 +253,9 @@
 			return false;
 		}else{
-			if(this.verify_names(aux[1])){
+			if(this.verify_names(aux[1]) && typeof(aux[2]) == 'undefined'){
 	            alert(get_lang("It's not possible delete the folder: ") + get_lang(special_folders[aux[1]]));	 
       			return false;
 			}else{
-				this.verify_children(ttree.FOLDER);
+				this.verify_children(folder_name);
 			}
 		}	
@@ -273,5 +263,4 @@
 	
 	Tree_Box.prototype.del_past = function(param){
-
 		var aux = param.split(cyrus_delimiter);
 		var aux1 = aux.pop();
@@ -288,8 +277,8 @@
 					alert(data);
 				}else{
-					ttree.FOLDER = "";
 					purgeCache();
+					ttreeBox.name_folder = "root";
 					ttreeBox.update_folder();
-                    alert(get_lang("The folder %1 was successfully removed", aux1));
+					alert(get_lang("The folder %1 was successfully removed", aux1));
 				}
 			}
