Index: /trunk/jabberit_messenger/templates/celepar/css/common.css
===================================================================
--- /trunk/jabberit_messenger/templates/celepar/css/common.css	(revision 417)
+++ /trunk/jabberit_messenger/templates/celepar/css/common.css	(revision 459)
@@ -65,4 +65,5 @@
 div.add_action
 {
+	padding-top: 30px;
 	padding-bottom: 30px;
 	margin-left: 83px;
Index: /trunk/jabberit_messenger/xsl/add_user.xsl
===================================================================
--- /trunk/jabberit_messenger/xsl/add_user.xsl	(revision 382)
+++ /trunk/jabberit_messenger/xsl/add_user.xsl	(revision 459)
@@ -32,7 +32,8 @@
 			<br/><br style="line-height:4px"/>
 			<span><xsl:value-of select="$lang5"/> :</span>
-			<input id="im_group" type="text" size="50" maxlength="50" class="add_user" onclick="this.select();"/>
+			<input id="im_group" type="text" size="50" maxlength="50" selectBoxOptions="" onclick="this.select();"/>
+			<span id="__span_load_im_group" style="background-color:#cc4444;color:white;display:none;width:auto;margin:2 0 5 83px;">Carregando Grupos .....</span>			
 		</div>
-
+		
 		<div class="add_action">
 			<span><xsl:value-of select="$lang6"/></span>
Index: /trunk/jabberit_messenger/xsl/list_ldap_contacts.xsl
===================================================================
--- /trunk/jabberit_messenger/xsl/list_ldap_contacts.xsl	(revision 382)
+++ /trunk/jabberit_messenger/xsl/list_ldap_contacts.xsl	(revision 459)
@@ -24,4 +24,5 @@
 			<xsl:sort select="cn"/>
 			<span value="{mail};{uid}" photo="{photo}">
+				<span id="{mail};{uid}" style="display:none;"><xsl:value-of select="cn" /></span>
 				<b><xsl:value-of select="name(..)"/></b>
 				<br/><xsl:value-of select="cn" />
Index: /trunk/jabberit_messenger/languages/jeti_pt_BR.properties
===================================================================
--- /trunk/jabberit_messenger/languages/jeti_pt_BR.properties	(revision 417)
+++ /trunk/jabberit_messenger/languages/jeti_pt_BR.properties	(revision 459)
@@ -456,9 +456,9 @@
 main.popup.{0}_was_last_seen_on_{1}={0} foi visto em {1}
 main.popup.Add_{0}_to=Adicionar {0} para \:
-main.popup.Add_to_roster=Adicionar para roster
+main.popup.Add_to_roster=Adicionar
 main.popup.Change_{0}_from_{1}_to=Trocar {0} para {1} to \:
 main.popup.Chat_with=Bate-papo com
 main.popup.Chat_with_who?=Bate-papo com quem?
-main.popup.Deny_subscription=Negar registrar
+main.popup.Deny_subscription=Negar
 main.popup.Enter_the_text_to_search_for=Entre o texto de pesquisa para 
 main.popup.Find=Procurar
Index: /trunk/jabberit_messenger/inc/controller.xml
===================================================================
--- /trunk/jabberit_messenger/inc/controller.xml	(revision 439)
+++ /trunk/jabberit_messenger/inc/controller.xml	(revision 459)
@@ -17,5 +17,5 @@
 	<controller-sections>
 		<css></css>
-		<js path="/var/www/expresso/jabberit_messenger/js" suffix=".js" debug="true">
+		<js path="/var/www/expresso/jabberit_messenger/js" suffix=".js" debug="false">
 			<item ref="connector" js="connector" />
 			<item ref="xtools" js="xtools" />
@@ -26,4 +26,5 @@
 			<item ref="images" js="images" />
 			<item ref="show_hidden" js="show_hidden" />
+			<item ref="editSelect" js="editSelect" />
 			<item ref="setup" js="setup" path="/var/www/expresso/jabberit_messenger/templates/celepar/"/>
 		</js>
@@ -35,4 +36,5 @@
 			<item ref="ldap_im" alias="photo_ldap" class="ldap_im" method="photo_ldap" prefix="class." suffix=".inc.php"/>
 			<item ref="ujabber" alias="AddNewContact" class="ujabber" method="AddNewContact" prefix="class." suffix=".inc.php"/>
+			<item ref="ujabber" alias="getGroupsJabber" class="ujabber" method="getGroupsJabber" prefix="class." suffix=".inc.php"/>			
 			<item ref="FileDefine" alias="getParams" class="FileDefine" method="getParams" prefix="class." suffix=".inc.php"/>			
 		</php>
Index: /trunk/jabberit_messenger/inc/class.jabber.inc.php
===================================================================
--- /trunk/jabberit_messenger/inc/class.jabber.inc.php	(revision 382)
+++ /trunk/jabberit_messenger/inc/class.jabber.inc.php	(revision 459)
@@ -103,5 +103,5 @@
 			$this->SendPacket("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");
 
-			sleep(2);
+			sleep(1);
 
 			if ($this->_check_connected())
@@ -304,5 +304,4 @@
 
 
-
 	function StripJID($jid = NULL)
 	{
@@ -310,5 +309,4 @@
 		return ($temp[1] != "") ? $temp[1] : $jid;
 	}
-
 
 
@@ -383,6 +381,4 @@
 		}
 	}
-
-
 
 	function SendError($to, $id = NULL, $error_number, $error_message = NULL)
@@ -399,5 +395,37 @@
 	}
 
-
+	function RosterGroups()
+	{
+		$roster_request_id = "roster_" . time();
+		$incoming_array = $this->SendIq(NULL, 'get', $roster_request_id, "jabber:iq:roster");
+		$groups = array();
+
+		if (is_array($incoming_array))
+		{
+			if ($incoming_array['iq']['@']['type'] == 'result'
+				&& $incoming_array['iq']['@']['id'] == $roster_request_id
+				&& $incoming_array['iq']['#']['query']['0']['@']['xmlns'] == "jabber:iq:roster")
+			{
+				$number_of_contacts = count($incoming_array['iq']['#']['query'][0]['#']['item']);
+				$this->roster = array();
+
+				for ($a = 0; $a < $number_of_contacts; $a++)
+					 $groups[] = $incoming_array['iq']['#']['query'][0]['#']['item'][$a]['#']['group'][0]['#'];
+
+				return $groups;
+			}
+			else
+			{
+				$this->AddToLog("ERROR: RosterGroups() #1");
+				return FALSE;
+			}
+		}
+		else
+		{
+			$this->AddToLog("ERROR: RosterGroups() #2");
+			return FALSE;
+		}
+
+	}
 
 	function RosterUpdate()
@@ -990,5 +1018,5 @@
 
 		$this->SendPacket("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\n");
-		sleep(2);
+		sleep(1);
 		$incoming_array = $this->_listen_incoming();
 
@@ -1018,5 +1046,5 @@
 		$this->SendPacket("<?xml version='1.0' encoding='UTF-8' ?" . ">\n");
 		$this->SendPacket("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");
-		sleep(2);
+		sleep(1);
 
 		if (!$this->_check_connected())
@@ -1753,6 +1781,4 @@
 	}
 
-
-
 	function AddPacketDetails($string, $value = NULL)
 	{
@@ -1777,6 +1803,4 @@
 		eval("\$this->nodes$node = \"" . htmlspecialchars($value) . "\";");
 	}
-
-
 
 	function BuildPacket($array = NULL)
Index: /trunk/jabberit_messenger/inc/login.php
===================================================================
--- /trunk/jabberit_messenger/inc/login.php	(revision 417)
+++ /trunk/jabberit_messenger/inc/login.php	(revision 459)
@@ -17,6 +17,6 @@
     {
 		$path = $_SESSION['phpgw_info']['jabberit_messenger']['webserver_url'];
-		$SERVER_EXPRESSO = gethostbyaddr($_SERVER['SERVER_ADDR']) . $path;
-
+		$SERVER_EXPRESSO = $_SERVER['HTTP_HOST'] . $path;
+		
 		$template = new Template('templates/celepar');
 		$template->set_var("path", $path);
Index: /trunk/jabberit_messenger/inc/jabberit_acl.inc.php
===================================================================
--- /trunk/jabberit_messenger/inc/jabberit_acl.inc.php	(revision 423)
+++ /trunk/jabberit_messenger/inc/jabberit_acl.inc.php	(revision 459)
@@ -57,4 +57,5 @@
 				'show_hidden',
 				'load',
+				'editSelect'
 				);
 
@@ -73,4 +74,5 @@
 		print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/celepar/css/window.css">';
 		print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/celepar/css/common.css">';
+		print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/celepar/css/selectEditStyle.css">';		
 
 		break;
Index: /trunk/jabberit_messenger/inc/class.ujabber.inc.php
===================================================================
--- /trunk/jabberit_messenger/inc/class.ujabber.inc.php	(revision 417)
+++ /trunk/jabberit_messenger/inc/class.ujabber.inc.php	(revision 459)
@@ -28,5 +28,5 @@
 	}	
 	
-	function connect()
+	private final function connect()
 	{
 		if(!$this->jabber->Connect())
@@ -44,5 +44,5 @@
 	}
 	
-	function disconnect()
+	private final function disconnect()
 	{
 		
@@ -50,5 +50,5 @@
 	}
 	
-	function AddNewContact($pNewUser)
+	public final function AddNewContact($pNewUser)
 	{
 		$this->connect();
@@ -60,4 +60,7 @@
 		if($this->jabber->RosterAddUser($jid,$id,$name,$group))
 		{
+			$_SESSION['phpgw_info']['jabberit_messenger']['groups_user'][] = $group;
+			$_SESSION['phpgw_info']['jabberit_messenger']['groups_user'] = array_unique($_SESSION['phpgw_info']['jabberit_messenger']['groups_user']);
+			
 			if($this->jabber->Subscribe($jid))
 				return true;
@@ -70,4 +73,32 @@
 		$this->disconnect();
 	}
+	
+	public final function getGroupsJabber()
+	{
+		$groups = array();
+		$return = '';
+		
+		if(!isset($_SESSION['phpgw_info']['jabberit_messenger']['groups_user']))
+		{		
+			$this->connect();
+			$groups = $this->jabber->RosterGroups();
+			$this->disconnect();
+			
+			$groups = array_unique($groups);
+			$_SESSION['phpgw_info']['jabberit_messenger']['groups_user'] = $groups;
+			
+		}else
+			$groups = $_SESSION['phpgw_info']['jabberit_messenger']['groups_user'];
+
+		natcasesort($groups);
+	
+		foreach($groups as $tmp)
+			$return .= $tmp . ";";
+		
+		if( trim($return) != '' )
+			$return = substr( $return, 0, strlen($return)-1 );
+	
+		return $return;
+	}
 }
-?>	
+?>
Index: /trunk/jabberit_messenger/inc/Controller.class.php
===================================================================
--- /trunk/jabberit_messenger/inc/Controller.class.php	(revision 417)
+++ /trunk/jabberit_messenger/inc/Controller.class.php	(revision 459)
@@ -164,8 +164,8 @@
 		$obj = new ReflectionClass($class);
 
-		if ( $pRequest['classCostructor'] )
+		if ( $pRequest['classConstructor'] )
 		{
-			$obj = $obj->newInstance($pRequest['classCostructor']);
-			unset($pRequest['classCostructor']);
+			$obj = $obj->newInstance($pRequest['classConstructor']);
+			unset($pRequest['classConstructor']);
 		}
 		else
Index: /trunk/jabberit_messenger/js/ldap.js
===================================================================
--- /trunk/jabberit_messenger/js/ldap.js	(revision 382)
+++ /trunk/jabberit_messenger/js/ldap.js	(revision 459)
@@ -39,5 +39,4 @@
 				_status.innerHTML = '';
 				_name.previousSibling.style.color = "#000";
-				_group.previousSibling.style.color = "#000";
 
 				if ( !_jid )
@@ -64,5 +63,4 @@
 						if ( !(_group.value) )
 						{
-							_group.previousSibling.style.color = "#f00";
 							_status.innerHTML += '<br/>** Informe um "GRUPO" para o contato.';
 						}
@@ -77,4 +75,5 @@
 							_uid = _jid.substr(0, (_jid.indexOf('@') - 1));
 
+						
 						_name.parentNode.style.display = 'none';
 						_name.parentNode.nextSibling.style.display = 'none';
@@ -86,4 +85,5 @@
 							{
 								_status.innerHTML = '<br/>Contato adicionado !<br/>';
+								setTimeout('cleanStatusAddContactIM();',2500);
 							},
 							'uid='+_uid+'&name='+_name.value+'&group='+_group.value
@@ -92,4 +92,5 @@
 						_name.value = '';
 						_group.value = '';
+						
 					}
 				}
@@ -158,21 +159,37 @@
 							return false;
 
+						document.getElementById('__span_load_im_group').style.display = 'block';
 						document.getElementById('im_jid').value = m.substr(0, m.indexOf(';'));
 						document.getElementById('im_uid').value = m.substr((m.indexOf(';')+1));
 
 						var _name = document.getElementById('im_name');
-						_name.value = m.substr(0, m.indexOf('@'));
-						_name.previousSibling.style.color = "#000";
-
-						_name.parentNode.style.display = 'block';
-						_name.parentNode.nextSibling.style.display = 'block';
-						_name.parentNode.nextSibling.nextSibling.innerHTML = '';
-
-						var _group = document.getElementById('im_group');
-						_group.value = '';
-						_group.focus();
+							_name.value = document.getElementById(m).innerHTML;							
+							_name.previousSibling.style.color = "#000";
+
+							_name.parentNode.style.display = 'block';
+							_name.parentNode.nextSibling.style.display = 'block';
+							_name.parentNode.nextSibling.nextSibling.innerHTML = '';
+						
+						_conn.go('$this.ujabber.getGroupsJabber',
+								function(data)
+								{
+									if( data = data.replace(/(^\s*)|(\s*$)/g,''))
+									{
+										var _group = document.getElementById('im_group');
+										var _groupOptions = '';
+
+										_group.setAttribute('selectBoxOptions', data);
+										if( document.getElementById('selectBox0') == null)
+											editS.create(document.getElementById('im_group'));
+									}
+									document.getElementById('__span_load_im_group').style.display = 'none';
+								});
+
+						document.getElementById('im_group').value = '';
+						document.getElementById('im_group').focus();
 					}
 
 					var _member = _target.firstChild;
+					
 					while ( _member )
 					{
@@ -205,2 +222,7 @@
 }
 )();
+
+function cleanStatusAddContactIM()
+{
+	document.getElementById('im_status_add').innerHTML = '';
+}
