Index: /trunk/jabberit_messenger/jmessenger/js/trophyim.js
===================================================================
--- /trunk/jabberit_messenger/jmessenger/js/trophyim.js	(revision 3091)
+++ /trunk/jabberit_messenger/jmessenger/js/trophyim.js	(revision 3092)
@@ -670,7 +670,6 @@
                 		nameChatRoom = Strophe.getBareJidFromJid(nameChatRoom);
 
-                	var nickName = xquery[i].firstChild.getAttribute('jid');
-            			nickName = Strophe.getBareJidFromJid( nickName );
-            			nickName = nickName.substring(0, nickName.indexOf('@'));
+            		var nickName = xquery[i].parentNode.getAttribute('from');
+            			nickName = Strophe.getResourceFromJid(nickName);
                 	
                 	var type = xquery[i].parentNode.getAttribute('type') ? xquery[i].parentNode.getAttribute('type') : 'available' ;
@@ -678,6 +677,9 @@
                 	var show = ( xquery[i].parentNode.firstChild.firstChild != null ) ? xquery[i].parentNode.firstChild.firstChild.nodeValue : type ;
                 	
-                	if ( Strophe.getBareJidFromJid( xquery[i].firstChild.getAttribute('jid') ) == Strophe.getBareJidFromJid( TrophyIM.connection.jid ) )
-                		show = loadscript.getStatusUserIM();
+                	if( xquery[i].firstChild.getAttribute('jid') )
+                	{
+	                	if ( Strophe.getBareJidFromJid( xquery[i].firstChild.getAttribute('jid') ) == Strophe.getBareJidFromJid( TrophyIM.connection.jid ) )
+	                		show = loadscript.getStatusUserIM();
+                	}
                 	
                 	var _UserChatRoom = document.createElement("div");
@@ -688,5 +690,5 @@
                 	var nodeUser = document.getElementById( nameChatRoom + "_UserChatRoom__" + xquery[i].firstChild.getAttribute('jid'));		
                 		
-                	if( nodeUser == null )
+                	if( nodeUser == null && xquery[i].firstChild.getAttribute('jid') )
                 	{
                 		nameChatRoom = document.getElementById(nameChatRoom + '__roomChat__participants');
@@ -697,11 +699,11 @@
                 		if( type == 'unavailable' )
                 		{
-                			nodeUser.parentNode.removeChild( nodeUser );
+                			var nodeUser = document.getElementById( nameChatRoom + "_UserChatRoom__" + xquery[i].parentNode.getAttribute('to'));
+                				nodeUser.parentNode.removeChild( nodeUser );
                 		}
                 		else if( show )
                 		{
                 			var _UserChatRoom = document.getElementById( nameChatRoom + "_UserChatRoom__" + xquery[i].firstChild.getAttribute('jid') )
-                			
-                			_UserChatRoom.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/" + show + ".gif')no-repeat center left");	
+                				_UserChatRoom.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/" + show + ".gif')no-repeat center left");	
                 		}
                 	}
@@ -1233,6 +1235,6 @@
     joinChatRoom : function( roomName )
     {
-    	var presence = $pres({from: TrophyIM.connection.jid, to: roomName}).c("x",{xmlns: Strophe.NS.MUC});
-    	
+        var presence = $pres({from: TrophyIM.connection.jid, to: roomName}).c("x",{xmlns: Strophe.NS.MUC});
+        
 		TrophyIM.connection.send( presence );
     },
@@ -1243,10 +1245,13 @@
      */
     
-    leaveChatRoom : function( roomName)
+    leaveChatRoom : function( roomName )
     {
-    	var room_nick = roomName;        
-        var presenceid = TrophyIM.connection.getUniqueId();
-        //var presence = $pres( {type: "unavailable", id: presenceid, to: room_nick} ).c("x",{ xmlns: Strophe.NS.MUC } );
-        //TrophyIM.connection.send( presence );
+    	var room_nick	= roomName + "/USUARIO_DE_TESTE"; 
+    	
+        var presenceid	= TrophyIM.connection.getUniqueId();
+        
+        var presence	= $pres( {type: "unavailable", id: presenceid, from: TrophyIM.connection.jid, to: room_nick} ).c("x",{xmlns: Strophe.NS.MUC});
+        
+        TrophyIM.connection.send( presence );        
     },
     
Index: /trunk/jabberit_messenger/jmessenger/js/jscode/loadIM.js
===================================================================
--- /trunk/jabberit_messenger/jmessenger/js/jscode/loadIM.js	(revision 3091)
+++ /trunk/jabberit_messenger/jmessenger/js/jscode/loadIM.js	(revision 3092)
@@ -1413,4 +1413,6 @@
 	    }
 		
+	    
+	    
 	    var room_nick = test_append_nick( jidRoom, "USUARIO_DE_TESTE" );
 	    
