Index: /sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js
===================================================================
--- /sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js	(revision 2815)
+++ /sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js	(revision 2821)
@@ -494,5 +494,5 @@
 		if( status == Strophe.Status.CONNECTED )
 		{
-			loadscript.setStatusJabber('Disponível','available');
+			loadscript.setStatusJabber('Disponï¿œvel','available');
 			TrophyIM.statusConn.connected = true;
             TrophyIM.showClient();
@@ -677,5 +677,5 @@
 		}
 
-		// Message with body are "content message", this mean state active
+		// Message with body are "content message", this means state active
 		if ( elems.length > 0 )
 		{
@@ -713,9 +713,16 @@
 		{
 			if( chatBox != null )
-				state = TrophyIM.getChatState(msg);			
-		}
-		
-		if( chatBox != null )
-			chatBox.innerHTML = '<font style="font-weight:bold; color:grey; margin-left: 5px; float:right;">' + state + '</font>';	
+				state = contact + TrophyIM.getChatState(msg);			
+		}
+		
+		// Clean chat status message some time later 		
+		var clearChatState = function(){
+			chatBox.innerHTML='';
+		}
+		
+		if (chatBox != null) {
+			chatBox.innerHTML = "<font style='font-weight:bold; color:grey; margin-left: 5px; float:left;'>" + state + "</font>";
+			var clearChatState = setTimeout(clearChatState, 2000);
+		}
 		
 		return true;
@@ -734,5 +741,5 @@
 		if ( state.length > 0 )
 		{
-        	return' está inativo...';
+        	return ' estÃ¡ inativo...';
 		}
 		else
@@ -748,5 +755,5 @@
             	if ( state.length > 0 )
             	{
-               		return ' está digitando...';
+               		return ' estÃ¡ digitando...';
 				}
             	else
@@ -755,5 +762,5 @@
                 	if ( state.length > 0 )
                 	{
-                  		return ' está parado...';
+                  		return ' estÃ¡ parado...';
 					}
 				}
@@ -831,4 +838,5 @@
 		loadscript.configEvents( _textarea, 'onkeyup', function( e )
 		{
+			setComposing();
 			if ( e.keyCode == 13 )
 				_send_message( );
@@ -860,4 +868,31 @@
    		loadscript.getPhotoUser(barejid);
    		
+   		var composingTimer_ = 0;
+   		var isComposing_ = 0;
+   		var timeCounter;
+
+   		function setComposing()
+   		{
+   			var checkComposing = function()
+   			{
+            	if (!isComposing_) {
+               		// User stopped composing
+               		composingTimer_ = 0;
+               		clearInterval(timeCounter);
+               		TrophyIM.sendContentMessage(barejid, 'paused');
+            	} else {
+               		TrophyIM.sendContentMessage(barejid, 'composing');
+            	}
+            	isComposing_ = 0; // Reset composing
+         	}
+
+         	if (!composingTimer_) {
+            	/* User (re)starts composing */
+            	composingTimer_ = 1;
+            	timeCounter = setInterval(checkComposing,3000);
+         	}
+         	isComposing_ = 1;
+      	}
+
    		_textarea.focus( );
    		
@@ -1204,5 +1239,5 @@
 							case "none" :
 								
-								paramsContact.status		= " (( PEDIR AUTORIZAÇAO ! )) ";
+								paramsContact.status		= " (( PEDIR AUTORIZAÃÃO ! )) ";
 								paramsContact.statusColor	= "red";
 								break;
@@ -1210,5 +1245,5 @@
 							case "to" :
 								
-								paramsContact.status 		= " (( CONTATO PEDE AUTORIZAÇÃO ! )) ";
+								paramsContact.status 		= " (( CONTATO PEDE AUTORIZAÃÃO ! )) ";
 								paramsContact.statusColor	= "orange";
 								break;
@@ -1222,5 +1257,5 @@
 							case "subscribe" : 
 								
-								paramsContact.status		= " (( AUTORIZAÇÃO ENVIADA ! )) ";
+								paramsContact.status		= " (( AUTORIZAÃÃO ENVIADA ! )) ";
 								paramsContact.statusColor	= "red";	
 								break;
@@ -1228,5 +1263,5 @@
 							case "not-in-roster" :
 								
-								paramsContact.status		= " (( QUERO ADICIONÁ-LO(A) ! POSSO ? )) ";
+								paramsContact.status		= " (( QUERO ADICIONÃ-LO(A) ! POSSO ? )) ";
 								paramsContact.statusColor	= "orange";	
 								break;
@@ -1295,5 +1330,5 @@
 							case "none" :
 								
-								status 		= " (( PEDIR AUTORIZAÇAO ! )) ";
+								status 		= " (( PEDIR AUTORIZAÃÃO ! )) ";
 								statusColor	= "red";
 								break;
@@ -1301,5 +1336,5 @@
 							case "to" :
 								
-								status 		= " (( CONTATO PEDE AUTORIZAÇÃO ! )) ";
+								status 		= " (( CONTATO PEDE AUTORIZAÃÃO ! )) ";
 								statusColor	= "orange";
 								break;
@@ -1313,5 +1348,5 @@
 							case "subscribe" : 
 								
-								status		= " (( AUTORIZAÇÃO ENVIADA ! )) ";
+								status		= " (( AUTORIZAÃÃO ENVIADA ! )) ";
 								statusColor	= "red";	
 								break;
@@ -1319,5 +1354,5 @@
 							case "not-in-roster" :
 								
-								status		= " (( QUERO ADICIONÁ-LO(A) ! POSSO ? )) ";
+								status		= " (( QUERO ADICIONÃ-LO(A) ! POSSO ? )) ";
 								statusColor	= "orange";	
 								break;
@@ -1440,5 +1475,5 @@
 		if( _type != 'status')
 		{
-			if( _type == "unavailable" && TrophyIM.statusConn.connected )
+			if( _type == "unavailable")
 			{
 				var loading_gif = document.getElementById("JabberIMRosterLoadingGif");
@@ -1543,21 +1578,52 @@
      */
      
-    sendMessage : function( _jidTo, _message )
+    sendMessage : function()
     {
-		_message = _message.replace(/^\s+|\s+$|^\n|\n$/g,"");
-        
-		if( _message != "" )
-		{
-    		// Send Message
-    		TrophyIM.connection.send(
-    			$msg( {
-    				to: _jidTo, from: TrophyIM.connection.jid,
-    				type: 'chat'
-    			} ).c('body').t( _message ).tree()
-    		);
-    		return true;
+		if (arguments.length > 0) {
+			var jidTo = arguments[0];
+			var message_input = arguments[1];
+			
+			
+			message_input = message_input.replace(/^\s+|\s+$|^\n|\n$/g, "");
+			
+			if (message_input != "") {
+			
+				// Send Message
+				var newMessage = $msg({
+					to: jidTo,
+					from: TrophyIM.connection.jid,
+					type: 'chat'
+				});
+				newMessage = newMessage.c('body').t(message_input);
+				newMessage.up();
+				newMessage = newMessage.c('active').attrs({
+					xmlns: 'http://jabber.org/protocol/chatstates'
+				});
+				// Send Message
+				TrophyIM.connection.send(newMessage.tree());
+				
+				return true;
+			}
 		}
 		
 		return false;
+    },
+	
+	/** Function: sendContentMessage
+     *
+     *  Send a content message from chat input to user
+     */
+	sendContentMessage : function()
+    {
+      if( arguments.length > 0 )
+      {
+         var jidTo = arguments[0];
+         var state = arguments[1];
+
+         var newMessage = $msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'});
+         newMessage = newMessage.c(state).attrs({xmlns : 'http://jabber.org/protocol/chatstates'});
+         // Send content message
+         TrophyIM.connection.send(newMessage.tree());
+      }
     }
 };
