Index: sandbox/2.2.0.2/expressoMail1_2/js/rich_text_editor.js
===================================================================
--- sandbox/2.2.0.2/expressoMail1_2/js/rich_text_editor.js	(revision 4225)
+++ sandbox/2.2.0.2/expressoMail1_2/js/rich_text_editor.js	(revision 4281)
@@ -25,4 +25,7 @@
 		parentDiv.appendChild(this.table);
 
+        var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + this.id );
+        this.table.style.visibility = ( mail_as_plain && mail_as_plain.checked ) ? 'hidden' : 'visible';
+
 	if(!Element(this.editor))
 	{
@@ -31,5 +34,5 @@
 	else
 	{
-		Element("viewsource_rt_checkbox").checked=false;
+		Element( 'viewsource_rt_checkbox_' + this.id ).checked=false;
 	}
 
@@ -50,5 +53,7 @@
 		config_events( iframe, 'onload', function( )
 		{
-			iframe.contentWindow.document.designMode = "on";
+			if ( iframe.contentWindow.document.body && iframe.contentWindow.document.body.contentEditable )
+				iframe.contentWindow.document.body.contentEditable = true;
+
 			if ( iframe.contentWindow.document.documentElement ){
 				iframe.contentWindow.document.documentElement.style.background = '#fff';
@@ -57,13 +62,19 @@
 		});
 
-		var checkbox = document.createElement("INPUT");
-		checkbox.id = 'viewsource_rt_checkbox';
-		checkbox.type = "checkbox";
-		checkbox.setAttribute("tabIndex","-1");
-		checkbox.onclick = function () {RichTextEditor.viewsource(this.checked)};
-		var text = document.createTextNode(get_lang('View HTML source') + '.');
 		parentDiv.appendChild(iframe);
-		parentDiv.appendChild(checkbox);
-		parentDiv.appendChild(text);
+
+		var source = document.createElement( 'input' );
+		source.id = 'viewsource_rt_checkbox_' + this.id;
+		source.type = "checkbox";
+		source.setAttribute("tabIndex","-1");
+		source.onclick = function( )
+		{
+			RichTextEditor.viewsource(this.checked);
+		};
+		source = parentDiv.appendChild(
+			document.createElement( 'span' ).appendChild( source ).parentNode
+		).appendChild(
+			document.createTextNode( get_lang( 'View HTML source' ) + '.' )
+		).parentNode;
 }
 
@@ -138,4 +149,62 @@
 			document.getElementById(this.editor).contentWindow.document.body.innerHTML = html.toString();
 			document.getElementById("table_richtext_toolbar").style.visibility="visible";  
+		}
+	}
+}
+
+cRichTextEditor.prototype.plain = function(source) {
+	var html;
+	var editor = document.getElementById( this.editor );
+
+	if (source) {
+		if (is_ie){
+			connector.loadScript('html2xhtml');
+			html = frames[this.editor].document.body;
+			var xhtml = get_xhtml(html, 'en', 'iso-8859-1');
+			frames[this.editor].document.body.innerText = xhtml;
+			document.getElementById("table_richtext_toolbar").style.visibility="hidden";
+		}
+		else{
+                        var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + this.id );
+
+			html = document.createTextNode( editor.contentWindow.document.body.innerHTML );
+                        html = html.nodeValue.replace( /<br\s*\/?>/mg, "\n" ).replace( /(<([^>]+)>)/ig, '' ).replace( /^[\n ]+|[\n ]+$/g, '' );
+
+			if ( ! mobile_device && html != '' && ! ( mail_as_plain.checked = confirm( 'The text format will be lost.' ) ) )
+				return false;
+
+			this.table.style.visibility="hidden";
+			editor.contentWindow.document.body.innerHTML = '';
+
+			var textarea = document.createElement( 'textarea' );
+			textarea.style.width = '99%';
+			textarea.style.height = '300px';
+			textarea.style.fontSize = '12pt';
+			textarea.innerHTML = html;
+
+			editor.style.width = '0px';
+			editor.style.height = '0px';
+			editor.style.visibility = 'hidden';
+
+			editor.parentNode.insertBefore( textarea, editor );
+			textarea.focus( );
+		}
+	} else {
+		if (is_ie){
+			var output = escape(frames[this.editor].document.body.innerText);
+			output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E");
+			output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E");
+			frames[this.editor].document.body.innerHTML = unescape(output);
+			document.getElementById("table_richtext_toolbar").style.visibility="visible";
+		}
+		else{
+			editor.contentWindow.document.body.innerHTML = editor.previousSibling.value.replace( /\n/g, '<br/>' );
+			editor.parentNode.removeChild( editor.previousSibling );
+
+			editor.style.width = '99%';
+			editor.style.height = '300px';
+			editor.style.visibility = 'visible';
+
+			this.loadEditor( this.id );
 		}
 	}
@@ -497,5 +566,5 @@
 		form_upload.style.height = "75px";
 		form_upload.innerHTML = get_lang('Select the desired image file')+':<br>'+
-								'<input name="image_at" maxlength="255" size="40" id="inputFile_img" type="file"><br>' +
+								'<input name="image_at" maxlength="255" size="50" id="inputFile_img" type="file"><br>' +
 								'<input title="' + get_lang('Include') + '"  value="' + get_lang('Include') + '"' + 'type="button" onclick="RichTextEditor.addInputFile();">&nbsp;' +
 								'<input title="' + get_lang('Close') + '"  value="' + get_lang('Close') + '"' +
