Index: branches/2.4/expressoMail1_2/js/main.js
===================================================================
--- branches/2.4/expressoMail1_2/js/main.js	(revision 7288)
+++ branches/2.4/expressoMail1_2/js/main.js	(revision 7292)
@@ -2864,92 +2864,10 @@
 	save_link.button({disabled: true});
 
-	ID_tmp = ID;
-
-	var handler_send_message = function(data){
-		send_message_return(data, this.ID_tmp); // this is a hack to escape quotation form connector bug
-	};
-
-        var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + ID );
-	mail_as_plain = ( mail_as_plain ) ? mail_as_plain.checked : false;
-
-       var content_body  = RichTextEditor.getData('body_'+ID);        
-	var textArea = document.createElement("TEXTAREA");
-	textArea.style.display='none';
-	textArea.name = "body";
-	textArea.value = content_body;
-   
-	var input_folder = document.createElement("INPUT");
-	input_folder.style.display='none';
-	input_folder.name = "folder";
-	input_folder.value = folder;      
-	
-	var input_type = document.createElement("INPUT"); 
-	input_type.style.display='none'; 
-	input_type.name = "type"; 
-	input_type.value = RichTextEditor.plain[ID] ? 'plain' : 'html'; 
-	
-        var uids = document.createElement("INPUT");
-	uids.style.display='none';
-	uids.name = "uids_save";
-	uids.value = uidsSave[ID].toString();
-        
-        var save_folder = document.createElement("INPUT");
-	save_folder.style.display='none';
-	save_folder.name = "save_folder";
-	save_folder.value = (openTab.imapBox[ID] && openTab.type[ID] < 6) ? openTab.imapBox[ID]: "INBOX" + cyrus_delimiter + draftsfolder;
-        
-        var msg_attachments = document.createElement("INPUT");
-	msg_attachments.style.display='none';
-	msg_attachments.name = "attachments";
-	msg_attachments.value = listAttachment(ID);
-
-	if (is_ie){
-		var i = 0;
-		while (document.forms(i).name != "form_message_"+ID){i++}
-		form = document.forms(i);
-	}
-	else
-		form = document.forms["form_message_"+ID];
-
-		// Evita que e-mails assinados sejam enviados quando o usuÃ¡rio tenta enviar um e-mail
-		// nÃ£o assinado (desmarcou a opÃ§Ã£o) apÃ³s tentar enviar um e-mail assinado que nÃ£o passou
-		// no teste de validaÃ§Ã£o.
-		var checkSign = document.getElementById('return_digital_'+ID);
-		if (checkSign && !checkSign.checked){
-			var smime = Element('smime');
-			if (smime)
-			{
-				var parent = smime.parentNode;
-				parent.removeChild(smime);
-			}
-		 }
-
-	form.appendChild(textArea);
-	form.appendChild(input_folder);
-    form.appendChild(input_type);
-	// ImplementaÃ§Ã£o do In_Reply_To e References
-	var msgId = document.createElement("INPUT");
-	msgId.style.display = 'none';
-	msgId.name = 'messageNum';
-	msgId.value = currentTab;
-
-	form.appendChild(msgId);
-    form.appendChild(save_folder);
-    form.appendChild(uids);
-	form.appendChild(msg_attachments);
-
-        var mail_type = document.createElement('input');
-	mail_type.setAttribute('type', 'hidden');
-	mail_type.name = 'type';
-	mail_type.value = ( mail_as_plain ) ? 'plain' : 'html';
-        form.parentNode.appendChild(mail_type);
-
-	var _subject = trim(content.find(".subject").val());
-	if((_subject.length == 0) && !confirm(get_lang("Send this message without a subject?"))) {
-		save_link.click(onClick);
-		content.find(".subject").focus();
-		return;
-	}
-	//stringEmail = content.find('[name="input_to"]').val();
+	var _subject = trim(content.find(".subject").val()); 
+    if((_subject.length == 0) && !confirm(get_lang("Send this message without a subject?"))) { 
+        save_link.click(onClick); 
+        content.find(".subject").focus(); 
+        return; 
+    }
 
     var stringReply = "";
@@ -2960,86 +2878,85 @@
         stringReply += $(value).find("input").val() + ",";
     });
-    content.find('[name="input_reply_to"]').val(stringReply);
-
-	var stringEmail = "";
-	var stringToEmail = "";
-	draw_email_box(content.find(".to-tr").find("textarea:first").val() || content.find(".to-tr").find("input:visible").val(), content.find(".to-tr").find("textarea:first"));
-	content.find(".to-tr").find("textarea:first").val("");
-	content.find(".to-tr").find("input:visible").val("");
-	var array = content.find(".to-tr").find(".box");
-	$.each(array, function(index, value){
-		//stringEmail += $(value).find("input").val() + ",";
-		stringToEmail += $(value).find("input").val() + ",";
-	});
-	content.find('[name="input_to"]').val(stringToEmail);
-	stringEmail = stringToEmail;
-	var stringCCoEmail = "";
-	if ( content.find('[name="input_cco"]').length){
-		if(content.find(".cco-tr").css("display") != "none"){
-			draw_email_box(content.find(".cco-tr").find("textarea:first").val() || content.find(".cco-tr").find("input:visible").val(), content.find(".cco-tr").find("textarea:first"));
-			content.find(".cco-tr").find("textarea:first").val("");
-			content.find(".cco-tr").find("input:visible").val("");
-			var array = content.find(".cco-tr").find(".box");
-			$.each(array, function(index, value){
-				//stringEmail += $(value).find("input").val() + ",";
-				stringCCoEmail += $(value).find("input").val() + ",";
-			});
-			content.find('[name="input_cco"]').val(stringCCoEmail);
-		}
-	}
-	stringEmail += stringCCoEmail;
-	var stringCCEmail = "";		
-	if(content.find(".cc-tr").css("display") != "none")
-	{
-		draw_email_box(content.find(".cc-tr").find("textarea:first").val() || content.find(".cc-tr").find("input:visible").val(), content.find(".cc-tr").find("textarea:first"));
-		content.find(".cc-tr").find("textarea:first").val("");
-		content.find(".cc-tr").find("input:visible").val("");
-		var array = content.find(".cc-tr").find(".box");
-		$.each(array, function(index, value){
-			//stringEmail += $(value).find("input").val() + ",";
-			stringCCEmail += $(value).find("input").val() + ",";
+    var stringToEmail = ""; 
+    draw_email_box(content.find(".to-tr").find("textarea:first").val() || content.find(".to-tr").find("input:visible").val(), content.find(".to-tr").find("textarea:first")); 
+    content.find(".to-tr").find("textarea:first").val(""); 
+    content.find(".to-tr").find("input:visible").val(""); 
+    var array = content.find(".to-tr").find(".box"); 
+    $.each(array, function(index, value){ 
+        stringToEmail += $(value).find("input").val() + ","; 
+    }); 
+    var stringEmail = ""; 
+    stringEmail = stringToEmail; 
+    var stringCCoEmail = ""; 
+    if ( content.find('[name="input_cco"]').length){ 
+        if(content.find(".cco-tr").css("display") != "none"){ 
+            draw_email_box(content.find(".cco-tr").find("textarea:first").val() || content.find(".cco-tr").find("input:visible").val(), content.find(".cco-tr").find("textarea:first")); 
+            content.find(".cco-tr").find("textarea:first").val(""); 
+            content.find(".cco-tr").find("input:visible").val(""); 
+            var array = content.find(".cco-tr").find(".box"); 
+            $.each(array, function(index, value){ 
+                stringCCoEmail += $(value).find("input").val() + ","; 
+            }); 
+        } 
+    } 
+    stringEmail += stringCCoEmail; 
+    var stringCCEmail = ""; 
+    if(content.find(".cc-tr").css("display") != "none") 
+    { 
+        draw_email_box(content.find(".cc-tr").find("textarea:first").val() || content.find(".cc-tr").find("input:visible").val(), content.find(".cc-tr").find("textarea:first")); 
+        content.find(".cc-tr").find("textarea:first").val(""); 
+        content.find(".cc-tr").find("input:visible").val(""); 
+        var array = content.find(".cc-tr").find(".box"); 
+        $.each(array, function(index, value){ 
+            stringCCEmail += $(value).find("input").val() + ","; 
+        }); 
+    } 
+    stringEmail +=      stringCCEmail; 
+ 
+    var mailData = new Object(); 
+    mailData.body = Base64.encode(RichTextEditor.getData('body_'+ID)); 
+    mailData.folder = folder; 
+    mailData.type = RichTextEditor.plain[ID] ? 'plain' : 'html'; 
+    mailData.uids_save = uidsSave[ID].toString(); 
+    mailData.save_folder = (openTab.imapBox[ID] && openTab.type[ID] < 6) ? openTab.imapBox[ID]: "INBOX" + cyrus_delimiter + draftsfolder; 
+    mailData.attachments = listAttachment(ID); 
+    mailData.messageNum = currentTab; 
+    mailData.input_subject = trim(content.find(".subject").val()); 
+    mailData.input_reply_to = stringReply; 
+    mailData.input_to = stringToEmail; 
+    mailData.input_cco = stringCCoEmail; 
+    mailData.input_cc = stringCCEmail; 
+    mailData.input_cc = stringCCEmail; 
+    mailData.abaID = $(content).find('[name="abaID"]').val(); 
+    mailData.input_important_message = $(content).find('input:checkbox:checked[name="input_important_message"]').val(); 
+    mailData.input_return_receipt = $(content).find('input:checkbox:checked[name="input_return_receipt"]').val(); 
+    mailData.msg_forward_from = $(content).find('[name="msg_forward_from"]').val(); 
+    mailData.msg_reply_from = $(content).find('[name="msg_reply_from"]').val(); 
+ 
+ 
+        if(stringEmail != ""){ 
+                $.ajax({ 
+                        url: "controller.php?action=$this.imap_functions.send_mail", 
+            data:  mailData, 
+            type: 'POST', 
+                success: function(data){ 
+                send_message_return(connector.unserialize(data),ID); 
+                        }, 
+                        error: function(){ 
+                                write_msg("Erro ao tentar enviar a mensagem. Nova tentativa em alguns segundos..."); 
+                                var interval = setInterval(function(){ 
+                                                send_valided_message(ID,folder,folder_name); 
+                                                clearInterval(interval); 
+                                },15000); 
+                                return; 
+                        }
 		});
-		content.find('[name="input_cc"]').val(stringCCEmail);
-	}
-	stringEmail += 	stringCCEmail;
-	if (expresso_offline) {
-		
-		var invalidEmail = searchEmail(stringEmail);
-		if(content.find('[name="input_to"]').val()=="" && content.find('[name="input_cco"]').val()=="" && content.find('[name="input_cc"]').val()=="") {
-			write_msg(get_lang("message without receiver"));
-			return;
-		}else if(invalidEmail[0] == true){
-			write_msg("Os endereÃ§os de destinatÃ¡rio a seguir estÃ£o incorretos: "+invalidEmail[1]);
-			return;
-		}
-
-		sucess = expresso_local_messages.send_to_queue(form);
-		var data_return = new Array();
-		data_return.success = sucess;
-		handler_send_message(data_return,ID);
-	}
-	else{
-		if(stringEmail != ""){
-			$.ajax({			
-				url: "controller.php?",
-				success: function(data){
-					cExecuteForm("$this.imap_functions.send_mail", form, handler_send_message, ID);
-				},
-				error: function(){
-					write_msg("Erro ao tentar enviar a mensagem. Nova tentativa em alguns segundos...");
-					var interval = setInterval(function(){
-							send_valided_message(ID,folder,folder_name);
-							clearInterval(interval);
-					},15000);
-					return;
-				}
-			});			
-		}else{
-			write_msg(get_lang("message without receiver"));
-			return;
-		}
-	}
-
-}
+		}else{ 
+                write_msg(get_lang("message without receiver")); 
+                return; 
+        } 
+ 
+ 
+} 
 
 
