Index: /trunk/expressoMail1_2/js/main.js
===================================================================
--- /trunk/expressoMail1_2/js/main.js	(revision 7567)
+++ /trunk/expressoMail1_2/js/main.js	(revision 7568)
@@ -2298,7 +2298,19 @@
 			// Insert the signature automaticaly at message body if use_signature preference is set
 			if (preferences.use_signature == "1"){  
-				RichTextEditor.setInitData(new_border_ID, '<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>' + block_quoted_body,true); 				
+				var body_text = '<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>' + block_quoted_body;
+				if (preferences.plain_text_editor == "1"){
+					body_text = "\n\n"+remove_tags(body_text);
+					$("#body_"+new_border_ID).val(body_text, true);
+				} else {
+					RichTextEditor.setInitData(new_border_ID, body_text, true); 				
+				}
 			}else{
-				RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+ block_quoted_body,true);
+				body_text = '<div><br type="_moz"></div>'+ block_quoted_body;
+				if (preferences.plain_text_editor == "1"){
+					body_text = "\n\n"+remove_tags(body_text);
+					$("#body_"+new_border_ID).val(body_text, true);
+				} else {
+					RichTextEditor.setInitData(new_border_ID, body_text, true);
+				}
 			}
 			break;
@@ -2401,7 +2413,21 @@
 			
 			if (preferences.use_signature == "1"){  
-				RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div><div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ block_quoted_body,true); 
+				var body_text = '<div><br type="_moz"></div><div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ block_quoted_body;
+				if (preferences.plain_text_editor == "1"){
+					body_text = "\n\n"+remove_tags(body_text);
+					$("#body_"+new_border_ID).val(body_text, true);
+				}
+				else {
+					RichTextEditor.setInitData(new_border_ID, body_text, true); 
+				}
 			}else{                
-				RichTextEditor.setInitData(new_border_ID,block_quoted_body,true); 
+				var body_text = '<div><br type="_moz"></div><div><br type="_moz"></div>' + block_quoted_body;
+				if (preferences.plain_text_editor == "1"){
+					body_text = "\n\n"+remove_tags(body_text);
+					$("#body_"+new_border_ID).val(body_text, true);
+				}
+				else {
+					RichTextEditor.setInitData(new_border_ID, body_text, true); 
+				}
 			}
 				
@@ -2418,16 +2444,27 @@
 			if (Element("attachments_" + border_ID))
                             addOriginalAttachments(new_border_ID,border_ID);
-			
+
 			// Insert the signature automaticaly at message body if use_signature preference is set
 			if (preferences.use_signature == "1"){ 
-				$("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc));
- 		        RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)); 
-				content.find(".to").focus();
+				var body_text = '<div><br type="_moz"></div><div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc);
+				if (preferences.plain_text_editor == "1"){
+					body_text = "\n\n"+remove_tags(body_text);
+					$("#body_"+new_border_ID).val(body_text);
+				}
+				else {
+ 		        	RichTextEditor.setInitData(new_border_ID, body_text, true); 
+ 		        }
 			}
 			else{   
-				RichTextEditor.setInitData(new_border_ID,make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc));   
-				$("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>'+make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc));
-				content.find(".to").focus();
-			}
+				var body_text = '<div><br type="_moz"></div><div><br type="_moz"></div>'+make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc);
+				if (preferences.plain_text_editor == "1"){
+					body_text = "\n\n"+remove_tags(body_text);
+					$("#body_"+new_border_ID).val(body_text);
+				}
+				else {
+					RichTextEditor.setInitData(new_border_ID, body_text, true);   
+				}
+			}
+			content.find(".to").focus();
 
 			break;
@@ -2457,13 +2494,20 @@
 			// Insert the signature automaticaly at message body if use_signature preference is set
 			 if (preferences.use_signature == "1"){ 
-				$("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>' + signature);
-				RichTextEditor.setInitData(new_border_ID, '<div><br type="_moz"></div>' + signature);
+			 	var signature_text = '<div><br type="_moz"></div><div><br type="_moz"></div>' + signature;
+				if (preferences.plain_text_editor == "1"){
+					signature_text = "\n\n"+remove_tags(signature_text);
+					$("#body_"+new_border_ID).val(signature_text);
+				} 
+				else {
+					RichTextEditor.setInitData(new_border_ID, signature_text, true);
+				}
 				content.find(".to").focus();
 			 }
 			 else
 			   content.find('[name="input_to"]').focus(); 
+			
 			break;
 		case "edit":
-		btnSaveVerify();
+			btnSaveVerify();
 
 			if(flagged == 'F')
@@ -2524,5 +2568,12 @@
 			if (Element("attachments_" + border_ID))
 				addOriginalAttachments(new_border_ID,border_ID);
-			RichTextEditor.setInitData(new_border_ID, data.body, 'edit');
+
+			if (preferences.plain_text_editor == "1"){
+				data.body = remove_tags(data.body);
+				$("#body_"+new_border_ID).val(data.body);
+			} 
+			else {
+				RichTextEditor.setInitData(new_border_ID, data.body, 'edit');
+			}
 			
 			uidsSave[new_border_ID].push(new_border_ID);
@@ -5375,4 +5426,16 @@
 }
 
+/*
+* @author Marcos Luiz Wilhelm (marcoswilhelm@gmail.com)
+* @date 2012/11/26
+* @Remove HTML tags in the email body when the simple editor is used.
+*/
+function remove_tags (body){
+	var div = $("<div>").attr("display", "none");
+	div.html(body);
+    div.html($.trim(div.text().replace(/[\t]+/g, '').replace(/[\n]+/g, '\n')));
+	return div.text();
+}
+
 DataLayer.links('message');
 DataLayer.poll('message',30);
Index: /trunk/expressoMail1_2/js/rich_text_editor.js
===================================================================
--- /trunk/expressoMail1_2/js/rich_text_editor.js	(revision 7522)
+++ /trunk/expressoMail1_2/js/rich_text_editor.js	(revision 7568)
@@ -213,5 +213,5 @@
       RichTextEditor.plain[id] = active;
 	  var content = $("#content_id_"+id);
-	  var div = $("<div>").attr("display", "none");
+	  //var div = $("<div>").attr("display", "none");
       if(active === true)
       {
@@ -219,10 +219,7 @@
             var height = document.body.scrollHeight;
             height -= 330;
-            $('#body_'+id).height(height);
-            div.html($('#body_'+id).val());
-            /*Remove as tags html, tabulações e quebras de linha quando for utilizado o editor de texto simples*/
-            div.html($.trim(div.text().replace(/[\t]+/g, '').replace(/[\n]+/g, '\n')));
-            /*Insere o texto sem formatação no textarea*/
-            $('#body_'+id).val(div.text());
+            //Insere o texto sem formatação no textarea
+            var text_body = remove_tags($('#body_'+id).val());
+            $('#body_'+id).val(text_body);
             
             $('#body_'+id).keydown(function(event) {
@@ -238,6 +235,6 @@
           RichTextEditor.active('body_'+id, id);
           /*Insere somente quebras de linha para que o texto convertido não fique todo em uma linha só*/
-          div.html($('#body_'+id).val().replace(/[\n]+/g, '<br>'));
-          $('#body_'+id).val(div.html());
+          var text_body = $('#body_'+id).val().replace(/[\n]+/g, '<br>');
+          $('#body_'+id).val(text_body);
       }
 }
