Index: sandbox/2.2.0.2/expressoMail1_2/js/main.js
===================================================================
--- sandbox/2.2.0.2/expressoMail1_2/js/main.js	(revision 4282)
+++ sandbox/2.2.0.2/expressoMail1_2/js/main.js	(revision 4283)
@@ -5,4 +5,6 @@
 var autosave_time = 20000;
 
+var cabecalho = '<h4>ExpressoLivre - ExpressoMail</h4>'; 
+
 function init(){
 	if (!is_ie)
@@ -20,4 +22,13 @@
 
 		preferences = data;
+		
+		if(preferences.show_name_print_messages == "1") { 
+			var getUserName = document.getElementById("user_info"); 
+			var userName = getUserName.innerHTML; 
+			var position = userName.indexOf("-"); 
+			var userName = userName.substring(3, position); 
+			cabecalho = '<h4>' + userName; 
+ 	  	}  
+		
 		current_folder="INBOX";
 		
@@ -79,8 +90,4 @@
 
 	cExecute ("$this.functions.get_preferences", save_preferences);
-        cExecute ("phpgwapi.browser.isMobile", function( data )
-	{
-		mobile_device = ( ( data.constructor == Boolean ) ? data : ( data === 'true' ) );
-	} );
 	setTimeout('auto_refresh()', time_refresh);
 
@@ -890,4 +897,5 @@
 		}
 	var new_border_ID = draw_new_message(parseInt(border_ID));
+
 	if(typeof(openTab.type[new_border_ID]) != "undefined") {
 		if(tabTypes[type] == openTab.type[new_border_ID]) {
@@ -910,4 +918,5 @@
 		}
 	}
+
 	if (new_border_ID == false)
 	{
@@ -1639,6 +1648,6 @@
 	}
 
-	if ( document.getElementById('viewsource_rt_checkbox_' + ID).checked == true )
-		document.getElementById('viewsource_rt_checkbox_' + ID).click();
+	if ( document.getElementById('viewsource_rt_checkbox').checked == true )
+		document.getElementById('viewsource_rt_checkbox').click();
 
 	var save_link = Element("save_message_options_"+ID);
@@ -1651,7 +1660,4 @@
 		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 textArea = document.createElement("TEXTAREA");
@@ -1659,5 +1665,7 @@
 	textArea.name = "body";
 	body = document.getElementById("body_"+ID);
-	textArea.value = ( ( mail_as_plain ) ? body.previousSibling.value : ( '<body>\r\n' + body.contentWindow.document.body.innerHTML + '\r\n</body>' ) );
+	textArea.value += '<body>\r\n';
+	textArea.value += body.contentWindow.document.body.innerHTML;
+	textArea.value += '\r\n</body>';
 	var input_folder = document.createElement("INPUT");
 	input_folder.style.display='none';
@@ -1693,9 +1701,4 @@
 	form.appendChild(input_folder);
 	form.appendChild(msg_id);
-
-        var mail_type = form.appendChild( document.createElement( 'input' ) );
-	mail_type.name = 'type';
-	mail_type.type = 'hidden';
-	mail_type.value = ( mail_as_plain ) ? 'plain' : 'html';
 
 	var _subject = trim(Element("subject_"+ID).value);
@@ -1903,5 +1906,5 @@
 		withImage = false;
 
-	var rt_checkbox = Element('viewsource_rt_checkbox_' + border_id);
+	var rt_checkbox = Element('viewsource_rt_checkbox');
 	if (rt_checkbox == null)
 		return false;
@@ -1929,7 +1932,4 @@
 	message_id = openTab.imapUid[border_id];
 	var handler_save_msg = function(data){ return_save(data,this.tmp_border_id,this.tmp_folder_name,this.tmp_folder_id,this.message_id); }
-	
-	var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + border_id ); 
- 	mail_as_plain = ( mail_as_plain ) ? mail_as_plain.checked : false; 
 
 	var textArea = document.createElement("TEXTAREA");
@@ -1939,6 +1939,7 @@
 	if (! body)
 		return;
-	
-	textArea.value = ( ( mail_as_plain ) ? body.previousSibling.value : ( '<body>\r\n' + body.contentWindow.document.body.innerHTML + '\r\n</body>' ) ); 
+	textArea.value += '<body>\r\n';
+	textArea.value += body.contentWindow.document.body.innerHTML;
+	textArea.value += '\r\n</body>';
 	var input_folder = document.createElement("INPUT");
 	input_folder.style.display='none';
@@ -1967,9 +1968,4 @@
 	form.appendChild(input_insertImg);
 
-	var mail_type = form.appendChild( document.createElement( 'input' ) ); 
- 	mail_type.name = 'type'; 
- 	mail_type.type = 'hidden'; 
- 	mail_type.value = ( mail_as_plain ) ? 'plain' : 'html'; 
-	
 	cExecuteForm ("$this.imap_functions.save_msg", form, handler_save_msg,border_id);
 }
@@ -2165,5 +2161,5 @@
 		try{
 			var html = '<br>';
-			html += "<h4>ExpressoLivre - ExpressoMail</h4>";
+			html += cabecalho + "</h4><hr>";
 			html += folder+"<hr>";
 
@@ -2243,22 +2239,15 @@
 	} else{
 		show_attachs = "";
-	}       
+	}
+        
 	var current_path = window.location.href.substr(0,window.location.href.lastIndexOf("/"));
-	var window_print_head  = window_print.document.getElementsByTagName("head")[0];
-	// For IE
-	if(typeof(window_print_head) == 'undefined'){
-		window_print_head = window_print.document.createElement("head");
-		window_print.document.appendChild(window_print_head);
-	}
-	var window_print_style = window_print.document.createElement("LINK");
-	window_print_style.href = current_path+'/templates/default/main.css';
-	window_print_style.type = "text/css";
-	window_print_style.rel = "stylesheet";
-	window_print_head.appendChild(window_print_style);	
-
+
+	var head = '<head><title></title><link href="'+current_path+'/templates/default/main.css" type="text/css" rel="stylesheet"></head>'; 
+	window_print.document.write(head); 
+	
 	while (1){
 		try{
 			var html ='<body>';
-			html += "<h4>ExpressoLivre - ExpressoMail</h4><hr>";
+			html += cabecalho + "</h4><hr>";
 			html += '<table><tbody>';
 			if(sender)
@@ -2286,5 +2275,5 @@
 			html += show_attachs; //to show the names of the attachments
 			html += "</tbody></table><hr>";
-			window_print.document.body.innerHTML = html + body.innerHTML;
+			window_print.document.write(html + body.innerHTML); 
 			if(!is_ie){
 				var tab_tags = window_print.document.getElementsByTagName("IMG");
@@ -2514,5 +2503,5 @@
 	}
 	form_upload.innerHTML = '<form method="POST" name="form_import" enctype="multipart/form-data">'+get_lang('zip mails to import')+':<br>'+
-	'<input name="file_1" maxlength="255" size="50" id="file_1" type="file"><br>' +
+	'<input name="file_1" maxlength="255" size="40" id="file_1" type="file"><br>' +
 	'<input title="'+get_lang('Select a folder')+'"  value="' + get_lang('Select a folder') + '"' + 'type="button" onclick="javascript:select_import_folder()">&nbsp;' +
 	'<input title="' + get_lang('Close') + '"  value="' + get_lang('Close') + '"' +
Index: sandbox/2.2.0.2/expressoMail1_2/js/draw_api.js
===================================================================
--- sandbox/2.2.0.2/expressoMail1_2/js/draw_api.js	(revision 4281)
+++ sandbox/2.2.0.2/expressoMail1_2/js/draw_api.js	(revision 4283)
@@ -2592,8 +2592,7 @@
 		//var option_send = '<span class="message_options" onclick=send_message("'+ID+'","null","null");>'+get_lang("Send")+'</span> | ';
 		var option_send   = '<input type="button" id="send_button_'+ID+'" class="em_button_like_span" tabindex="1" value="'+get_lang("Send and not file")+'" onclick=send_message("'+ID+'","null","null");>' + ' | ';
-
 		if(!expresso_offline)
 			var option_send_and_file= '<span class="message_options" onclick=wfolders.makeWindow("'+ID+'","send_and_file");>'+get_lang("Send and file")+'</span> | ';
-		else
+		else			
 			var option_send_and_file='';
 	}
@@ -2616,5 +2615,4 @@
 
 	tr_menu_new_message.appendChild(td_menu_new_message);
-
 	tbody_menu_new_message.appendChild(tr_menu_new_message);
 	table_menu_new_message.appendChild(tbody_menu_new_message);
@@ -3144,26 +3142,4 @@
 	tr5.appendChild(td5);
 	tr5.appendChild(td_return_receipt);
-
-        if ( ! expresso_offline )
-	{
-		var text_plain = td_return_receipt.appendChild(
-			document.createElement( 'span' )
-		).appendChild(
-			document.createTextNode( ' | ' )
-		).parentNode.appendChild(
-			document.createTextNode( get_lang('Send this mail as text plain') + '.')
-		).parentNode.appendChild(
-			document.createElement( 'input' )
-		);
-		text_plain.setAttribute( 'tabIndex', '-1' );
-		text_plain.id = 'textplain_rt_checkbox_' + ID ;
-		text_plain.type = "checkbox";
-		text_plain.onclick = function ()
-		{
-			RichTextEditor.plain( this.checked );
-			document.getElementById( 'viewsource_rt_checkbox_' + ID ).parentNode.style.display = ( this.checked ) ? 'none' : '';
-		};
-	}
-
 	tbody_message.appendChild(tr5);
 	if (parseInt(preferences.use_important_flag))
@@ -3245,14 +3221,4 @@
 		draw_from_field(sel_from,tr1_1);
 	resizeWindow();
-
-        if ( ! expresso_offline )
-	{
-		if ( mobile_device )
-		{
-			text_plain.click( );
-			text_plain.parentNode.style.display = 'none';
-		}
-	}
-        
 	return ID;
 }
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 4281)
+++ sandbox/2.2.0.2/expressoMail1_2/js/rich_text_editor.js	(revision 4283)
@@ -25,7 +25,4 @@
 		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))
 	{
@@ -34,5 +31,5 @@
 	else
 	{
-		Element( 'viewsource_rt_checkbox_' + this.id ).checked=false;
+		Element("viewsource_rt_checkbox").checked=false;
 	}
 
@@ -53,7 +50,5 @@
 		config_events( iframe, 'onload', function( )
 		{
-			if ( iframe.contentWindow.document.body && iframe.contentWindow.document.body.contentEditable )
-				iframe.contentWindow.document.body.contentEditable = true;
-
+			iframe.contentWindow.document.designMode = "on";
 			if ( iframe.contentWindow.document.documentElement ){
 				iframe.contentWindow.document.documentElement.style.background = '#fff';
@@ -62,19 +57,13 @@
 		});
 
+		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);
-
-		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;
+		parentDiv.appendChild(checkbox);
+		parentDiv.appendChild(text);
 }
 
@@ -149,62 +138,4 @@
 			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 );
 		}
 	}
@@ -566,5 +497,5 @@
 		form_upload.style.height = "75px";
 		form_upload.innerHTML = get_lang('Select the desired image file')+':<br>'+
-								'<input name="image_at" maxlength="255" size="50" id="inputFile_img" type="file"><br>' +
+								'<input name="image_at" maxlength="255" size="40" 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') + '"' +
