Index: trunk/expressoMail1_2/js/abas.js
===================================================================
--- trunk/expressoMail1_2/js/abas.js	(revision 5439)
+++ trunk/expressoMail1_2/js/abas.js	(revision 5459)
@@ -285,5 +285,5 @@
 	div.style.overflow = "hidden";
 
-	Element("exmail_main_body").insertBefore(div,Element("footer_menu"));
+	Element("exmail_main_body").insertBefore(div,Element("footer_menu"));       
 	alternate_border(ID);
 	return ID;
@@ -436,11 +436,12 @@
 	openTab.imapUid[ID] = 0;
 
-	if (preferences.auto_save_draft == 1)
-	{
-		if (openTab.autosave_timer[ID])
-			clearTimeout(openTab.autosave_timer[ID]);
-		openTab.autosave_timer[ID] = false;
-	}
-
+        // Limpa o autosave
+            if (preferences.auto_save_draft == 1 && autoSaveControl.timer[ID] !== null )
+            {
+                autoSaveControl.status[ID] = null;
+                clearInterval(autoSaveControl.timer[ID]);
+            }
+        ////////////////////////////////
+        
 	hold_session = false;
 	if (exist_className(Element('border_id_'+ID),'menu-sel'))
Index: trunk/expressoMail1_2/js/common_functions.js
===================================================================
--- trunk/expressoMail1_2/js/common_functions.js	(revision 5458)
+++ trunk/expressoMail1_2/js/common_functions.js	(revision 5459)
@@ -367,11 +367,5 @@
  	inputFile.onchange  = function () {
             validateFileExtension(this.value, this.id.replace('input','div'), this.getAttribute('id_border'));
-            openTab.autosave_timer[id_border] = setTimeout("save_msg("+id_border+")", autosave_time);
  	};
-
- 	inputFile.onfocus = function () {
-            if (openTab.autosave_timer[id_border])
-                clearTimeout(openTab.autosave_timer[id_border]);
-            };
 
  	divFile.appendChild(inputFile);
Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 5453)
+++ trunk/expressoMail1_2/js/main.js	(revision 5459)
@@ -3,5 +3,5 @@
 // tempo do auto save (em milisegundos)
 // 20000 = 20 segundos
-var autosave_time = 20000;
+var autosave_time = 40000;
 
 var results_search_messages = ""; 
@@ -2039,15 +2039,6 @@
 function send_message(ID, folder, folder_name){
 
-	//limpa autosave_timer[ID]; havia conflito quando uma mensagem ia ser enviada e nesse exato momento o autosave
-		//entrava em execucao (a aba de edicao da mensagem continuava aberta e a mensagem exibida era a de que a mensagem foi
-		//salva na pasta Rascunhos e nao que tinha sido enviada, como deveria);
 	if (preferences.auto_save_draft == 1)
-	{
-		if (openTab.autosave_timer[ID])
-		{
-			clearTimeout(openTab.autosave_timer[ID]);
-		}
-	}
-
+            autoSaveControl.status[ID] = true;
 
 	var save_link = Element("save_message_options_"+ID);
@@ -2393,5 +2384,17 @@
 }
 
+function autoSave( ID )
+{
+    if(autoSaveControl.status[ID] === false)
+        save_msg(ID);         
+}
+
 function save_msg(border_id,withImage, out){
+       
+       //seta o status do auto_save = true
+        if (preferences.auto_save_draft == 1)
+            autoSaveControl.status[border_id] = true;
+       ///////////////////////////////////////////
+      
 	if (typeof(withImage) == 'undefined')
 		withImage = false;
@@ -2451,5 +2454,5 @@
 	mail_as_plain = ( mail_as_plain ) ? mail_as_plain.checked : false;
 
-        var content_body  = RichTextEditor.getData("body_"+border_id);
+       var content_body  = RichTextEditor.getData("body_"+border_id);
        //Remove imagens do corpo que estao com o checkbox desmarcados
        var files_checkbox =  $("#divFiles_"+border_id+" input:checkbox");
Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 5456)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 5459)
@@ -6,7 +6,12 @@
 	'imapBox' : [], // Stores the folder name
 	'toPreserve' : [], // Check if the message should be removed from draft after send
-	'autosave_timer' : [], // The timeout timer for autosave function
 	'condition' : [] // Will store the search condition if the tab is the result of a search
 };
+
+var autoSaveControl = {
+    'timer' : [], // The timeout timer for autosave function
+    'status' : [] // The status autosave 
+};
+
 var tabTypes = {
 	'new':4,
@@ -17,5 +22,5 @@
 	'reply_to_all_without_history':10,
 	'edit':5
-	}
+	};
 
 var currentTab,numBox = 0; // Open Tab and num of mailboxes opened at context
Index: trunk/expressoMail1_2/js/rich_text_editor.js
===================================================================
--- trunk/expressoMail1_2/js/rich_text_editor.js	(revision 5417)
+++ trunk/expressoMail1_2/js/rich_text_editor.js	(revision 5459)
@@ -146,9 +146,4 @@
 
 cRichTextEditor.prototype.createImage = function(){
-	if (preferences.auto_save_draft == 1)
-        {
-			autosave_time = 200000;
-			clearTimeout(openTab.autosave_timer[currentTab]);
-	}
                 
 	var form = document.getElementById("attachment_window");
@@ -264,4 +259,6 @@
 
 cRichTextEditor.prototype.execPosInstance = function(inst) {
+     if(RichTextEditor.editorReady === false)
+     {
 	var editor =  CKEDITOR.instances[inst]; 
 	var id = inst.replace('body_','');
@@ -274,13 +271,4 @@
 	});
         
-//Adicionando atalhos de preferencias  
-//TODO: Não esta pegando o numero (keycode)
-//        if (preferences.use_shortcuts == '1')
-//        {
-//            CKEDITOR.instances[inst].document.on('keyup', function(event){
-//                    if(event.keyCode == 27){                         
-//                            delete_border(id,'false');}  //Tecla delete fechar aba          
-//            });
-//        }  
        
         // IM Module Enabled
@@ -291,38 +279,20 @@
 		});            	
 	}
-        
+
 	if (preferences.auto_save_draft == 1)
 	{
-		openTab.autosave_timer[id] = false;
-		var save_link = document.getElementById("save_message_options"+id);
-		CKEDITOR.instances[inst].document.on('keydown', function(event){
-		   if (openTab.autosave_timer[id])
-				clearTimeout(openTab.autosave_timer[id]);
-		   openTab.autosave_timer[id] = setTimeout("save_msg("+id+")", autosave_time);
-					
-		});  
-	}
-	
-	/*var rich_button = document.createElement("a");
-	//rich_button.className = "button small";
-	rich_button.name = "textplain_rt_checkbox_"+id;
-	rich_button.innerHTML = get_lang('Simple text mode')+" >>";
-	rich_button.href = "#";
-	rich_button.onclick = function (){
-		var check = $("#"+$(this).attr("name")).attr("checked");
-		$("#"+$(this).attr("name")).attr("checked", (!check ? true : false));
-		$("#"+$(this).attr("name")).trigger('click');
-		//RichTextEditor.setPlain($("#"+$(this).attr("name")).attr("checked"), id);
-	};
-	if($("#cke_top_body_"+id).find(".cke_toolbar:last"))
-	$("#cke_top_body_"+id).find(".cke_toolbar:last").append("<span class='button small'></span>");
-	$("#cke_top_body_"+id).find("span:last").append(rich_button);
-	$("#cke_top_body_"+id).attr("colSpan", "2");
-	$("#cke_contents_body_"+id).attr("colSpan", "2");
-	$("#cke_bottom_body_"+id).attr("colSpan", "2");*/
+            autoSaveControl.status[id] = true;
+            autoSaveControl.timer[id] = window.setInterval( "autoSave("+id+")" ,autosave_time);  
+
+            CKEDITOR.instances[inst].document.on('keydown', function(event){   
+                autoSaveControl.status[id] = false;
+            })
+        }
+        
 	$(".cke_editor").css("white-space", "normal");
-	
-	RichTextEditor.editorReady = true;
-}
+        RichTextEditor.editorReady = true;
+     }	
+}
+
 cRichTextEditor.prototype.setPlain = function (active,id){
       RichTextEditor.plain[id] = active;
