Index: /sandbox/2.5.0-expresso1/expressoMail1_2/js/messages_controller.js
===================================================================
--- /sandbox/2.5.0-expresso1/expressoMail1_2/js/messages_controller.js	(revision 7340)
+++ /sandbox/2.5.0-expresso1/expressoMail1_2/js/messages_controller.js	(revision 7373)
@@ -275,5 +275,7 @@
                 else{
                     //user has preference to "save" delete messasge on trash folder, so move it to there
-                    if (((preferences.save_deleted_msg == true)) && (folder != expresso_mail_archive.specialfolders.trash)){
+                    //Marcosw inicio - removido "messages_" da string folder para evitar inconsistência
+                    if (((preferences.save_deleted_msg == true)) && (folder.replace('messages_','') != expresso_mail_archive.specialfolders.trash)){
+                    //Marcosw fim  
                       expresso_mail_archive.createFolder("","Trash");
                       expresso_mail_archive.folder_destination = 'trash';
Index: /sandbox/2.5.0-expresso1/expressoMail1_2/js/MAExpressoPattern.js
===================================================================
--- /sandbox/2.5.0-expresso1/expressoMail1_2/js/MAExpressoPattern.js	(revision 7146)
+++ /sandbox/2.5.0-expresso1/expressoMail1_2/js/MAExpressoPattern.js	(revision 7373)
@@ -1312,9 +1312,12 @@
     if(taglist != null){
         var tagdata = "";
-        var flag_draft = false;
+        //var flag_draft = false;
         
         //first message to tag data
         if(expresso_mail_archive.taglist == ""){
-            //Draft folder, are "draft"
+
+            //Marcosw inicio - cÃ³digo comentado para evitar inconsistÃªncia de flags quando mensagens passam pela pasta rascunhos
+            /*
+            Draft folder, are "draft"
             if(expresso_mail_archive.folder_destination == 'drafts'){
                 flag_draft = true;
@@ -1368,6 +1371,8 @@
             }
             else
-                tagdata += '<remove value="draft"/>';
-        
+               tagdata += '<remove value="draft"/>';
+            */
+            //Marcosw fim
+
             //Trash folder, are "deleted""
             if(expresso_mail_archive.folder_destination == 'trash'){
@@ -1377,70 +1382,77 @@
                 tagdata += '<remove value="deleted"/>';
         
-            if(!flag_draft){
-                var action;
-                if (op == 0)
-                    action = 'add';
-                else
-                    action = 'remove';
-        
-                //object data -used at archieve op
-                if (typeof(taglist) == 'object'){
-                    for(var x in taglist[0]){
-                        if (x != 'importance'){
-                            if(( x != 'unseen') && ( x != 'answered')){
-                                if((taglist[0][x] != '') && (taglist[0][x] != ' ') && (taglist[0][x] != null) && (x != 'msgid'))
-                                    tagdata += '<'+action+' value="'+x+'"/>';
-                            }
-                            else{
-                                if( x == 'unseen'){
-                                    if (taglist[0][x] == ' ')
-                                        tagdata += '<'+action+' value="seen"/>';
-                                    else
-                                        if((taglist[0][x] != '') && (taglist[0][x] != null))
-                                            tagdata += '<'+action+' value="unseen"/>';                                
-                                }
-                                if( x == 'answered'){
-                                    if (taglist[0][x] == ' ')
-                                        tagdata += '<'+action+' value="unanswered"/>';
-                                    else
-                                        if((taglist[0][x] != '') && (taglist[0][x] != null))
-                                            tagdata += '<'+action+' value="answered"/>';                                                                    
-                                }                            
-                            }
+            //Marcosw inicio - cÃ³digo comentado para evitar inconsistÃªncia de flags quando mensagens passam pela pasta rascunhos
+            //if(!flag_draft){
+            //Marcosw fim
+
+            var action;
+            if (op == 0)
+                action = 'add';
+            else
+                action = 'remove';
+    
+            //object data -used at archieve op
+            if (typeof(taglist) == 'object'){
+                for(var x in taglist[0]){
+                    if (x != 'importance'){
+                        if(( x != 'unseen') && ( x != 'answered')){
+                            if((taglist[0][x] != '') && (taglist[0][x] != ' ') && (taglist[0][x] != null) && (x != 'msgid'))
+                                tagdata += '<'+action+' value="'+x+'"/>';
                         }
                         else{
-                            if((taglist[0][x] != '') && (taglist[0][x] != ' ')){
-                                switch (taglist[0][x].toLowerCase()){
-                                    case 'high':
-                                        tagdata += '<'+action+' value="importance_high"/>';
-                                        tagdata += '<'+action+' value="flagged"/>';
-                                        break;
-                                    default:
-                                        tagdata += '<'+action+' value="importance_normal"/>';
-                                        tagdata += '<'+action+' value="unflagged"/>';
-                                        break;                                        
-                                }
-                               
-                           }
-                           //if no importance data received, defaults is "Normal"
-                           else{
-                               tagdata += '<add value="importance_normal"/>';
-                               tagdata += '<add value="unflagged"/>';
-                           }
+                            if( x == 'unseen'){
+                                if (taglist[0][x] == ' ')
+                                    tagdata += '<'+action+' value="seen"/>';
+                                else
+                                    if((taglist[0][x] != '') && (taglist[0][x] != null))
+                                        tagdata += '<'+action+' value="unseen"/>';                                
+                            }
+                            if( x == 'answered'){
+                                if (taglist[0][x] == ' ')
+                                    tagdata += '<'+action+' value="unanswered"/>';
+                                else
+                                    if((taglist[0][x] != '') && (taglist[0][x] != null))
+                                        tagdata += '<'+action+' value="answered"/>';                                                                    
+                            }                            
                         }
                     }
-                }
-                //string data - used to tag a message when reading it (unseen and important, by now)
-                else{
-                    if(taglist.indexOf(",") != -1){
-                        var vet_tags = taglist.split(",");
-                        for(var k=0; k<vet_tags.length; k++){
-                            tagdata += '<'+action+' value="'+vet_tags[k]+'"/>';
-                        }
-                    }
-                    else
-                        tagdata += '<'+action+' value="'+taglist+'"/>';
-                }
-            }
+                    else{
+                        if((taglist[0][x] != '') && (taglist[0][x] != ' ')){
+                            switch (taglist[0][x].toLowerCase()){
+                                case 'high':
+                                    tagdata += '<'+action+' value="importance_high"/>';
+                                    tagdata += '<'+action+' value="flagged"/>';
+                                    break;
+                                default:
+                                    tagdata += '<'+action+' value="importance_normal"/>';
+                                    tagdata += '<'+action+' value="unflagged"/>';
+                                    break;                                        
+                            }
+                           
+                       }
+                       //if no importance data received, defaults is "Normal"
+                       else{
+                           tagdata += '<add value="importance_normal"/>';
+                           tagdata += '<add value="unflagged"/>';
+                       }
+                    }
+                }
+            }
+            //string data - used to tag a message when reading it (unseen and important, by now)
+            else{
+                if(taglist.indexOf(",") != -1){
+                    var vet_tags = taglist.split(",");
+                    for(var k=0; k<vet_tags.length; k++){
+                        tagdata += '<'+action+' value="'+vet_tags[k]+'"/>';
+                    }
+                }
+                else
+                    tagdata += '<'+action+' value="'+taglist+'"/>';
+            }
+
+            //Marcosw inicio - cÃ³digo comentado para evitar inconsistÃªncia de flags quando mensagens passam pela pasta rascunhos
+            //}
+            //Marcosw fim
+
             if(tagdata != ""){    
                 var tobject = '<tag>'
@@ -1457,5 +1469,7 @@
             var endpoint = expresso_mail_archive.taglist.lastIndexOf("<");
            
-            //Draft folder, are "draft"
+            //Marcosw inicio - cÃ³digo comentado para evitar inconsistÃªncia de flags quando mensagens passam pela pasta rascunhos
+            /*
+            Draft folder, are "draft"
             if(expresso_mail_archive.folder_destination == 'drafts'){
                 flag_draft = true;
@@ -1514,5 +1528,7 @@
             else
                 tagdata += '<remove value="draft"/>';
-        
+            */
+            //Marcosw fim
+
             //Trash folder, are "deleted""
             if(expresso_mail_archive.folder_destination == 'trash'){
@@ -1522,74 +1538,77 @@
                 tagdata += '<remove value="deleted"/>';
             
-            if(!flag_draft){
-                var action;
-                if (op == 0)
-                    action = 'add';
+            //Marcosw inicio - cÃ³digo comentado para evitar inconsistÃªncia de flags quando mensagens passam pela pasta rascunhos
+            //if(!flag_draft){
+            //Marcosw fim
+
+            var action;
+            if (op == 0)
+                action = 'add';
+            else
+                action = 'remove';
+    
+            //object data -used at archieve op
+            if (typeof(taglist) == 'object'){
+                for(var x in taglist[0]){
+                    if (x != 'importance'){
+                        if(( x != 'unseen') && ( x != 'answered')){
+                            if((taglist[0][x] != '') && (taglist[0][x] != ' ') && (taglist[0][x] != null) && (x != 'msgid'))
+                                tagdata += '<'+action+' value="'+x+'"/>';
+                        }
+
+                        else{
+                            if( x == 'unseen'){
+                                if (taglist[0][x] == ' ')
+                                    tagdata += '<'+action+' value="seen"/>';
+                                else
+                                    if((taglist[0][x] != '') && (taglist[0][x] != null))
+                                        tagdata += '<'+action+' value="unseen"/>';                                
+                            }
+                            if( x == 'answered'){
+                                if (taglist[0][x] == ' ')
+                                    tagdata += '<'+action+' value="unanswered"/>';
+                                else
+                                    if((taglist[0][x] != '') && (taglist[0][x] != null))
+                                        tagdata += '<'+action+' value="answered"/>';                                                                    
+                            }                             
+                        }
+                    }
+                    else{
+                        if((taglist[0][x] != '') && (taglist[0][x] != ' ')){
+                            switch (taglist[0][x].toLowerCase()){
+                                case 'important':
+                                    tagdata += '<'+action+' value="importance_high"/>';
+                                    tagdata += '<'+action+' value="flagged"/>';
+                                    break;
+                                default:
+                                    tagdata += '<'+action+' value="importance_normal"/>';
+                                    tagdata += '<'+action+' value="unflagged"/>';
+                                    break;                                        
+                            }
+                            
+                        }
+                       //if no importance data received, defaults is "Normal"
+                       else{
+                           tagdata += '<add value="importance_normal"/>'; 
+                           tagdata += '<add value="unflagged"/>';
+                       }
+                    }
+                }
+            }
+            //string data - used to tag a message
+            else{
+                if(taglist.indexOf(",") != -1){
+                    var vet_tags = taglist.split(",");
+                    for(var k=0; k<vet_tags.length; k++){
+                        tagdata += '<'+action+' value="'+vet_tags[k]+'"/>';
+                    }
+                }
                 else
-                    action = 'remove';
-        
-                //object data -used at archieve op
-                if (typeof(taglist) == 'object'){
-                    for(var x in taglist[0]){
-                        if (x != 'importance'){
-                            if(( x != 'unseen') && ( x != 'answered')){
-                                if((taglist[0][x] != '') && (taglist[0][x] != ' ') && (taglist[0][x] != null) && (x != 'msgid'))
-                                    tagdata += '<'+action+' value="'+x+'"/>';
-                            }
-
-                            else{
-                                if( x == 'unseen'){
-                                    if (taglist[0][x] == ' ')
-                                        tagdata += '<'+action+' value="seen"/>';
-                                    else
-                                        if((taglist[0][x] != '') && (taglist[0][x] != null))
-                                            tagdata += '<'+action+' value="unseen"/>';                                
-                                }
-                                if( x == 'answered'){
-                                    if (taglist[0][x] == ' ')
-                                        tagdata += '<'+action+' value="unanswered"/>';
-                                    else
-                                        if((taglist[0][x] != '') && (taglist[0][x] != null))
-                                            tagdata += '<'+action+' value="answered"/>';                                                                    
-                                }                             
-                            }
-
-
-                          
-                        }
-                        else{
-                            if((taglist[0][x] != '') && (taglist[0][x] != ' ')){
-                                switch (taglist[0][x].toLowerCase()){
-                                    case 'important':
-                                        tagdata += '<'+action+' value="importance_high"/>';
-                                        tagdata += '<'+action+' value="flagged"/>';
-                                        break;
-                                    default:
-                                        tagdata += '<'+action+' value="importance_normal"/>';
-                                        tagdata += '<'+action+' value="unflagged"/>';
-                                        break;                                        
-                                }
-                                
-                            }
-                           //if no importance data received, defaults is "Normal"
-                           else{
-                               tagdata += '<add value="importance_normal"/>'; 
-                               tagdata += '<add value="unflagged"/>';
-                           }
-                        }
-                    }
-                }
-                //string data - used to tag a message
-                else{
-                    if(taglist.indexOf(",") != -1){
-                        var vet_tags = taglist.split(",");
-                        for(var k=0; k<vet_tags.length; k++){
-                            tagdata += '<'+action+' value="'+vet_tags[k]+'"/>';
-                        }
-                    }
-                    else
-                        tagdata += '<'+action+' value="'+taglist+'"/>';
-                }
-            }
+                    tagdata += '<'+action+' value="'+taglist+'"/>';
+            }
+
+            //Marcosw inicio - cÃ³digo comentado para evitar inconsistÃªncia de flags quando mensagens passam pela pasta rascunhos
+            //}
+            //Marcosw fim
             
             if(tagdata != ""){        
