Index: /trunk/jmessenger/js/trophyim.js
===================================================================
--- /trunk/jmessenger/js/trophyim.js	(revision 2971)
+++ /trunk/jmessenger/js/trophyim.js	(revision 2975)
@@ -308,5 +308,5 @@
                 TrophyIM.connection.rawInput	= TrophyIM.rawInput;
                 TrophyIM.connection.rawOutput	= TrophyIM.rawOutput;
-                Strophe.log = TrophyIM.log;
+                //Strophe.log = TrophyIM.log;
                 Strophe.info('Attempting Strophe attach.');
                 TrophyIM.connection.attach(xids[0], xids[1], xids[2], TrophyIM.onConnect);
@@ -397,5 +397,5 @@
         TrophyIM.connection.rawInput	= TrophyIM.rawInput;
         TrophyIM.connection.rawOutput	= TrophyIM.rawOutput;
-        Strophe.log 					= TrophyIM.log;
+        //Strophe.log 					= TrophyIM.log;
         
 		if ( arguments.length > 0 )
@@ -1042,5 +1042,5 @@
     	var divItenContact	 = null;
     	var spanShow		 = null;
-    	
+
     	if( ( divItenContact = document.getElementById('itenContact_' + jidTo )))
     	{	
@@ -1052,12 +1052,12 @@
     		
     		divItenContact.parentNode.removeChild(divItenContact);
-
-	    	// Remove Contact
-			var _id	= TrophyIM.connection.getUniqueId(); 	
-	    	var delContact	= $iq({type: 'set', id: _id})
-	    		delContact	= delContact.c('query').attrs({xmlns : 'jabber:iq:roster'});
-	    		delContact	= delContact.c('item').attrs({jid: jidTo, subscription:'remove'}).tree();
-
-	    	TrophyIM.connection.send( delContact );	    		
+    		
+        	// Remove Contact
+    		var _id	= TrophyIM.connection.getUniqueId(); 	
+        	var delContact	= $iq({type: 'set', id: _id})
+        		delContact	= delContact.c('query').attrs({xmlns : 'jabber:iq:roster'});
+        		delContact	= delContact.c('item').attrs({jid: jidTo, subscription:'remove'}).tree();
+
+        	TrophyIM.connection.send( delContact );	    		
     	}
     },
@@ -1240,11 +1240,4 @@
 								status 		= " (( " + i18n.CONTACT_ASK_FOR_AUTH  + " )) ";
 								statusColor	= "orange";
-								
-								if ( TrophyIM.controll.notificationNewUsers == 0 )
-								{
-									loadscript.enabledNotificationNewUsers();
-									TrophyIM.controll.notificationNewUsers++;
-								}
-								
 								break;
 	
@@ -1265,11 +1258,4 @@
 								status		= " (( " + i18n.ASK_FOR_AUTH_QUESTION  + " )) ";
 								statusColor	= "orange";	
-								
-								if ( TrophyIM.controll.notificationNewUsers == 0 )
-								{
-									loadscript.enabledNotificationNewUsers();
-									TrophyIM.controll.notificationNewUsers++;
-								}
-
 								break;
 								
@@ -1282,77 +1268,94 @@
 				};
 
-				var itensJid	= document.getElementById( "itenContact_" + objContact.contact.jid );
-
-				if( itensJid == null )
+				if( objContact.contact.subscription != "remove")
 				{
-					// Name
-					var nameContact = "";					
+					var itensJid	= document.getElementById( "itenContact_" + objContact.contact.jid );
 					
-					if ( objContact.contact.name ) 
-						nameContact = objContact.contact.name;
+					if( itensJid == null )
+					{
+						// Name
+						var nameContact = "";					
+						
+						if ( objContact.contact.name ) 
+							nameContact = objContact.contact.name;
+						else
+						{
+							nameContact = objContact.contact.jid;
+							nameContact = nameContact.substring(0, nameContact.indexOf('@'));
+						}
+						
+						// Get Presence
+						_presence(objContact);
+						
+						var paramsContact =
+						{
+							divDisplay		: "block", 
+							id		  		: 'itenContact_' + objContact.contact.jid ,
+							jid		  		: objContact.contact.jid,
+							nameContact 	: nameContact,
+							path_jabberit	: path_jabberit,
+							presence	  	: presence,
+							spanDisplay		: statusDisplay,
+							status	  		: status,
+							statusColor		: "black",
+							subscription	: objContact.contact.subscription,
+							resource		: _resource
+						}
+						
+						// Get Authorization
+						_subscription( objContact );
+						
+						if( group != "")
+						{
+							var _NodeChild		= element.firstChild;
+							
+							while( _NodeChild )
+							{
+								if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" )
+								{
+									if( _NodeChild.childNodes[0].childNodes[0].nodeValue === group )
+									{
+										_NodeChild.innerHTML += loadscript.parse("itens_group", "itensGroup.xsl", paramsContact);
+									}
+								}
+	
+								_NodeChild = _NodeChild.nextSibling;
+							}
+						}	
+					}
 					else
 					{
-						nameContact = objContact.contact.jid;
-						nameContact = nameContact.substring(0, nameContact.indexOf('@'));
-					}
-					
-					// Get Presence
-					_presence(objContact);
-					
-					var paramsContact =
-					{
-						divDisplay		: "block", 
-						id		  		: 'itenContact_' + objContact.contact.jid ,
-						jid		  		: objContact.contact.jid,
-						nameContact 	: nameContact,
-						path_jabberit	: path_jabberit,
-						presence	  	: presence,
-						spanDisplay		: statusDisplay,
-						status	  		: status,
-						statusColor		: "black",
-						subscription	: objContact.contact.subscription,
-						resource		: _resource
-					}
-					
-					// Get Authorization
-					_subscription( objContact );
-					
-					if( group != "")
-					{
-						var _NodeChild		= element.firstChild;
+						// Get Presence
+						_presence(objContact);
+	
+						var is_open = itensJid.parentNode.childNodes[0].style.backgroundImage;	
+							is_open = is_open.indexOf("arrow_down.gif");
+	
+						// Get Authorization
+						_subscription( objContact );
 						
-						while( _NodeChild )
+						// Set subscription
+						itensJid.setAttribute('subscription', objContact.contact.subscription );
+						
+						with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid ) )
 						{
-							if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" )
+							if( presence == "unavailable" && !showOffline )
 							{
-								if( _NodeChild.childNodes[0].childNodes[0].nodeValue === group )
+								style.display = "none";
+							}
+							else
+							{
+								if( is_open > 0 )
 								{
-									_NodeChild.innerHTML += loadscript.parse("itens_group", "itensGroup.xsl", paramsContact);
+									style.display	= statusDisplay;
+									style.color		= statusColor;
+									innerHTML		= status;
 								}
 							}
-
-							_NodeChild = _NodeChild.nextSibling;
 						}
-					}	
-				}
-				else
-				{
-					// Get Presence
-					_presence(objContact);
-
-					var is_open = itensJid.parentNode.childNodes[0].style.backgroundImage;	
-						is_open = is_open.indexOf("arrow_down.gif");
-					
-					// Get Authorization
-					_subscription( objContact );
-					
-					// Set subscription
-					itensJid.setAttribute('subscription', objContact.contact.subscription );
-					
-					with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid ) )
-					{
+						
 						if( presence == "unavailable" && !showOffline )
 						{
-							style.display = "none";
+							itensJid.style.display = "none";
 						}
 						else
@@ -1360,46 +1363,45 @@
 							if( is_open > 0 )
 							{
-								style.display	= statusDisplay;
-								style.color		= statusColor;
-								innerHTML		= status;
+								itensJid.style.display = "block";
+							}
+						}
+						
+						itensJid.style.background	= "url('"+path_jabberit+"templates/default/images/" + presence + ".gif') no-repeat center left";
+						
+					}
+	
+					// Contact OffLine
+					if( !objContact.presence && !showOffline )
+					{
+						if( objContact.contact.subscription != "remove" )
+						{
+							with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid ))
+							{
+								style.display 	= "none";
+							}
+		
+							with ( document.getElementById('itenContact_' + objContact.contact.jid ) )
+							{
+								style.display	= "none";
 							}
 						}
 					}
-					
-					if( presence == "unavailable" && !showOffline )
-					{
-						itensJid.style.display = "none";
-					}
-					else
-					{
-						if( is_open > 0 )
-						{
-							itensJid.style.display = "block";
-						}
-					}
-					
-					itensJid.style.background	= "url('"+path_jabberit+"templates/default/images/" + presence + ".gif') no-repeat center left";
 				}
-
-				// Contact OffLine
-				if( !objContact.presence && !showOffline )
+			}
+		};
+		
+		var flag = false;
+		
+		for( var i = 0 ; i < users.length; i++ )
+		{
+			if( TrophyIM.rosterObj.roster[users[i]].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) )
+			{
+				var _subscription = TrophyIM.rosterObj.roster[users[i]].contact.subscription;
+				
+				if( _subscription == "to" || _subscription == "not-in-roster")
 				{
-					with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid ))
-					{
-						style.display 	= "none";
-					}
-
-					with ( document.getElementById('itenContact_' + objContact.contact.jid ) )
-					{
-						style.display	= "none";
-					}
+					flag = true;
 				}
-			}
-		};
-		
-		for( var i = 0 ; i < users.length; i++ )
-		{
-			if( TrophyIM.rosterObj.roster[users[i]].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) )
-			{
+				
 				if( TrophyIM.rosterObj.roster[users[i]].contact.groups )
 				{
@@ -1423,4 +1425,18 @@
 				}
 			}
+		}
+		
+		if( flag )
+		{
+			if ( TrophyIM.controll.notificationNewUsers == 0 )
+			{
+				loadscript.enabledNotificationNewUsers();
+				TrophyIM.controll.notificationNewUsers++;
+			}
+		}
+		else
+		{
+			loadscript.disabledNotificationNewUsers();
+			TrophyIM.controll.notificationNewUsers = 0;
 		}
 	},
@@ -1682,7 +1698,11 @@
 	this.addContact = function(jid, subscription, name, groups )
 	{
-    	if( subscription !== "remove" )
+		if( subscription === "remove" || subscription == "remove")
         {
-    		var contact		= { jid:jid, subscription:subscription, name:name, groups:groups }
+			this.removeContact(jid);
+        }
+     	else
+    	{
+   			var contact		= { jid:jid, subscription:subscription, name:name, groups:groups }
 	        var jid_lower	= jid.toLowerCase();
 	
@@ -1707,8 +1727,4 @@
 				this.groups[groups[g]][jid_lower] = jid_lower;
 	        }
-        }
-     	else
-    	{
-    		this.removeContact(jid);
     	}
     }
Index: /trunk/jmessenger/js/jscode/loadIM.js
===================================================================
--- /trunk/jmessenger/js/jscode/loadIM.js	(revision 2969)
+++ /trunk/jmessenger/js/jscode/loadIM.js	(revision 2975)
@@ -57,5 +57,4 @@
 			var _element	= ( e.target ) ? e.target : e.srcElement;
 			var jid 	= arguments[1];
-			var index	= arguments[2];
 			var coord	= null;
 
@@ -79,5 +78,5 @@
 			{
 				if( e.button > 1 )
-					optionsItensContact( jid, index, coord );
+					optionsItensContact( jid, coord );
 				else
 					TrophyIM.rosterClick(jid);
@@ -86,5 +85,5 @@
 			{
 				if( e.which > 1 )
-					optionsItensContact( jid, index, coord );
+					optionsItensContact( jid, coord );
 				else
 					if( e.target.id )
@@ -281,5 +280,52 @@
 		}
 	}
-	
+
+	function disabledNotificationNewUsers()
+	{
+		var _notification	= getElement('notification_new_users_jabber') ;
+		var _statusJabber	= getElement('status_jabber_expresso');
+
+		_notification.style.display = 'none';
+		
+		_statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat";
+		
+		if( _timeOutNotification )
+			clearTimeout(_timeOutNotification );
+		
+		TrophyIM.controll.notificationNewUsers = 0;
+	}
+	
+	function enabledNotificationNewUsers()
+	{
+		var _notification	= getElement('notification_new_users_jabber') ;
+		var _statusJabber	= getElement('status_jabber_expresso');
+	
+		if( _notification && _statusJabber )
+		{	
+			if ( _notification.style.display == 'none' )
+			{
+				_notification.style.display = 'block';
+				
+				_statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/alert_mini.png') no-repeat";
+				
+				if( _timeOutNotification )
+					clearTimeout(_timeOutNotification );
+
+				_timeOutNotification = setTimeout( function(){ enabledNotificationNewUsers(); }, 2000 );
+			}
+			else
+			{
+				_notification.style.display = 'none';
+				
+				_statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat";
+				
+				if( _timeOutNotification )
+					clearTimeout(_timeOutNotification );
+
+				_timeOutNotification = setTimeout( function(){ enabledNotificationNewUsers(); }, 800 );
+			}
+		}
+	}
+
 	function fastMenu()
 	{
@@ -579,7 +625,6 @@
 		{
 			var jid 	= arguments[0];
-			var index	= arguments[1];
-			var coord	= arguments[2];
-			var element = getElement('itenContact_' + jid + '_' + index );
+			var coord	= arguments[1];
+			var element = getElement('itenContact_' + jid );
 			var action	= ( element.getAttribute("subscription") === "not-in-roster" ) ? "Adicionar" : "Autorizar"; 	
 			
@@ -588,8 +633,8 @@
 
 			var _options = [
-			                	[ action , 'loadscript.setAutorization(\''+jid+'\',\''+index+'\')'],
-			                	['Remover' , 'loadscript.removeContact(\''+jid+'\',\''+index+'\')'],
-			                	['Renomear' , 'loadscript.renameContact(\''+jid+'\',\''+index+'\')'],
-			                	['Trocar grupo' , 'loadscript.renameGroup(\''+jid+'\',\''+index+'\')']
+			                	[ action , 'loadscript.setAutorization(\''+jid+'\')'],
+			                	['Remover' , 'loadscript.removeContact(\''+jid+'\')'],
+			                	['Renomear' , 'loadscript.renameContact(\''+jid+'\')'],
+			                	['Trocar grupo' , 'loadscript.renameGroup(\''+jid+'\')']
 						   ];
 
@@ -709,11 +754,7 @@
 	}
 	
-	function removeContact(jid, index)
-	{
-		setTimeout(function()
-		{
-			TrophyIM.removeContact(jid, index);
-			
-		},300);
+	function removeContact( jid )
+	{
+		TrophyIM.removeContact( jid );
 	}
 	
@@ -742,7 +783,6 @@
 		{
 			var _jid	= arguments[0];
-			var _index	= arguments[1];
-			
-			TrophyIM.renameContact( _jid, _index );
+			
+			TrophyIM.renameContact( _jid );
 		}
 	}
@@ -753,7 +793,6 @@
 		{
 			var _jid 	= arguments[0];
-			var _index	= arguments[1];
-			
-			TrophyIM.renameGroup( _jid , _index );
+			
+			TrophyIM.renameGroup( _jid );
 		}
 	}
@@ -815,12 +854,20 @@
 	}
 	
-	function setAutorization(jidTo, indexTo)
-	{
-    	var divItenContact = null;
-    	
-    	if( ( divItenContact = getElement('itenContact_' + jidTo + '_' + indexTo )))
+	function setAutorization()
+	{
+		var divItenContact = null;
+		
+		if( arguments.length > 0 )
+		{
+			var jidTo = arguments[0];
+		
+			if( getElement('itenContact_' + jidTo) )
+				divItenContact = getElement('itenContact_' + jidTo );
+		}
+		
+    	if( divItenContact )
     	{	
     		var subscription = divItenContact.getAttribute('subscription');
-    		
+
     		switch(subscription)
     		{
@@ -845,5 +892,5 @@
 	    				if( ( _add = confirm("Deseja adicionar o usuario!")) )		
 	    				{
-	    					addUser.add( jidTo, indexTo );
+	    					addUser.add( jidTo );
 	    				}
 	    				
@@ -863,8 +910,15 @@
 					
 				default :
+					alert( "SEM PARAMETRO DEFINIDO : " + subscription );
 					
-					alert( "DEFAULT : " + subscription );
     		}
-    	}	
+    	}
+    	
+    	setTimeout(function()
+    	{
+			if( getElement('itenContactNotification_' + jidTo ) )
+				loadscript.removeElement( getElement('itenContactNotification_' + jidTo ) );
+    	},500);
+    
 	}
 	
@@ -1170,9 +1224,9 @@
 					var _user	= _users.createElement('user');
 					var _jid 	= _users.createElement('jid');
-					var _index	= _users.createElement('index');
+					var _status	= _users.createElement('status');
 					_jid.appendChild( _users.createTextNode(TrophyIM.rosterObj.roster[user].contact.jid) );
-					_index.appendChild( _users.createTextNode("0"));
+					_status.appendChild( _users.createTextNode( _subscription ) );
 					_user.appendChild( _jid );
-					_user.appendChild( _index );
+					_user.appendChild( _status );
 					_users.documentElement.appendChild( _user );
 				}
@@ -1206,41 +1260,5 @@
 		_winBuild( winNotification );
 	}
-	
-	function teste_new()
-	{
-		var _notification	= getElement('notification_new_users_jabber') ;
-		var _statusJabber	= getElement('status_jabber_expresso');
-	
-		if( _notification && _statusJabber )
-		{	
-			if ( _notification.style.display == 'none' )
-			{
-				_notification.style.display = 'block';
-				
-				_statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/alert_mini.png') no-repeat";
-				
-				if( _timeOutNotification )
-					clearTimeout(_timeOutNotification );
-
-				_timeOutNotification = setTimeout( function(){ teste_new(); }, 2000 );
-			}
-			else
-			{
-				_notification.style.display = 'none';
-				
-				_statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat";
-				
-				if( _timeOutNotification )
-					clearTimeout(_timeOutNotification );
-
-				_timeOutNotification = setTimeout( function(){ teste_new(); }, 800 );
-			}
-		}
-	}
-	
-	
-	loadIM.prototype.teste_new = teste_new;
-	
-	
+
 	function loadIM()
 	{
@@ -1320,4 +1338,6 @@
 	loadIM.prototype.clrAllContacts		= clrAllContacts;
 	loadIM.prototype.configEvents		= configEvents;
+	loadIM.prototype.disabledNotificationNewUsers	= disabledNotificationNewUsers;
+	loadIM.prototype.enabledNotificationNewUsers	= enabledNotificationNewUsers;	
 	loadIM.prototype.getIsIE			= getIsIE;
 	loadIM.prototype.getPhotoUser		= getPhotoUser;
