Index: /trunk/instant_messenger/js/im_functions.js
===================================================================
--- /trunk/instant_messenger/js/im_functions.js	(revision 64)
+++ /trunk/instant_messenger/js/im_functions.js	(revision 65)
@@ -55,9 +55,6 @@
 	            	_this.vcards = true;
 	            }
-	      }
-	      catch(e)
-	      {
-				//alert("listen\n\n" + e + "\n\n" + e.description)
-	      }
+	      }catch(e){}
+
 	      _this._listen = true;
 	      setTimeout('IM.listen()', 3000);
@@ -131,9 +128,5 @@
 			 this.atalho();
 	      }
-	   }
-	   catch (e)
-	   {
-	      //alert('getContacts()' + e);
-	   }
+	   }catch(e){}
 
 	};
@@ -256,8 +249,5 @@
 	      }
 	      _this.Contacts_Offline();
-	   }
-	   catch(e)
-	   {
-	   }
+	   }catch(e){}
 	};
 
@@ -320,4 +310,6 @@
 						    nickname = func.trim(nickname);
 				   }
+				   else
+				      var nickname = from;
 
 	               var win = document.getElementById(from + '_chatMessages');
@@ -335,12 +327,10 @@
 
 	                  var label = document.createElement('strong');
-		              if(nickname)
-		                  label.appendChild(document.createTextNode(nickname));
-					  else
-		                  label.appendChild(document.createTextNode(from));
+	                  label.appendChild(document.createTextNode(nickname));
+
 	                  win.appendChild(label);
 	                  win.appendChild(document.createElement('br'));
-	                  win.innerHTML += XMLTools.transform(el, xsl);
-	                  win.innerHTML = this.emotions_icons(win.innerHTML);
+	                  var msg = XMLTools.transform(el, xsl);
+	                  win.innerHTML += this.emotions_icons(msg);
 	                  win.appendChild(document.createElement('br'));
 	                  win.appendChild(document.createElement('br'));
@@ -359,9 +349,5 @@
 	         }
 	      }
-	   }
-	   catch (e)
-	   {
-	   		//alert(e.description)
-	   }
+	   }catch(e){}
 	}
 
@@ -372,5 +358,22 @@
 	   var envio = name_document.contentWindow.document.getElementsByTagName('body').item(0);
 
-	   envio.innerHTML = func.trim(envio.innerHTML.replace(/^(&nbsp;|<br>| )*|(&nbsp;|<br>| )*$/g, ''));
+	   var imgs = envio.getElementsByTagName('img');
+	   var cod;
+	   var emotion_regexp;
+
+	   for ( i = imgs.length - 1; i > -1; i--)
+	   {
+	      if ( (cod = imgs[i].getAttribute('emotion')) )
+		  {
+			 emotion_regexp = new RegExp('<img[^>]*?emotion="' + cod_emotions[cod][1] + '"[^>]*?>', "i");
+             envio.innerHTML = envio.innerHTML.replace(emotion_regexp, cod);
+          }
+	      else
+	         imgs[i].parentNode.removeChild(imgs[i]);
+	   }
+
+	   envio.innerHTML = func.trim(envio.innerHTML.replace(/&nbsp;| +/g, ' '));
+	   envio.innerHTML = func.trim(envio.innerHTML.replace(/<br>/g, '<br/>'));
+	   envio.innerHTML = func.trim(envio.innerHTML);
 
 	   if ( envio.innerHTML != "" )
@@ -398,6 +401,6 @@
 
 	      message_element.innerHTML += '<strong>' + nickname + ' ';
-	      message_element.innerHTML += ' ' + _this.get_lang('speak') + ':</strong><br/>';
-		  message_element.innerHTML += message_text + '<br/>';
+	      message_element.innerHTML += ' ' + _this.get_lang('speak') + ':</strong><br />';
+		  message_element.innerHTML += this.emotions_icons(message_text) + '<br />';
 	      message_element.scrollTop = message_element.scrollHeight;
 
@@ -480,5 +483,4 @@
 	   {
 	      im_win.windowMaximizeRestore('contacts_im');
-	      //this.load_im();
 	   }
 	};
@@ -490,10 +492,22 @@
     IM.prototype.emotions_icons = function(pEmotion)
     {
-       for ( i = 1; i < cod_emotions.length; i++ )
+	   var emotion_regexp;
+	   for ( i in cod_emotions )
        {
-          var image = eval('smile_' + i + '.src.substr(smile_' + i + '.src.indexOf(im_path))')
-          pEmotion  = pEmotion.replace(cod_emotions[i], '<img emotion="' + pEmotion + '" src="' + image + '">');
+		  try
+		  {
+			 emotion_regexp = new RegExp(cod_emotions[i][1], 'gi');
+             if ( emotion_regexp.test(pEmotion) )
+             {
+                var image = eval('smile_' + cod_emotions[i][0] + '.src.substr(smile_' +cod_emotions[i][0]  + '.src.indexOf(im_path))');
+			    emotion_regexp = new RegExp(cod_emotions[i][1], 'gi');
+                pEmotion = pEmotion.replace(emotion_regexp, '<img emotion="' + i + '" src="' + image + '">');
+             }
+		  }
+		  catch(e)
+		  {
+			  //alert(e.description)
+		  }
        }
-
        return pEmotion;
     }
@@ -574,6 +588,4 @@
 
 		  }catch(e){}
-
-
 	};
 
@@ -607,9 +619,5 @@
 				if ( func.byId(pJid).firstChild.src != img_unavailable.src )
 					this.open_chat(pJid);
-		}
-		catch(e)
-		{
-			//alert("action_button\n\n" + e)
-		}
+		}catch(e){}
 	};
 
@@ -683,5 +691,5 @@
 				Child[i].firstChild.insertBefore(img, Child[i].firstChild.firstChild);
 			}
-		}catch (e){}
+		}catch(e){}
 	}
 
@@ -803,7 +811,6 @@
 				this.ImgStatus(pStatus);
 				pStatus = 'show=' + pStatus;
-	         }
-	         catch(e){}
-	         }
+	         }catch(e){}
+	        }
 	      }
 		  XMLTools.request('$this.Ujabber.setPresence', 'POST', handler, pStatus);
Index: /trunk/instant_messenger/js/im_var_globals.js
===================================================================
--- /trunk/instant_messenger/js/im_var_globals.js	(revision 64)
+++ /trunk/instant_messenger/js/im_var_globals.js	(revision 65)
@@ -67,15 +67,16 @@
 var im_busy = false;
 
-var cod_emotions = new Array();
-	cod_emotions[1] = /\:\)/gi;
-	cod_emotions[2] = /\:d/gi;
-	cod_emotions[3] = /\;\)/gi;
-	cod_emotions[4] = /\:o/gi;
-	cod_emotions[5] = /\:p/gi;
-	cod_emotions[6] = /\(h\)/gi;
-	cod_emotions[7] = /\:\@/gi;
-	cod_emotions[8] = /\:\$/gi;
-	cod_emotions[9] = /\:s/gi;
-	cod_emotions[10] = /\:\(/gi;
-	cod_emotions[11] = /\:\'\(/gi;
-	cod_emotions[12] = /\:\|/gi;
+var cod_emotions = {
+	":)" : [1,"\\\:\\\)"],
+	":d" : [2,"\\\:d"],
+	";)" : [3,"\\\;\\\)"],
+	":o" : [4,"\\\:o"],
+	":p" : [5,"\\\:p"],
+	"(h)" : [6,"\\\(h\\\)"],
+	":@" : [7,"\\\:\\\@"],
+	":$" : [8,"\\\:\\\$"],
+	":s" : [9,"\\\:s"],
+	":(" : [10,"\\\:\\\("],
+	":'(" : [11,"\\\:\\\'\\\("],
+	":|" : [12,"\\\:\\\|"]
+};
Index: /trunk/expressoMail1_2/setup/setup.inc.php
===================================================================
--- /trunk/expressoMail1_2/setup/setup.inc.php	(revision 60)
+++ /trunk/expressoMail1_2/setup/setup.inc.php	(revision 65)
@@ -12,5 +12,5 @@
 	$setup_info['expressoMail1_2']['name']      	= 'expressoMail1_2';
 	$setup_info['expressoMail1_2']['title']     	= 'ExpressoMail 1.2';
-	$setup_info['expressoMail1_2']['version']   	= '1.2101';
+	$setup_info['expressoMail1_2']['version']   	= '1.2102';
 	$setup_info['expressoMail1_2']['app_order'] 	= 2;
 //	$setup_info['expressoMail1_2']['tables'][]    	= 'phpgw_expressoMail1_2';
Index: /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 63)
+++ /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 65)
@@ -417,5 +417,5 @@
 
 				}
-				else if($file_type == "message/rfc822"){
+				else if($file_type == "message/rfc822" || $file_type == "text/rfc822-headers"){
 					
 					include_once("class.imap_attachment.inc.php");
@@ -425,5 +425,6 @@
 						foreach($attachments ['attachment'] as $index => $attachment){
 							if(strtolower($attachment['type']) == "delivery-status" ||
-								strtolower($attachment['type']) == "rfc822" ||
+								strtolower($attachment['type']) == "rfc822" ||								
+								strtolower($attachment['type']) == "rfc822-headers" ||
 								strtolower($attachment['type']) == "plain"
 							){
Index: /trunk/expressoMail1_2/js/common_functions.js
===================================================================
--- /trunk/expressoMail1_2/js/common_functions.js	(revision 53)
+++ /trunk/expressoMail1_2/js/common_functions.js	(revision 65)
@@ -26,11 +26,13 @@
 	var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight;
 	var defaultHeight = screenHeight - offset;
-	for(var i = 1; BordersArray.length > 1 && i < BordersArray.length;i++) {
-		var div_scroll = Element("div_message_scroll_"+BordersArray[i].sequence);
-		if(div_scroll)
-			div_scroll.style.height = defaultHeight - 122;
-		var div = Element("content_id_"+BordersArray[i].sequence);
-		if(div)
-			div.style.height = defaultHeight - 73;
+	if(BordersArray) {
+		for(var i = 1; BordersArray.length > 1 && i < BordersArray.length;i++) {
+			var div_scroll = Element("div_message_scroll_"+BordersArray[i].sequence);
+			if(div_scroll)
+				div_scroll.style.height = defaultHeight - 122;
+			var div = Element("content_id_"+BordersArray[i].sequence);
+			if(div)
+				div.style.height = defaultHeight - 73;
+		}
 	}
 	Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150);
Index: /trunk/expressoMail1_2/js/main.js
===================================================================
--- /trunk/expressoMail1_2/js/main.js	(revision 63)
+++ /trunk/expressoMail1_2/js/main.js	(revision 65)
@@ -504,5 +504,5 @@
 	else{			
 		if(data == 'false')
-			write_msg(get_lang('The size of this message exceeded  the limit (%1B).',Element('upload_max_filesize').value));
+			write_msg(get_lang('The size of this message has exceeded  the limit (%1B).',Element('upload_max_filesize').value));
 		else if(data == null)
 			write_msg(get_lang("your session could not be verified."));
Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 63)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 65)
@@ -660,5 +660,5 @@
 function draw_message(info_msg, ID){
 	var content = document.getElementById('content_id_' + ID);
-	var defaultWidth = document.body.clientWidth - (is_ie ? 32 : 37);
+	var defaultWidth = document.body.offsetWidth - 37;
 	
 	var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
Index: /trunk/expressoMail1_2/index.php
===================================================================
--- /trunk/expressoMail1_2/index.php	(revision 60)
+++ /trunk/expressoMail1_2/index.php	(revision 65)
@@ -4,5 +4,5 @@
 		'nonavbar' => False,
 		'currentapp' => 'expressoMail1_2',
-		'update_version'	=> '1.2101',
+		'update_version'	=> '1.2102',
 		'enable_nextmatchs_class' => True
 	);
@@ -41,5 +41,5 @@
 	$template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
 	$template->set_var("txt_loading",lang("Loading"));
-	$template->set_var("txt_clear_trash",lang("message(s) were deleted from trash folder."));
+	$template->set_var("txt_clear_trash",lang("message(s) deleted from your trash folder."));
 	$template->set_var("upload_max_filesize",ini_get('upload_max_filesize'));
 	$template->set_var("msg_folder",$_GET['msgball']['folder']);
Index: /trunk/expressoMail1_2/templates/default/index.tpl
===================================================================
--- /trunk/expressoMail1_2/templates/default/index.tpl	(revision 64)
+++ /trunk/expressoMail1_2/templates/default/index.tpl	(revision 65)
@@ -30,9 +30,9 @@
 				<div align="center">
 					<input type="text" id="em_message_search" size="18" maxlength="22"/>
-					<a  onMouseOut="window.status='';return true;" title="Abrir janela de Pesquisa..." onMouseOver="window.status='Abrir janela de Pesquisa...';return true;" href="javascript:void(0);"  onClick="javascript:search_emails(Element('em_message_search').value)">
+					<a class='' onMouseOut="window.status='';return true;" title="Abrir janela de Pesquisa..." onMouseOver="window.status='Abrir janela de Pesquisa...';return true;" href="javascript:void(0);"  onClick="javascript:search_emails(Element('em_message_search').value)">
 						<img valign="center" align="center" src="templates/default/images/search.gif">
 					</a>
-					<a onMouseOut="window.status='';return true;" title="Pesquisar usuário..." onMouseOver="window.status='Pesquisar usuário...';return true;" href="javascript:void(0);"  onClick="javascript:emQuickSearch(Element('em_message_search').value, 'null', 'null')">
-						<img valign="center" align="center" src="templates/default/images/users.png">
+					<a class='' onMouseOut="window.status='';return true;" title="Pesquisar usuário..." onMouseOver="window.status='Pesquisar usuário...';return true;" href="javascript:void(0);"  onClick="javascript:emQuickSearch(Element('em_message_search').value, 'null', 'null')">
+						<img valign="center" align="center" src="templates/default/images/users.jpg">
 					</a>
 				</div>
