Index: sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js	(revision 2716)
+++ sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js	(revision 2724)
@@ -644,45 +644,92 @@
         var stamp	= ( delay[0] != null ) ? messageDate(delay[0].getAttribute('stamp')) :  dtNow;
 
-        if ( (type == 'chat' || type == 'normal') && elems.length > 0 )
-        {
-            var barejid		= Strophe.getBareJidFromJid(from);
-            var jid_lower	= barejid.toLowerCase();
-            var contact		= "";
-            contact			= barejid.toLowerCase();
-        	contact 		= contact.substring(0, contact.indexOf('@'));
+		var barejid		= Strophe.getBareJidFromJid(from);
+		var jid_lower	= barejid.toLowerCase();
+		var contact		= "";
+		var state = '';
+
+		var chatBox	= document.getElementById(jid_lower + "__chatState");
+
+		contact			= barejid.toLowerCase();
+		contact 		= contact.substring(0, contact.indexOf('@'));
             
-            if( TrophyIM.rosterObj.roster[barejid] )
-            {
-	            if( TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'] )
-	            {
-	            	contact = TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'];
-	            }
-            }
-
-        	var _message = document.createElement("div");
-    		_message.innerHTML = Strophe.getText(elems[0]);
-
-	    	var scripts = _message.getElementsByTagName( 'script' );
-
-	    	for ( var i = 0; i < scripts.length; i++ )
-	    		_message.removeChild( scripts[ i-- ] );
-	    	
-	    	_message.innerHTML = _message.innerHTML.replace(/^\s+|\s+$|^\n|\n$/g,"");
-
-        	if ( _message.hasChildNodes( ) )
-        	{
-	            var message = 
-	            { 
-	            	contact : "[" + stamp + "] <font style='font-weight:bold; color:black;'>" + contact + "</font>",
-	            	msg		: "<br/>" + _message.innerHTML
-	            };
-	
-	            TrophyIM.makeChat(from); //Make sure we have a chat window
-	            TrophyIM.addMessage(message, jid_lower);
-        	}
-        }
-        
-        return true;
-    },
+		if( TrophyIM.rosterObj.roster[barejid] )
+		{
+			if( TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'] )
+			{
+				contact = TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'];
+			}
+		}
+
+		// Message with body are "content message", this mean state active
+		if (elems.length > 0)
+		{
+			state = contact + ' está ativo.';
+
+			if (type == 'chat' || type == 'normal') {
+			
+				var _message = document.createElement("div");
+				_message.innerHTML = Strophe.getText(elems[0]);
+				
+				var scripts = _message.getElementsByTagName('script');
+				
+				for (var i = 0; i < scripts.length; i++) 
+					_message.removeChild(scripts[i--]);
+				
+				_message.innerHTML = _message.innerHTML.replace(/^\s+|\s+$|^\n|\n$/g, "");
+
+				if (_message.hasChildNodes() )
+				{
+					var message = 
+					{
+		            	contact : "[" + stamp + "] <font style='font-weight:bold; color:black;'>" + contact + "</font>",
+		            	msg		: "</br>" + _message.innerHTML
+	    	        };
+					
+					TrophyIM.makeChat(from); //Make sure we have a chat window
+					TrophyIM.addMessage(message, jid_lower);
+				}
+			}
+		}
+		// Message without body are "content message", this mean state is not active
+		else
+		{
+			state = contact + TrophyIM.getChatState(msg);			
+		}
+		chatBox.innerHTML = "<font style='font-weight:bold; color:grey;'>" + state + "</font>";	
+		return true;
+	},
+
+	/** Function: getChatState
+	 *
+	 *  Parameters:
+	 *    (string) msg - the message to get chat state
+	 *    (string) jid - the jid of chat box to update the chat state to.
+  	 */
+	getChatState : function(msg)
+	{
+		var	state =  msg.getElementsByTagName('inactive');
+         	
+		if ( state.length > 0 ) {
+        	return' está inativo...';
+		} else {
+         	state = msg.getElementsByTagName('gone');
+            if ( state.length > 0 ){
+            	return ' saiu da conversa.';
+			} else {
+            	state = msg.getElementsByTagName('composing'); 
+            	if ( state.length > 0 ){
+               		return ' está compondo...';
+				} else {
+               		state =  msg.getElementsByTagName('paused');
+                	if ( state.length > 0 ){
+                  		return ' está parado...';
+					}
+				}
+			}
+		}
+		return '';
+	},
+
     
     /** Function: makeChat
@@ -729,5 +776,5 @@
    			 id_window		: "window_chat_area_" + barejid,
 			 width			: 387,
-			 height			: 365,
+			 height			: 375,
 			 top			: TrophyIM.posWindow.top,
 			 left			: TrophyIM.posWindow.left,
