Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 5200)
+++ trunk/expressoMail1_2/js/main.js	(revision 5211)
@@ -539,10 +539,10 @@
  		        { 
  		          var arrayFolder = folder.split(cyrus_delimiter); 
- 		          userTrashFolder = 'user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+trashfolder;  
+ 		          userTrashFolder = 'user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Trash'];  
  		        } 
-				else userTrashFolder = 'INBOX'+cyrus_delimiter+trashfolder; 
+				else userTrashFolder = 'INBOX'+cyrus_delimiter+special_folders['Trash']; 
  	 
  		        if(openTab.type[currentTab] == 1) 
-					return move_search_msgs('content_id_'+currentTab,userTrashFolder,trashfolder); 
+					return move_search_msgs('content_id_'+currentTab,userTrashFolder,special_folders['Trash']); 
 					
 				if(currentTab.toString().indexOf("_r") != -1) 
@@ -550,5 +550,5 @@
  		         
  		        if (!archive && (parseInt(preferences.save_deleted_msg)) && (folder != userTrashFolder)){ 
- 		                move_msgs2(folder, msgs_number, border_ID, userTrashFolder,trashfolder,show_success_msg ); 
+ 		                move_msgs2(folder, msgs_number, border_ID, userTrashFolder,special_folders['Trash'],show_success_msg ); 
 				return;
 	}
@@ -749,12 +749,12 @@
 			params += "&new_folder_name_move="+url_encode(new_folder_name);
 		
-			new_folder = 'INBOX'+cyrus_delimiter+trashfolder;
-			new_folder_name = trashfolder;
+			new_folder = 'INBOX'+cyrus_delimiter+special_folders['Trash'];
+			new_folder_name = special_folders['Trash'];
 			params += "&selected_messages_delete="+url_encode(msg_to_delete);
 			params += "&new_folder_delete="+url_encode(new_folder);
 			cExecute ("$this.imap_functions.move_delete_search_messages", handler_move_search_msgs, params);
 		}else if(msg_to_delete != ""){
-			new_folder = 'INBOX'+cyrus_delimiter+trashfolder;
-			new_folder_name = trashfolder;
+			new_folder = 'INBOX'+cyrus_delimiter+special_folders['Trash'];
+			new_folder_name = special_folders['Trash'];
 			params += "&delete=true";
 			params += "&selected_messages="+url_encode(msg_to_delete);
@@ -775,5 +775,6 @@
 function move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,show_success_msg, not_opem_previus){
 	not_opem_previus = typeof(not_opem_previus) != 'undefined' ? not_opem_previus : false;
-	if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( msgs_number, folder ) ){
+	var folder_error = new_folder_name;
+        if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( msgs_number, folder ) ){
 	    alert( "Impossivel mover mensagens que estão ainda estão sendo arquivadas." );
 	    return;
@@ -789,6 +790,6 @@
 			if (data.match(/^(.*)TRYCREATE(.*)$/)){
 				connector.loadScript('TreeS');
-				var move_to_folder = data.match(/^(.*)Spam(.*)$/) ? "Spam" : trashfolder;
-				alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.', move_to_folder));
+				var move_to_folder = data.match(/^(.*)Spam(.*)$/) ? "Spam" : special_folders['Trash'];
+				alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.', folder_error));
 				connector.loadScript('TreeShow');
 				ttree.FOLDER = 'root';
@@ -1081,5 +1082,5 @@
 {
     var msgs_to_remove = {};
-    var target = 'INBOX' + cyrus_delimiter + trashfolder + cyrus_delimiter + 'tmpMoveToLocal';
+    var target = 'INBOX' + cyrus_delimiter + special_folders['Trash'] + cyrus_delimiter + 'tmpMoveToLocal';
     
     success = expresso_local_messages.select_mail( [ 'original_id', 'original_folder' ], success );
@@ -1269,6 +1270,7 @@
 			show_msg_img(border_ID.match(/^\d*/)[0], Element('input_folder_'+border_ID).value);
 		}
-	var new_border_ID = draw_new_message(parseInt(border_ID));
-	if(typeof(openTab.type[new_border_ID]) != "undefined") {
+        var new_border_ID = draw_new_message(parseInt(border_ID.replace('_r','')));
+      	
+        if(typeof(openTab.type[new_border_ID]) != "undefined") {
 		if(tabTypes[type] == openTab.type[new_border_ID]) {
                     if (type != 'edit')
@@ -2821,10 +2823,10 @@
 		if(!verify_session(data))
 			return;
-		tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder).alter({caption: get_lang("Trash")});
-		tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder)._refresh();
+		tree_folders.getNodeById('INBOX'+cyrus_delimiter+special_folders['Trash']).alter({caption: get_lang("Trash")});
+		tree_folders.getNodeById('INBOX'+cyrus_delimiter+special_folders['Trash'])._refresh();
 		update_quota(get_current_folder());
 		if (data){
 			write_msg(get_lang('Your Trash folder was empty.'));
-			if (get_current_folder() == 'INBOX'+cyrus_delimiter+trashfolder){
+			if (get_current_folder() == 'INBOX'+cyrus_delimiter+special_folders['Trash']){
 				draw_paging(0);
 				remove_rows(document.getElementById("table_box"));				
@@ -2846,10 +2848,10 @@
 		if(!verify_session(data))
 			return;
-		if (get_current_folder() == 'INBOX'+cyrus_delimiter+spamfolder){
+		if (get_current_folder() == 'INBOX'+cyrus_delimiter+special_folders['Spam']){
 			draw_paging(0);
 			remove_rows(document.getElementById("table_box"));
 		}
-		tree_folders.getNodeById('INBOX'+cyrus_delimiter+spamfolder).alter({caption: get_lang("Spam")});
-		tree_folders.getNodeById('INBOX'+cyrus_delimiter+spamfolder)._refresh();
+		tree_folders.getNodeById('INBOX'+cyrus_delimiter+special_folders['Spam']).alter({caption: get_lang("Spam")});
+		tree_folders.getNodeById('INBOX'+cyrus_delimiter+special_folders['Spam'])._refresh();
 		update_quota(get_current_folder());
 		if (data)
@@ -3010,9 +3012,9 @@
 	{       
 		arrayFolder = folder.split(cyrus_delimiter);
-		new_folder = 'user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+spamfolder;
+		new_folder = 'user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Spam'];
 	}
 	else
 	{
-		new_folder = 'INBOX' + cyrus_delimiter + spamfolder;
+		new_folder = 'INBOX' + cyrus_delimiter + special_folders['Spam'];
 	}
 	var new_folder_name = 'Spam';
@@ -3029,5 +3031,5 @@
 		msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));
 	else if(currentTab != 0 && currentTab.indexOf("search_")  >= 0){
-		var content_search = document.getElementById('content_id_'+currentTab);  'INBOX/Trash', 'Trash',
+		var content_search = document.getElementById('content_id_'+currentTab);'INBOX/Trash', 'Trash',
 		move_search_msgs('content_id_'+currentTab,  'INBOX'+cyrus_delimiter+special_folders['Spam'], special_folders['Spam']);
 		refresh();
@@ -3216,5 +3218,5 @@
                write_msg(data.append);
 	}
-        cExecute('$this.imap_functions.ope_msg_part&msg_folder='+data+'&save_folder=INBOX'+cyrus_delimiter+trashfolder , handler_open_msg_part);	
+        cExecute('$this.imap_functions.ope_msg_part&msg_folder='+data+'&save_folder=INBOX'+cyrus_delimiter+special_folders['Trash'] , handler_open_msg_part);	
 }
 function hack_sent_queue(data,rowid_message) {
Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 5200)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 5211)
@@ -209,14 +209,14 @@
 		}
 
-		var trash_span = document.getElementById('lINBOX'+cyrus_delimiter+trashfolder  + 'tree_folders'); 
- 	    var draft_span = document.getElementById('lINBOX'+cyrus_delimiter+draftsfolder + 'tree_folders'); 
- 	    var sent_span  = document.getElementById('lINBOX'+cyrus_delimiter+sentfolder   + 'tree_folders'); 
- 	    var spam_span  = document.getElementById('lINBOX'+cyrus_delimiter+spamfolder   + 'tree_folders');
+		var trash_span = document.getElementById('lINBOX'+cyrus_delimiter+special_folders['Trash']  + 'tree_folders'); 
+                var draft_span = document.getElementById('lINBOX'+cyrus_delimiter+special_folders['Drafts'] + 'tree_folders'); 
+                var sent_span  = document.getElementById('lINBOX'+cyrus_delimiter+special_folders['Sent'] + 'tree_folders'); 
+                var spam_span  = document.getElementById('lINBOX'+cyrus_delimiter+special_folders['Spam'] + 'tree_folders');
 		//local folders
 		var sent_local_conf = this.preferences.save_in_folder.replace("INBOX"+cyrus_delimiter,"local_");
 		var sent_local_conf_span=document.getElementById('l'+sent_local_conf+'tree_folders');
-		var trash_local_span=document.getElementById('llocal_'+trashfolder+'tree_folders');
-		var draft_local_span=document.getElementById('llocal_'+draftsfolder+'tree_folders');
-		var sent_span_default=document.getElementById('llocal_'+sentfolder+'tree_folders');
+		var trash_local_span=document.getElementById('llocal_'+special_folders['Trash']+'tree_folders');
+		var draft_local_span=document.getElementById('llocal_'+special_folders['Drafts']+'tree_folders');
+		var sent_span_default=document.getElementById('llocal_'+special_folders['Sent']+'tree_folders');
 
 
@@ -247,5 +247,5 @@
 
 		draw_paging(Element('tot_m').innerHTML);
-		if(document.getElementById("nINBOX"+cyrus_delimiter+trashfolder+"tree_folders"))
+		if(document.getElementById("nINBOX"+cyrus_delimiter+special_folders['Trash']+"tree_folders"))
 		{
 			var trash = document.createElement("SPAN");
@@ -258,7 +258,7 @@
 			trash.onmouseover = function() {trash.style.color="red";};
 			trash.onmouseout= function() {trash.style.color="#666666";};
-			document.getElementById("nINBOX"+cyrus_delimiter+trashfolder+"tree_folders").appendChild(trash);
-		}
-		if(document.getElementById("nINBOX"+cyrus_delimiter+spamfolder+"tree_folders"))
+			document.getElementById("nINBOX"+cyrus_delimiter+special_folders['Trash']+"tree_folders").appendChild(trash);
+		}
+		if(document.getElementById("nINBOX"+cyrus_delimiter+special_folders['Spam']+"tree_folders"))
 		{
 						var spam = document.createElement("SPAN");
@@ -272,5 +272,5 @@
 						spam.onmouseover = function() {spam.style.color="red";};
 						spam.onmouseout= function() {spam.style.color="#666666";};
-						document.getElementById("nINBOX"+cyrus_delimiter+spamfolder+"tree_folders").appendChild(spam);
+						document.getElementById("nINBOX"+cyrus_delimiter+special_folders['Spam']+"tree_folders").appendChild(spam);
 			   }
 
@@ -1363,5 +1363,5 @@
 
 		test = true;
-		if(msg_folder.indexOf(sentfolder) !=-1 ||msg_folder.indexOf(preferences.save_in_folder) !=-1 || msg_folder.replace("local_","INBOX"+cyrus_delimiter).indexOf(preferences.save_in_folder) !=-1)
+		if(msg_folder.indexOf(special_folders['Sent']) !=-1 ||msg_folder.indexOf(preferences.save_in_folder) !=-1 || msg_folder.replace("local_","INBOX"+cyrus_delimiter).indexOf(preferences.save_in_folder) !=-1)
 		    test = false;
 
