Index: sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/messages_controller.js
===================================================================
--- sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/messages_controller.js	(revision 4910)
+++ sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/messages_controller.js	(revision 4955)
@@ -246,43 +246,61 @@
 	}
 
-	messages_proxy.prototype.proxy_move_messages = function (folder, msgs_number, border_ID, new_folder, new_folder_name) {
-		if (! folder || folder == 'null')
-			folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder());
-		if ((this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { //Move entre pastas nï¿œo locais...
-			if (folder == new_folder){
-				write_msg(get_lang('The origin folder and the destination folder are the same.'));
-				return;
-			}
-			if(msgs_number=='selected')
-				msgs_number = get_selected_messages();
-			if (new_folder == 'local_root')
-				alert(get_lang("Select a folder!"));
-			if (parseInt(msgs_number) > 0 || msgs_number.length > 0) {
-				expresso_local_messages.move_messages(new_folder.substr(6), msgs_number);
-				this.aux_interface_remove_mails(msgs_number, new_folder_name, border_ID);
-				draw_tree_local_folders();
-			}
-			else 
-				write_msg(get_lang('No selected message.'));
-		}
-		else
-			if ((!this.is_local_folder(folder)) && (!this.is_local_folder(new_folder))) { //Move entre pastas locais...
-				move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name);
-			}
-			else if ((!this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) {
-				if(msgs_number=='selected')
-					archive_msgs(folder,new_folder);
-				else
-					archive_msgs(folder,new_folder,msgs_number);
-				draw_tree_local_folders();
-			}
-			else {
-                //Por Bruno Costa (bruno.vieira-costa@serpro.gov.br) permite o desarquivamento de menssagens chamando a funï¿œï¿œo unarchive_msgs quando uma msg ï¿œ movida de uma pasta local para uma pasta remota.
-
-				expresso_local_messages.unarchive_msgs(folder,new_folder,msgs_number);
-                //write_msg(get_lang("you can't move mails from local to server folders"));
-			}
-		
-		
+	messages_proxy.prototype.proxy_move_messages = function (folder, msgs_number, border_ID, new_folder, new_folder_name) {                           
+            if (! folder || folder == 'null'){
+                folder = get_current_folder();
+                if (!this.is_local_folder(folder)){
+                    folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder());                    
+                }
+            }
+            if (folder == new_folder){
+                write_msg(get_lang('The origin folder and the destination folder are the same.'));
+                return;
+            }
+            
+            if (this.is_local_folder(folder)){
+                //Folder de onde sai a mensagem Ã© local (armazenamento local)
+                
+                if (new_folder == 'local_root'){
+                    alert(get_lang("Select a folder!"));
+                }
+                
+                if(msgs_number=='selected'){
+                    msgs_number = get_selected_messages();
+                }
+                
+                if (parseInt(msgs_number) > 0 || msgs_number.length > 0) {
+                    if (this.is_local_folder(new_folder)){
+                        //esta tirando de um folder local para outro folder local
+                        expresso_mail_archive.moveMessages(new_folder.substr(6), msgs_number);
+                    }
+                    else{
+                        //esta tirando de um folder local para um folder IMAP (desarquivamento)
+                        if(!new_folder){
+                            new_folder = 'INBOX';
+                        }
+                        if(currentTab.toString().indexOf("_r") != -1){
+                            msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));
+                        }                      
+                        expresso_mail_archive.unarchieve(folder, new_folder, msgs_number);
+                    }
+                }
+                else{
+                    write_msg(get_lang('No selected message.'));
+                }
+            }else{
+                if (this.is_local_folder(new_folder)){
+                    //esta tirando de um folder nÃ£o local para um folder local (arquivamento)
+                    if(msgs_number=='selected'){
+                        archive_msgs(folder, new_folder);
+                    }
+                    else{
+                        archive_msgs(folder, new_folder, msgs_number);
+                    }
+                }
+                else{
+                    //esta tirando de um folder nÃ£o local para outro folder nÃ£o local (move)
+                    move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name);
+                }
+            }
 	}
 	
