Index: /trunk/jabberit_messenger/plugins.xml
===================================================================
--- /trunk/jabberit_messenger/plugins.xml	(revision 390)
+++ /trunk/jabberit_messenger/plugins.xml	(revision 697)
@@ -9,46 +9,4 @@
     </plugin>
     <plugin>
-        <name>groupchat</name>
-        <description>groupchat.groupchat</description>
-        <version>0.2</version>
-        <min_jeti_version>0.5.1</min_jeti_version>
-        
-    </plugin>
-    <plugin>
-        <name>keyboardflash</name>
-        <description>keyboardflash.Flashes_the_scrollock_led_on_new_message</description>
-        <version>0.2</version>
-        <min_jeti_version>0.5</min_jeti_version>
-        <parent>Notifiers</parent>
-    </plugin>
-    <plugin>
-        <name>metaltheme</name>
-        <description>metaltheme.Change_Colors</description>
-        <version>0.1</version>
-        <min_jeti_version>0.5</min_jeti_version>
-        <parent>Skins</parent>
-    </plugin>
-    <plugin>
-        <name>sound</name>
-        <description>sound.Plays_a_sound_on_new_message_or_person_available</description>
-        <version>0.1</version>
-        <min_jeti_version>0.5.1</min_jeti_version>
-        <parent>Notifiers</parent>
-    </plugin>
-    <plugin>
-        <name>titlescroller</name>
-        <description>titlescroller.Scrolls_the_window_title_of_chat_windows_on_new_messages</description>
-        <version>0.1</version>
-        <min_jeti_version>0.5.3</min_jeti_version>
-        <parent>Notifiers</parent>
-    </plugin>
-    <plugin>
-        <name>vcard</name>
-        <description>vcard.shows_contact_details</description>
-        <version>0.1</version>
-        <min_jeti_version>0.6</min_jeti_version>
-        
-    </plugin>
-    <plugin>
         <name>xhtml</name>
         <description>xhtml.Formats_messages</description>
Index: /trunk/jabberit_messenger/default.xml
===================================================================
--- /trunk/jabberit_messenger/default.xml	(revision 390)
+++ /trunk/jabberit_messenger/default.xml	(revision 697)
@@ -1,4 +1,8 @@
 <?xml version='1.0'?>
 <preferences>
+	<!-- File Transfer -->
+	<preference key="filetransfer.closeOnComplete" value="true"/>
+	<preference key="filetransfer.useLocalIP" value="true"/>
+	
 	<!--Main Jeti menu-->
 	<preference key="jeti.country" value="BR"/>
@@ -36,9 +40,5 @@
 	<plugins>
 		<plugin type="plugins" name="xhtml" enabled="true" transport="0.3"/>
-		<plugin type="plugins" name="filetransfer" enabled="false" transport="0.1"/>
-		<plugin type="plugins" name="keyboardflash" enabled="false" transport="0.2"/>
-		<plugin type="plugins" name="sound" enabled="false" transport="0.1"/>
-		<plugin type="plugins" name="titlescroller" enabled="false" transport="0.1"/>
-		<plugin type="plugins" name="vcard" enabled="false" transport="0.1"/>
-    	</plugins>
+		<plugin type="plugins" name="filetransfer" enabled="true" transport="0.1"/>
+   	</plugins>
 </preferences>
Index: /trunk/jabberit_messenger/index.php
===================================================================
--- /trunk/jabberit_messenger/index.php	(revision 551)
+++ /trunk/jabberit_messenger/index.php	(revision 697)
@@ -7,5 +7,5 @@
 
 	$GLOBALS['phpgw_info']['flags']['currentapp'] = 'jabberit_messenger';
-	$GLOBALS['phpgw_info']['flags']['jabberit_version'] = '0.7.10';
+	$GLOBALS['phpgw_info']['flags']['jabberit_version'] = '0.7.11';
 
 	include("../header.inc.php");
@@ -18,5 +18,5 @@
 	$template->pfp('out','index');
 
-	require_once "inc/jabberit_acl.inc.php";
+	$GLOBALS['phpgw']->common->phpgw_footer();
 
 ?>
Index: /trunk/jabberit_messenger/templates/default/confGroupsLocked.tpl
===================================================================
--- /trunk/jabberit_messenger/templates/default/confGroupsLocked.tpl	(revision 697)
+++ /trunk/jabberit_messenger/templates/default/confGroupsLocked.tpl	(revision 697)
@@ -0,0 +1,59 @@
+<!-- BEGIN confGroups -->
+<script type="text/javascript" src="jabberit_messenger/js/connector.js"></script>
+<script type="text/javascript" src="jabberit_messenger/js/xtools.js"></script>
+<script type="text/javascript" src="jabberit_messenger/controller.php?act=j.setup"></script>
+<form>
+<table align="center" width="60%" cellspacing="2" style="border: 1px solid #000000;">
+	<tr class="th">
+		<td colspan="2">&nbsp;<b>{lang_Informe_as_Organizacoes}</b></td>
+	</tr>
+	<tr class="row_on">	
+		<td colspan="2" style="padding:5 0 5 0px;">
+			&nbsp;<b>&nbsp;{lang_Nome_Grupo}&nbsp;:</b><span style="font-size:12px;color:red;">&nbsp;{value_Name_Group}&nbsp;</span>
+		</td>
+	</tr>
+	<tr class="row_on">
+		<td colspan="2" style="padding:5 0 5 0px;">&nbsp;<b>&nbsp;{lang_Cadastrar_Organizacao}&nbsp;</b></td>
+	</tr>
+	<tr class="row_on">
+		<td colspan="2">
+			<table>
+				<tr>
+					<td colspan="3">
+						<label>{lang_Organization}</label>&nbsp;.:&nbsp;
+						<select id="organizations_ldap_jabberit">
+				   			{value_organizations_ldap}
+				   		</select>
+					</td>
+					<td class="row_on" style="border:1px solid #00000">
+					  <input type="button" name="add" value="{lang_save}" {value_flag} onclick="constructScript.setOrgFgroups();">
+					</td>
+				</tr>
+			</table>
+		</td>
+	</tr>
+	<tr class="row_on">
+		<td colspan="2" style="padding:5 0 5 0px;">&nbsp;<b>{lang_Organizacoes_cadastradas_para_grupo}</b></td>
+	</tr>
+	<tr>
+		<td colspan="2">
+			<table id="tableOrganizationsEnabledGroupsJabberit" cellspacing="2" style="width:100%">
+				<tr class='th'>
+					<td align="left" class="row_on">{lang_Organization}</td>
+					<td align="left" class="row_on" style="width:30% !important">{lang_Delete}</td>					
+				</tr>
+				{value_Groups_Organizations}
+			</table>
+		</td>
+	</tr>
+	<tr>
+		<td colspan="2" align="center">
+		  <input type="button" name="back" value="{lang_Back}" onClick="document.location.href='{action_url}'">
+		  <input type="hidden" id="nameGroup" value="{value_Name_Group}"/>
+		  <input type="hidden" id="gidNumber" value="{value_gidNumber}"/>
+		  <br/>
+		</td>
+	</tr>
+</table>
+</form>
+<!-- END confGroups -->
Index: /trunk/jabberit_messenger/templates/default/jabberIM_IE.tpl
===================================================================
--- /trunk/jabberit_messenger/templates/default/jabberIM_IE.tpl	(revision 622)
+++ /trunk/jabberit_messenger/templates/default/jabberIM_IE.tpl	(revision 697)
@@ -6,9 +6,8 @@
 		
 		// Pop-up or Layer
-
 		if( window.parent.loadscript )
-			var elementStatus = window.parent.loadscript.getElement();
+			var element = window.parent.loadscript;
 		else
-			var elementStatus = self.opener.parent.loadscript.getElement();
+			var element = self.opener.parent.loadscript;
 
 		changestatus.setpath('{path}');
@@ -16,6 +15,12 @@
 		function getArgumentsApplet()
 		{
-			if(( arguments.length > 0 ) && (arguments[0] == "getArgumentsApplet"))
-				changestatus.get(arguments[1], elementStatus);
+			if( arguments.length > 0 )
+			{
+			 	if( arguments[0] == "getArgumentsApplet" )
+					changestatus.get(arguments[1], element.getElement());
+
+				if( arguments[0] == "cleanStatus" )
+					element.autoStatusIM();
+			}
 		}
 
@@ -31,5 +36,5 @@
 		<object classid='clsid:8AD9C840-044E-11D1-B3E9-00805F499D93' width='250px' height='400px'>
 			<param name='name' value='jeti'>
-			<param name='archive' value='{path}applet.jar?{file0},{path}plugins/groupchat.jar?{file1},{path}plugins/sound.jar?{file2},{path}plugins/xhtml.jar?{file3}'>
+			<param name='archive' value='{java_files}'>
 			<param name='code' value='nu.fw.jeti.applet.Jeti.class'>
 			<param name='codebase' value='.'>	
Index: /trunk/jabberit_messenger/templates/default/jabberIM.tpl
===================================================================
--- /trunk/jabberit_messenger/templates/default/jabberIM.tpl	(revision 622)
+++ /trunk/jabberit_messenger/templates/default/jabberIM.tpl	(revision 697)
@@ -6,9 +6,8 @@
 		
 		// Pop-up or Layer
-		
 		if( window.parent.loadscript )
-			var elementStatus = window.parent.loadscript.getElement();
+			var element = window.parent.loadscript;
 		else
-			var elementStatus = self.opener.parent.loadscript.getElement();
+			var element = self.opener.parent.loadscript;
 
 		changestatus.setpath('{path}');
@@ -16,6 +15,12 @@
 		function getArgumentsApplet()
 		{
-			if(( arguments.length > 0 ) && (arguments[0] == "getArgumentsApplet"))
-				changestatus.get(arguments[1], elementStatus);
+			if( arguments.length > 0 )
+			{ 
+				if( arguments[0] == "getArgumentsApplet" )
+					changestatus.get(arguments[1], element.getElement());
+				
+				if( arguments[0] == "cleanStatus" )
+					element.autoStatusIM();
+			}
 		}
 		
@@ -29,5 +34,5 @@
 	</head>
 	<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
-		<applet name='jeti' archive='{path}applet.jar?{file0},{path}plugins/groupchat.jar?{file1},{path}plugins/sound.jar?{file2},{path}plugins/xhtml.jar?{file3}' code='nu.fw.jeti.applet.Jeti.class' codebase='.' width='220px' height='400px' MAYSCRIPT>
+		<applet name='jeti' archive='{java_files}' code='nu.fw.jeti.applet.Jeti.class' codebase='.' width='220px' height='400px' MAYSCRIPT>
 			<param name='SERVER' value='{value_server}'>
 			<param name='HOST' value='{value_host}'>
Index: /trunk/jabberit_messenger/templates/default/enabled_ou_groups.tpl
===================================================================
--- /trunk/jabberit_messenger/templates/default/enabled_ou_groups.tpl	(revision 697)
+++ /trunk/jabberit_messenger/templates/default/enabled_ou_groups.tpl	(revision 697)
@@ -0,0 +1,21 @@
+<!-- BEGIN enabled_ous -->
+<script type="text/javascript" src="jabberit_messenger/js/connector.js"></script>
+<script type="text/javascript" src="jabberit_messenger/js/xtools.js"></script>
+<script type="text/javascript" src="jabberit_messenger/controller.php?act=j.glocked"></script>
+	<form>
+		<table align="center" width="90%" cellspacing="2" style="border:1px solid #000;margin-top:20px;">
+			<tr class="th">
+				<td width="30%"><b>Grupos<b/></td>
+				<td width="55%"><b>Organizações Liberadas<b/></td>
+				<td width="5%" align="center"><b>Editar</b></td>
+			</tr>
+			{list_groups}
+		</table>
+		<br/>
+		<table align="center" width="90%" cellspacing="2">
+			<tr>
+				<td><input type="button" value="{lang_back}" onClick="document.location.href='{action_url}'"></td>
+			</tr>
+		</table>
+	</form>
+<!-- END enabled_ous -->
Index: /trunk/jabberit_messenger/templates/default/setup.js
===================================================================
--- /trunk/jabberit_messenger/templates/default/setup.js	(revision 562)
+++ /trunk/jabberit_messenger/templates/default/setup.js	(revision 697)
@@ -239,4 +239,61 @@
 	}
 
+	function setOrganizationsForGroups()
+	{
+		var elementSel = document.getElementById('organizations_ldap_jabberit');
+		var Organization = "";
+		
+		for(var i = 0; i < elementSel.options.length; i++)
+		{
+			if( elementSel.options[i].selected == true && elementSel.options[i].value != "-1" )
+				Organization = elementSel.options[i].value;
+		}
+		
+		if( Organization )
+		{
+		
+			var group = document.getElementById('nameGroup').value;
+			var gidNumber = document.getElementById('gidNumber').value;
+	
+			
+			_conn.go("$this.db_im.setOuGroupsLocked",
+					 function(data)
+					 {
+	 					if ( data )
+						{
+							var _params = {
+								'lang1': jabberitGetLang('Organization'),
+								'lang2': jabberitGetLang('Delete')
+							};
+							
+							var Table = document.getElementById('tableOrganizationsEnabledGroupsJabberit');
+							Table.parentNode.innerHTML = _xtools.parse( data, 'tableOrganizationsEnabledGroupsJabberit.xsl', _params);
+						}
+					 }, 	
+					 "group="+group+"&gidnumber="+gidNumber+"&ou="+Organization);
+		}
+	}
+
+	function removeOrgGroupsLocked()
+	{
+		if( arguments.length > 0 )
+		{
+			var element = document.getElementById(arguments[0]);
+			var org = arguments[0];
+			var group = document.getElementById('nameGroup').value;
+			var gidNumber = document.getElementById('gidNumber').value;
+			
+			
+			_conn.go("$this.db_im.removeOuGroupsLocked",
+					function(data)
+					{
+						if( data )
+							element.parentNode.removeChild(element);
+					},
+					"group="+group+"&gidnumber="+gidNumber+"&ou="+org);
+		}
+	}
+
+
 	function removeOrgLdapAttributes()
 	{
@@ -278,5 +335,9 @@
 	constructScript.prototype.removePartExternal = removeParticipantsExternal;
 	constructScript.prototype.removeOrg = removeOrgLdapAttributes;
+	constructScript.prototype.removeOrgGroupsLocked = removeOrgGroupsLocked;
+	constructScript.prototype.setOrgFgroups = setOrganizationsForGroups;
+	constructScript.prototype.setPartExternal = setParticipantsExternal;	
 	constructScript.prototype.sendf = sendf;
+	
 	window.constructScript = new constructScript;
 }
Index: /trunk/jabberit_messenger/setup/phpgw_pt-br.lang
===================================================================
--- /trunk/jabberit_messenger/setup/phpgw_pt-br.lang	(revision 636)
+++ /trunk/jabberit_messenger/setup/phpgw_pt-br.lang	(revision 697)
@@ -16,5 +16,5 @@
 available	jabberit_messenger	pt-br	Disponível
 away	jabberit_messenger	pt-br	Volto Logo
-Away	jabberit_messenger	pt-br	Volto Logo
+Away	jabberit_messenger	pt-br	Ausente
 Birthday	jabberit_messenger	pt-br	Aniversário
 busy	jabberit_messenger	pt-br	Ocupado
@@ -45,8 +45,8 @@
 Enable the Expresso Messenger inside of the modules	common	pt-br	Habilitar o Expresso Messenger dentro dos módulos
 Enable the Expresso Messenger module	jabberit_messenger	pt-br	Habilitar o módulo Expresso Messenger 
+Enter a value greater than or equal to 1!	jabberit_messenger	pt-br	Informe um valor igual ou maior que 1!
 E-mail	jabberit_messenger	pt-br	E-mail
 External Participants	common	pt-br	Participantes Externos
 External Participants	jabberit_messenger	pt-br	Participantes Externos
-Ficar ausente depois de	jabberit_messenger	pt-br	Ficar ausente depois de
 Font	jabberit_messenger	pt-br	Fonte
 Full Name	jabberit_messenger	pt-br	Nome Completo
@@ -112,4 +112,5 @@
 Send	jabberit_messenger	pt-br	Enviar
 Send File	jabberit_messenger	pt-br	Enviar Arquivo
+Set status to away after	jabberit_messenger	pt-br	Definir status de ausente depois de
 Show friends Offline	jabberit_messenger	pt-br	Exibir amigos Offline
 Size	jabberit_messenger	pt-br	Tamanho
@@ -129,5 +130,5 @@
 unavailable	jabberit_messenger	pt-br	Desconectado
 Vcard	jabberit_messenger	pt-br	Vcard
-Xa	jabberit_messenger	pt-br	Ausente
+Xa	jabberit_messenger	pt-br	Ausente Estendido
 Yes	jabberit_messenger	pt-br	Sim
 You desire to register in service IM?	jabberit_messenger	pt-br	Você deseja registrar no serviço IM?
Index: /trunk/jabberit_messenger/setup/setup.inc.php
===================================================================
--- /trunk/jabberit_messenger/setup/setup.inc.php	(revision 551)
+++ /trunk/jabberit_messenger/setup/setup.inc.php	(revision 697)
@@ -8,5 +8,5 @@
 	$setup_info['jabberit_messenger']['name']      	= 'jabberit_messenger';
 	$setup_info['jabberit_messenger']['title']     	= 'Jeti Applet';
-	$setup_info['jabberit_messenger']['version']   	= '0.7.10';
+	$setup_info['jabberit_messenger']['version']   	= '0.7.11';
 	$setup_info['jabberit_messenger']['app_order'] 	= 9;
 	$setup_info['jabberit_messenger']['enable']    	= 1;
Index: /trunk/jabberit_messenger/xsl/options.xsl
===================================================================
--- /trunk/jabberit_messenger/xsl/options.xsl	(revision 382)
+++ /trunk/jabberit_messenger/xsl/options.xsl	(revision 697)
@@ -13,5 +13,5 @@
 
 	<xsl:template match="option" mode="option">
-		<dt style="{style}"><xsl:value-of select="item"/></dt>
+		<dt style="{style}" onmouseover="elementOnMouseOver(this);" onmouseout="elementOnMouseOut(this);"><xsl:value-of select="item"/></dt>
 	</xsl:template>
 
Index: /trunk/jabberit_messenger/xsl/tableOrganizationsEnabledGroupsJabberit.xsl
===================================================================
--- /trunk/jabberit_messenger/xsl/tableOrganizationsEnabledGroupsJabberit.xsl	(revision 697)
+++ /trunk/jabberit_messenger/xsl/tableOrganizationsEnabledGroupsJabberit.xsl	(revision 697)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+	<xsl:output method="html" omit-xml-declaration="yes"/>
+
+	<xsl:param name="lang1" />
+	<xsl:param name="lang2" />
+	
+	<xsl:template match="/">
+		<table id="tableOrganizationsEnabledGroupsJabberit" cellspacing="2" style="width:100%">
+			<tr class="th">
+				<td align="left" class="row_on"><xsl:value-of select="$lang1" /></td>
+				<td align="left" class="row_on" style="width:30% !important"><xsl:value-of select="$lang2" /></td>
+			</tr>
+			<xsl:for-each select="return/ou	">
+				<tr id="{.}" style="width:40%" class="row_off">
+					<td class="row_on"><xsl:value-of select="." /></td>
+					<td class="row_on" style="width:30% !important"><a href="javascript:constructScript.removeOrgGroupsLocked('{.}');"><xsl:value-of select="$lang2"/></a></td>
+				</tr>
+			</xsl:for-each>
+		</table>
+	</xsl:template>
+
+</xsl:stylesheet>
Index: /trunk/jabberit_messenger/xsl/contacts_jabberit.xsl
===================================================================
--- /trunk/jabberit_messenger/xsl/contacts_jabberit.xsl	(revision 382)
+++ /trunk/jabberit_messenger/xsl/contacts_jabberit.xsl	(revision 697)
@@ -6,5 +6,5 @@
 
 	<xsl:template match="contacts_jabberit">
-		<iframe src="{$path}client.php" frameborder="0" width="100%" height="400px"></iframe>
+		<iframe id="iframe_applet_jabberit" src="{$path}client.php" frameborder="0" width="100%" height="400px"></iframe>
 	</xsl:template>
 
Index: /trunk/jabberit_messenger/xsl/preferences_jabberit.xsl
===================================================================
--- /trunk/jabberit_messenger/xsl/preferences_jabberit.xsl	(revision 622)
+++ /trunk/jabberit_messenger/xsl/preferences_jabberit.xsl	(revision 697)
@@ -12,5 +12,8 @@
 	<xsl:param name="lang7" />
 	<xsl:param name="lang8" />
-	<xsl:param name="lang9" />	
+	<xsl:param name="lang9" />
+	<xsl:param name="lang10" />
+	<xsl:param name="lang11" />
+	<xsl:param name="lang12" />
 	<xsl:param name="langYes" />
 	<xsl:param name="langNo" />		
@@ -28,5 +31,4 @@
 				</select>
 			</fieldset>
-			<br/>
 			<fieldset style="height:60px;margin-bottom:6px;padding:5px; border:1px solid #cecece;">
 				<legend><xsl:value-of select="$lang8"/></legend>
@@ -37,4 +39,9 @@
 					<option value="false"><xsl:value-of select="$langNo"/></option>
 				</select>
+			</fieldset>
+			<fieldset style="height:60px;margin-top:6px;padding:5px; border:1px solid #cecece;">
+				<legend><xsl:value-of select="$lang10"/></legend>			
+				<br/>
+				<label><xsl:value-of select="$lang11"/><input id="flagAwayIM" type="text" size="2" maxlength="2" style="margin-left:4px; margin-right:4px;" onclick="this.select();" /><xsl:value-of select="$lang12"/></label>
 			</fieldset>
 		</fieldset>
Index: /trunk/jabberit_messenger/xsl/add_user.xsl
===================================================================
--- /trunk/jabberit_messenger/xsl/add_user.xsl	(revision 595)
+++ /trunk/jabberit_messenger/xsl/add_user.xsl	(revision 697)
@@ -19,5 +19,5 @@
 				<input type="text" size="30" onclick="this.select();" onkeypress="javascript:loadscript.keyPress(event, this);" style="margin: 0 10 0 0px;"/>
 				<input type="image" src='../jabberit_messenger/templates/default/images/users.png' value="{$lang2}" onclick="javascript:loadscript.search(this);" />
-				<div id="external_Participants_Jabberit" style="display:block;margin:3 0 0 0px;border-bottom:1px dashed #000;width:430px;">
+				<div id="external_Participants_Jabberit" style="display:none;margin:3 0 0 0px;border-bottom:1px dashed #000;width:430px;">
 					<input type="checkbox" name="checkbox_external_Participants_Jabberit" style="margin:10 5 0 0px;" onclick="javascript:loadscript.cLabel(this);"/>
 					<span style="width:130px;"><xsl:value-of select="$lang8" /> .: </span> - <span onclick="javascript:loadscript.openWinParExt(this);" style="cursor:pointer;">
Index: /trunk/jabberit_messenger/inc/getphoto.php
===================================================================
--- /trunk/jabberit_messenger/inc/getphoto.php	(revision 551)
+++ /trunk/jabberit_messenger/inc/getphoto.php	(revision 697)
@@ -176,21 +176,22 @@
 		$photoHeight = 90;
 		$newImage = imagecreatetruecolor($photoWidth,$photoHeight);		
-		
+
 		if($photo)
 		{
 			$photo = imagecreatefromstring($photo);
-			$trans = imagecolortransparent($photo);
 			imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo));
-			imagepng($newImage);
-			imagedestroy($newImage);
 		}
 		else
 		{
 			$photo = @imagecreatefrompng("../templates/default/images/photo.png");
-			$trans = imagecolortransparent($photo);
 			imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo));
-			imagepng($newImage);
-			imagedestroy($newImage);
-		}
+		}
+
+		ob_start();
+		imagepng($newImage);
+		$imagePhoto = ob_get_contents();
+		imagedestroy($newImage);
+		ob_end_clean();
+		printf("%s",base64_encode($imagePhoto));
 	}
 	else
Index: /trunk/jabberit_messenger/inc/controller.xml
===================================================================
--- /trunk/jabberit_messenger/inc/controller.xml	(revision 563)
+++ /trunk/jabberit_messenger/inc/controller.xml	(revision 697)
@@ -33,10 +33,13 @@
 			<item ref="contacts_im" alias="getParticipantsExternal" class="contacts_im" method="getParticipantsExternal" prefix="class." suffix=".inc.php"/>
 			<item ref="contacts_im" alias="list_contacts" class="contacts_im" method="list_contacts" prefix="class." suffix=".inc.php"/>
+			<item ref="contacts_im" alias="verifyAddNewContact" class="contacts_im" method="verifyAddNewContact" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="getPreferences" class="db_im" method="getPreferences" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="setAttributesLdap" class="db_im" method="setAttributesLdap" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="setPreferences" class="db_im" method="setPreferences" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="setUseParticipantsExternal" class="db_im" method="setUseParticipantsExternal" prefix="class." suffix=".inc.php"/>
+			<item ref="db_im" alias="setOuGroupsLocked" class="db_im" method="setOuGroupsLocked" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="setOrganization" class="db_im" method="setOrganization" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="removeAttributesLdap" class="db_im" method="removeAttributesLdap" prefix="class." suffix=".inc.php"/>
+			<item ref="db_im" alias="removeOuGroupsLocked" class="db_im" method="removeOuGroupsLocked" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="removeParticipantsExternal" class="db_im" method="removeParticipantsExternal" prefix="class." suffix=".inc.php"/>
 			<item ref="ldap_im" alias="list_organizations_ldap" class="ldap_im" method="list_organizations_ldap" prefix="class." suffix=".inc.php"/>
Index: /trunk/jabberit_messenger/inc/class.uienabledgroups.inc.php
===================================================================
--- /trunk/jabberit_messenger/inc/class.uienabledgroups.inc.php	(revision 697)
+++ /trunk/jabberit_messenger/inc/class.uienabledgroups.inc.php	(revision 697)
@@ -0,0 +1,168 @@
+<?php
+  /***************************************************************************\
+  *  Expresso - Expresso Messenger                                            *
+  *  	- Alexandre Correia / Rodrigo Souza							          *
+  * ------------------------------------------------------------------------- *
+  *  This program is free software; you can redistribute it and/or modify it  *
+  *  under the terms of the GNU General Public License as published by the    *
+  *  Free Software Foundation; either version 2 of the License, or (at your   *
+  *  option) any later version.                                               *
+  \***************************************************************************/
+  
+require_once "class.boenabledgroups.inc.php";
+
+class uienabledgroups
+{
+	private $bo;
+	
+	public $public_functions = array(
+		'backPage'  => True,
+		'editGroups' => True,
+		'getGroups' => True,
+	);
+	
+	function __construct()
+	{
+		$this->bo = new boenabledgroups();
+	}
+	
+	public final function backPage()
+	{
+		echo "<pre>";
+		print_r($_POST);
+		echo "</pre>";
+	}	
+
+	public final function editGroups()
+	{
+		if($_GET['menuaction'])
+		{
+			if($GLOBALS['phpgw']->acl->check('applications_access',1,'admin'))
+			{
+				$GLOBALS['phpgw']->redirect_link('/index.php');
+			}		
+			
+			$GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin') .' - ' . 'Liberar Organizações para grupos restritos';
+	
+			$GLOBALS['phpgw']->common->phpgw_header();
+			echo parse_navbar();
+	
+			$webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
+			$webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
+	
+			if(strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1))
+				$webserver_url .= '/';
+	
+			// Load Language;
+			require_once "load_lang.php";
+			
+			// Load Ldap;
+			require_once "class.ldap_im.inc.php";
+			
+			$ldap = new ldap_im();
+			
+			$ous = "<option value='-1'>-- ".lang('Select Organization')." --</option>";	
+			if( ($LdapOus = $ldap->listOrganizationsLdap()) )
+			{
+				foreach($LdapOus as $tmp )
+					$ous .= "<option value='".$tmp."'>".$tmp."</option>";
+			}
+
+			$group = unserialize($_GET['groups']);
+			$valueGroupsOrganizations = "";
+			
+			if( $group[2] )
+			{
+				$ou_groups = explode(",",$group[2]);
+			
+				natcasesort($ou_groups);
+			
+				foreach($ou_groups as $tmp)
+				{
+					$valueGroupsOrganizations .= "<tr id='".$tmp."'>";
+					$valueGroupsOrganizations .= "<td align='left' class='row_on'>".$tmp."</td>";
+					$valueGroupsOrganizations .= "<td align='left' class='row_on' style='width:30% !important'><a href='javascript:constructScript.removeOrgGroupsLocked(\"".$tmp."\");'>Excluir</a></td>";					
+					$valueGroupsOrganizations .= "</tr>";
+				}
+			}
+			
+			
+			$GLOBALS['phpgw']->template->set_file(array('jabberit_messenger'=>'confGroupsLocked.tpl'));
+			$GLOBALS['phpgw']->template->set_block('jabberit_messenger','confGroups');	
+			$var = array(
+							'action_url' => "./index.php?menuaction=jabberit_messenger.uienabledgroups.getGroups",
+							'lang_Back' => "Voltar",	
+							'lang_Cadastrar_Organizacao' => "Cadastrar Organização",	
+							'lang_Delete' => "Excluir",							
+							'lang_Informe_as_Organizacoes' => "Informe as Organizações",
+							'lang_Nome_Grupo' => "Nome do Grupo",
+							'lang_Organizacoes_cadastradas_para_grupo' => "Organizações cadastradas para o grupo",	
+							'lang_Organization' => "Organização",
+							'lang_save' => "Salvar",
+							'value_Groups_Organizations' => $valueGroupsOrganizations,	
+							'value_organizations_ldap' => $ous,							
+							'value_Name_Group' => $group[0],
+							'value_gidNumber' => $group[1],
+						);	
+			$GLOBALS['phpgw']->template->set_var($var);
+			$GLOBALS['phpgw']->template->pparse('out','confGroups');
+		}
+	}
+
+	public final function getGroups()
+	{
+		if($GLOBALS['phpgw']->acl->check('applications_access',1,'admin'))
+		{
+			$GLOBALS['phpgw']->redirect_link('/index.php');
+		}		
+		
+		$GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin') .' - ' . 'Liberar Organizações para grupos restritos';
+
+		$GLOBALS['phpgw']->common->phpgw_header();
+		echo parse_navbar();
+
+		$webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
+		$webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
+
+		if(strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1))
+			$webserver_url .= '/';
+
+		echo '<script type="text/javascript">var path_jabberit="'.$webserver_url .'"</script>';
+
+		// Load Language;
+		require_once "load_lang.php";
+
+		$groups_locked_jabberit = $this->bo->getGroupsBlocked();
+
+		if(trim($groups_locked_jabberit))
+		{
+			$glocked = explode(';',$GLOBALS['phpgw_info']['server']['groups_locked_jabberit']);
+			$list_groups = "";
+
+			natcasesort($glocked);
+						
+			foreach( $glocked as $tmp )
+			{
+				$groups = explode(":",$tmp);
+				$list_groups .= "<tr class='row_off'>";
+				$list_groups .= "<td width='30%'>".$groups[0]."</td>";
+				$list_groups .= "<td width='55%'>".$groups[2]."</td>";
+				$list_groups .= "<td width='5%' align='center'><a href='./index.php?menuaction=jabberit_messenger.uienabledgroups.editGroups&groups=".serialize($groups)."'>Editar</a></td>";
+				$list_groups .= "</tr>";
+			}
+		}
+
+		$GLOBALS['phpgw']->template->set_file(array('jabberit_messenger'=>'enabled_ou_groups.tpl'));
+		$GLOBALS['phpgw']->template->set_block('jabberit_messenger','enabled_ous');	
+		$var = array(
+						'action_url' => './admin',						
+						'lang_back' => lang("Back"),
+						'list_groups' => (trim($list_groups) != "") ? $list_groups : "",
+					);	
+		$GLOBALS['phpgw']->template->set_var($var);
+		$GLOBALS['phpgw']->template->pparse('out','enabled_ous');
+	}
+}
+
+
+?>
Index: /trunk/jabberit_messenger/inc/login.php
===================================================================
--- /trunk/jabberit_messenger/inc/login.php	(revision 622)
+++ /trunk/jabberit_messenger/inc/login.php	(revision 697)
@@ -80,10 +80,16 @@
 		}
 
+		// Enable Plugins Java;
+		$pluginsJava[] = $path . "applet.jar?" . filemtime("applet.jar");
+		$pluginsJava[] = $path . "plugins/filetransfer.jar?" . filemtime("plugins/filetransfer.jar");
+		$pluginsJava[] = $path . "plugins/xhtml.jar?" . filemtime("plugins/xhtml.jar");
+		
+		for($i = 0; $i < count($pluginsJava); $i++)
+			$javaFiles .= $pluginsJava[$i] . ",";
+
+		// Load Template;
 		$template = new Template('templates/default');
 		$template->set_var("path", $path);
-		$template->set_var("file0", filemtime("applet.jar"));
-		$template->set_var("file1", filemtime("plugins/groupchat.jar"));
-		$template->set_var("file2", filemtime("plugins/sound.jar"));
-		$template->set_var("file3", filemtime("plugins/xhtml.jar"));		
+		$template->set_var("java_files", $javaFiles);
 		$template->set_var("value_server",$_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit']);
 		$template->set_var("value_host",$_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit']);			
Index: /trunk/jabberit_messenger/inc/jabberit_acl.inc.php
===================================================================
--- /trunk/jabberit_messenger/inc/jabberit_acl.inc.php	(revision 563)
+++ /trunk/jabberit_messenger/inc/jabberit_acl.inc.php	(revision 697)
@@ -55,11 +55,11 @@
 			$ExternalParticipants = implode(",", $ExternalParticipants);
 		}
-					
+		
 		require_once dirname(__FILE__) . '/load_lang.php';
 		
-		print "<script type='text/javascript'>".
-				 "var path_jabberit='".$webserver_url."';".
-			 	 "var externalParticipantsJabberit='".$ExternalParticipants."';".
-			  "</script>";
+		$var_js  = "var path_jabberit='".$webserver_url."';";
+		$var_js	.= "var externalParticipantsJabberit='".$ExternalParticipants."';";
+
+		echo "<script type=\"text/javascript\">".$var_js."</script>";
 
 		$js = array(
Index: /trunk/jabberit_messenger/inc/class.contacts_im.inc.php
===================================================================
--- /trunk/jabberit_messenger/inc/class.contacts_im.inc.php	(revision 598)
+++ /trunk/jabberit_messenger/inc/class.contacts_im.inc.php	(revision 697)
@@ -19,9 +19,19 @@
 	private $ldap;
 	private $db;
-	
+	private $ou_User;
+		
 	public final function __construct()
 	{
 		$this->ldap = new ldap_im();
-		$this->db = new db_im();		
+		$this->db = new db_im();
+
+		$ou_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn'];
+		$ou_User = substr($this->ou_User,strpos($this->ou_User, "ou="));
+		$ou_User = strtoupper(substr($this->ou_User, 0, strpos($this->ou_User, ",dc=")));
+
+		// (OU) User
+		$this->ou_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn'];
+		$this->ou_User = substr($this->ou_User,strpos($this->ou_User, "ou="));
+		$this->ou_User = strtoupper(substr($this->ou_User, 0, strpos($this->ou_User, ",dc=")));
 	}
 
@@ -45,6 +55,9 @@
 		{
 			$groups = explode(":", $tmp);
-			if( array_search($groups[1], $memberShip) !== False)
+			if( array_search($groups[1], $memberShip) !== False )
+			{	
+				$_SESSION['phpgw_info']['jabberit_messenger']['organizationsGroupsLocked'] = $groups[2]; 
 				return true;
+			}
 		}
 		
@@ -82,5 +95,5 @@
 		return $return;
 	}
-	
+
 	private final function users_auth_im($pName)
 	{   
@@ -88,4 +101,5 @@
         $count = count($array_uids);
         $uids_members = array();
+        $result = array();
         
         for($i = 0; $i < $count ;$i+=50)
@@ -94,17 +108,140 @@
             $filter_uid = implode(")(uidnumber=",$partial_uids);
             $filter_uid = "(uidnumber=". $filter_uid. ")";
-            $result = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid, $this->groupsLocked());
-            if ( is_array($result) )
-            	$uids_members = array_merge($uids_members,$result);            	            
+
+			if( $this->groupsLocked() )
+			{
+	            $orgs[] = $this->ou_User;
+	            $orgsGroupsLocked = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['organizationsGroupsLocked']); 
+	            
+				foreach( $orgsGroupsLocked as $tmp )
+				{
+					if( $tmp != "" )
+						$orgs[] = "OU=". $tmp;            
+				}
+				
+	            $orgs = array_unique($orgs);
+
+				foreach( $orgs as $tmp )
+					$result[] = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid, $tmp);
+			}
+			else
+	            $result[] = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid);
+        }
+
+        if ( is_array($result) )
+        {
+          	for($i = 0; $i < count($result); $i++)
+           		if(is_array($result[$i]))
+           			$uids_members = array_merge($uids_members,$result[$i]);
+        }
 	        
-	        if(count($uids_members) > 50){
-	        	unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']);	        
-	          	return 'Many Results';
-	        }            
-        }
-        if(count($uids_members) > 0)
+        if( count($uids_members) > 50 )
+        {
+        	unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']);	        
+          	return 'Many Results';
+        }            
+        
+        if( count($uids_members) > 0 )
             return $uids_members;
         else
-            return 0;   
+            return 0;  
+	}
+	
+	public final function verifyAddNewContact($pUid)
+	{
+		$groupsLocked =  explode(";",$_SESSION['phpgw_info']['jabberit_messenger']['groups_locked']);
+		$gidNumbers = array();
+		$uid = $pUid['uid'];
+
+		foreach($groupsLocked as $tmp)
+		{
+			$groups = explode(":", $tmp);
+			$gidNumbers[] = $groups[1];
+		}
+		
+		$filter_gid = implode(")(gidnumber=",$gidNumbers);
+	    $filter_gid = "(gidnumber=". $filter_gid. ")";
+		
+		$result = $this->ldap->list_groups_memberUid($filter_gid);
+
+		if( $result && is_array($result) )
+		{
+			array_shift($result);
+			$i = 0;
+			
+			foreach($result as $value)
+			{
+				$Groups[$i]['dn'] = $value['dn'];
+				$Groups[$i]['gidnumber'] = $value['gidnumber'][0];
+				if(array_key_exists('memberuid',$value))
+				{
+					array_shift($value['memberuid']);
+					$Groups[$i++]['memberuid'] = $value['memberuid'];
+				}
+			}
+
+			$search = array();
+			$search_Gid = array();
+			
+			// Verifica Uid em Grupo Bloqueado
+			foreach($Groups as $value)
+			{			
+				if( array_search( $uid , $value['memberuid'] ) !== false )
+				{
+					$ou = substr($value['dn'],strpos($value['dn'], "ou="));
+					$search[] = strtoupper(substr($ou, 0, strpos($ou, ",dc=")));
+					$search_Gid[] = $value['gidnumber'];
+				}	
+			}
+		}
+
+		if( $this->groupsLocked() )
+		{
+			if( count($search) > 0 )
+			{
+				// Verifica permissões do grupo
+				foreach($groupsLocked as $value)
+				{							
+					$tpGroups = explode(":",$value);
+					if( $tpGroups[1] == $search_Gid[0] )
+					{
+						$ousTp = explode(",",$tpGroups[2]);
+						$ou_User = substr($this->ou_User,3);
+						
+						if( array_search( $ou_User, $ousTp) !== false )
+							return "true";
+					}
+				}
+				return "false";
+			}
+			else
+				return "true";
+		} 
+		else
+		{		
+			// Se Bloqueado verifica o Grupo	
+			if( count($search) > 0 )
+			{
+				if( array_search($this->ou_User, $search) === false )
+				{
+					// Verifica permissões do grupo
+					foreach($groupsLocked as $value)
+					{							
+						$tpGroups = explode(":",$value);
+						if( $tpGroups[1] == $search_Gid[0] )
+						{
+							$ousTp = explode(",",$tpGroups[2]);
+							$ou_User = substr($this->ou_User,3);
+								
+							if( array_search( $ou_User, $ousTp) !== false )
+								return "true";
+						}
+					}
+					return "false";
+				}
+				return "true";
+			}					
+			return "true";
+		}
 	}
 }
Index: /trunk/jabberit_messenger/inc/hook_admin.inc.php
===================================================================
--- /trunk/jabberit_messenger/inc/hook_admin.inc.php	(revision 563)
+++ /trunk/jabberit_messenger/inc/hook_admin.inc.php	(revision 697)
@@ -18,6 +18,6 @@
 		'Configuration of authentication attribute by Organization (OU)' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uiconforganization.edit_conf'),
 		'External Participants' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uiexternals.editParticipantsExternals'),
-		'Deny module\'s use by group' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uigroupslocked.editGroups')
-		
+		'Deny module\'s use by group' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uigroupslocked.editGroups'),
+		'Liberar Organizações para grupos restritos' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uienabledgroups.getGroups'),
 	);
 
Index: /trunk/jabberit_messenger/inc/class.ldap_im.inc.php
===================================================================
--- /trunk/jabberit_messenger/inc/class.ldap_im.inc.php	(revision 563)
+++ /trunk/jabberit_messenger/inc/class.ldap_im.inc.php	(revision 697)
@@ -35,9 +35,4 @@
 		$this->jid			= $_SESSION['phpgw_info']['jabberit_messenger']['user'];
 		$this->max_result	= 50;
-		
-		// Ou User
-		$this->ou_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn'];
-		$this->ou_User = substr($this->ou_User,strpos($this->ou_User, "ou="));
-		$this->ou_User = strtoupper(substr($this->ou_User, 0, strpos($this->ou_User, ",dc=")));
 	}
 
@@ -85,4 +80,22 @@
 		
 		@ldap_bind($this->ldap,$this->ldap_dn,$this->ldap_pass);
+	}
+
+	public final function list_groups_memberUid($pGroup)
+	{
+		$this->_ldapConnect();
+		
+		if( $this->ldap )
+		{
+			$filter = "(&(objectclass=posixgroup)(|".$pGroup."))";
+			$justthese = array("dn","memberuid","gidnumber");
+			$search = ldap_search($this->ldap,$this->ldap_context,$filter, $justthese);
+			$result = ldap_get_entries($this->ldap,$search);
+			
+			if( $result['count'] > 0 )
+				return $result;
+		}		
+		
+		return false;
 	}
 
@@ -156,5 +169,5 @@
 	}
 
-	public final function list_users_ldap($search, $uidnumber, $groupsDeny)
+	public final function list_users_ldap( $search, $uidnumber, $ous = false )
 	{
 		$this->_connect_ldap();
@@ -166,10 +179,12 @@
 			// SERPRO
 			//$justthese = array("uid","uidNumber","cn","mail","description","phpgwAccountVisible","dn","jpegPhoto");
-			if( $groupsDeny )			
-				$search = ldap_search($this->ldap,$this->ou_User.",".$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1);
+	
+			if( $ous != false )
+				$search = ldap_search($this->ldap,$ous.",".$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1);
 			else
 				$search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1);
+
 			$entry1 = ldap_get_entries($this->ldap,$search);
-			$entry = ldap_first_entry( $this->ldap, $search );
+			$entry  = ldap_first_entry($this->ldap,$search);
 		}
 
@@ -297,5 +312,4 @@
 		return $result_groups;
 	}
-
 }
 
Index: /trunk/jabberit_messenger/inc/class.db_im.inc.php
===================================================================
--- /trunk/jabberit_messenger/inc/class.db_im.inc.php	(revision 622)
+++ /trunk/jabberit_messenger/inc/class.db_im.inc.php	(revision 697)
@@ -112,4 +112,29 @@
 	}
 	
+	public final function getGroupsBlocked()
+	{
+		$return = "";
+		
+		if( $this->db )
+		{
+			$query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";	
+			
+			if($this->db->query($query))
+			{
+
+				if ( $this->db->query($query) )
+				{	
+					while($this->db->next_record())
+						$result[] = $this->db->row();
+				}
+				
+				if( count($result) > 0 )
+					$return = $result[0]['config_value'];
+			}
+		}
+		
+		return $return;
+	}
+	
 	public final function getPreferences()
 	{
@@ -126,17 +151,17 @@
 		}
 
-		return "openWindowJabberit:true;openWindowJabberitPopUp:false";
-
+		return "openWindowJabberit:true;openWindowJabberitPopUp:false;flagAwayIM:5";
+		//return "openWindowJabberit:true;openWindowJabberitPopUp:false";		
 	}
 
 	public final function setPreferences($pParam)
 	{
-		$preferences = $preferences1 = $pParam['preferences1'];
+		$preferences = $pParam['preferences1'];
 		
 		if(isset($pParam['preferences2']))
-		{
-			$preferences2 = $pParam['preferences2'];
-			$preferences .= ";". $preferences2;
-		}
+			$preferences .= ";". $pParam['preferences2'];
+		
+		if(isset($pParam['preferences3']))
+			$preferences .= ";". $pParam['preferences3'];
 		
 		$user_id  = $this->user_id;
@@ -291,4 +316,76 @@
 	}
 	
+	public final function setOuGroupsLocked($pGroup)
+	{
+		$group = $pGroup['group'];
+		$gidnumber = $pGroup['gidnumber'];
+		$organization = strtoupper($pGroup['ou']);
+
+		if( $this->db )
+		{
+			$query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";	
+			
+			if($this->db->query($query))
+			{
+
+				if ( $this->db->query($query) )
+				{	
+					while($this->db->next_record())
+						$result[] = $this->db->row();
+				}
+
+				$groupsLocked = explode(";",$result[0]['config_value']);
+					
+				foreach( $groupsLocked as $tmp )
+				{
+					$aux = explode(":", $tmp);
+					if(($group.":".$gidnumber) == ($aux[0].":".$aux[1]))
+					{
+						if( $aux[2] )
+						{
+							$ou_groups = explode(",",$aux[2]);
+							natcasesort($ou_groups);
+							$key = array_search($organization, $ou_groups);
+							
+							if( $key === false )
+								array_push($ou_groups, $organization);
+							
+							$groups .= $group.":".$gidnumber.":";
+							
+							$return = "<return>";						
+							
+							foreach($ou_groups as $tmp)
+							{
+								$return .= "<ou attr='".$tmp."'>".$tmp."</ou>";
+								$groups .= $tmp .",";	
+							}
+							
+							$return .= "</return>";
+							
+							$groups  = substr($groups,0,strlen($groups)-1);
+							$groups .= ";";
+						}
+						else
+						{
+							$groups .= $group.":".$gidnumber.":".$organization.";";
+							$return = "<return><ou attr='".$organization."'>".$organization."</ou></return>";
+						}
+					}
+					else
+						$groups .= $tmp . ";" ;
+				}
+
+				$groups = substr($groups,0,strlen($groups)-1);
+
+				$query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";
+				$this->db->query($query);
+				
+				return $return;
+			}
+		}
+		
+		return false;
+	}
+	
 	public final function setUseParticipantsExternal($pFlag)
 	{
@@ -377,4 +474,62 @@
 	}
 	
+	public final function removeOuGroupsLocked($pGroup)
+	{
+		$group = $pGroup['group'];
+		$gidnumber = $pGroup['gidnumber'];
+		$organization = strtoupper($pGroup['ou']);
+		$return = false;
+		
+		if( $this->db )
+		{
+			$query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";	
+			
+			if($this->db->query($query))
+			{
+
+				if ( $this->db->query($query) )
+				{	
+					while($this->db->next_record())
+						$result[] = $this->db->row();
+				}
+
+				$groupsLocked = explode(";",$result[0]['config_value']);
+				
+				foreach( $groupsLocked as $tmp )
+				{
+					$aux = explode(":",$tmp);
+					
+					if(($group.":".$gidnumber) == ($aux[0].":".$aux[1]))
+					{
+						$ous = explode(",", $aux[2]);
+						$key = array_search($organization, $ous);
+
+						if( $key !== false )
+							unset($ous[$key]);
+
+						$groups .= $group.":".$gidnumber.":";
+						
+						foreach($ous as $ouTmp)
+							$groups .= $ouTmp .",";	
+						
+						$groups  = substr($groups,0,strlen($groups)-1);
+						$groups .= ";";
+					}
+					else
+						$groups .= $tmp . ";" ;									
+				}
+					
+				$groups  = substr($groups,0,strlen($groups)-1);
+			
+				$query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";
+
+				if( $this->db->query($query))
+					$return = true;
+			}
+		}	
+		
+		return $return;
+	}
+	
 	public final function removeAttributesLdap($pOrg)
 	{
Index: /trunk/jabberit_messenger/inc/class.boenabledgroups.inc.php
===================================================================
--- /trunk/jabberit_messenger/inc/class.boenabledgroups.inc.php	(revision 697)
+++ /trunk/jabberit_messenger/inc/class.boenabledgroups.inc.php	(revision 697)
@@ -0,0 +1,31 @@
+<?php
+
+  /***************************************************************************\
+  *  Expresso - Expresso Messenger                                            *
+  *  	- Alexandre Correia / Rodrigo Souza							          *
+  * ------------------------------------------------------------------------- *
+  *  This program is free software; you can redistribute it and/or modify it  *
+  *  under the terms of the GNU General Public License as published by the    *
+  *  Free Software Foundation; either version 2 of the License, or (at your   *
+  *  option) any later version.                                               *
+  \***************************************************************************/
+
+require_once "class.db_im.inc.php";
+require_once "jabberit_sessions.inc.php";
+
+class boenabledgroups
+{
+	private $db;
+	
+	function __construct()
+	{
+		$this->db = new db_im();
+	}
+
+	public final function getGroupsBlocked()
+	{
+		return $this->db->getGroupsBlocked();		
+	}
+}
+
+?>
Index: /trunk/jabberit_messenger/js/images.js
===================================================================
--- /trunk/jabberit_messenger/js/images.js	(revision 622)
+++ /trunk/jabberit_messenger/js/images.js	(revision 697)
@@ -10,2 +10,19 @@
 	jabberit_group_open.src = path_jabberit + 'templates/default/images/group_open.gif';
 
+	var available_jabberit = new Image();
+	available_jabberit.src =  path_jabberit + 'templates/default/images/available.gif';
+
+	var chat_jabberit = new Image();
+	chat_jabberit.src =  path_jabberit + 'templates/default/images/chat.gif';
+
+	var away_jabberit = new Image();
+	away_jabberit.src =  path_jabberit + 'templates/default/images/away.gif';
+
+	var xa_jabberit = new Image();
+	xa_jabberit.src =  path_jabberit + 'templates/default/images/xa.gif';
+	
+	var dnd_jabberit = new Image();
+	dnd_jabberit.src = path_jabberit + 'templates/default/images/dnd.gif';
+	
+	var invisible_jabberit = new Image();
+	invisible_jabberit.src = path_jabberit + 'templates/default/images/invisible.gif';
Index: /trunk/jabberit_messenger/js/changeStatus.js
===================================================================
--- /trunk/jabberit_messenger/js/changeStatus.js	(revision 622)
+++ /trunk/jabberit_messenger/js/changeStatus.js	(revision 697)
@@ -13,9 +13,4 @@
 	}
 
-	function teste()
-	{
-		alert('aqui dentro');
-	}
-
 	function setPath()
 	{
@@ -26,6 +21,6 @@
 	function changeStatus(){}
 
-	changeStatus.prototype.get = getStatus;
-	changeStatus.prototype.setpath = setPath;
+	changeStatus.prototype.get			= getStatus;
+	changeStatus.prototype.setpath		= setPath;
 	
 	window.changestatus = new changeStatus;
Index: /trunk/jabberit_messenger/js/show_hidden.js
===================================================================
--- /trunk/jabberit_messenger/js/show_hidden.js	(revision 382)
+++ /trunk/jabberit_messenger/js/show_hidden.js	(revision 697)
@@ -8,4 +8,5 @@
 	var _event_show = false;
 	var _event_hidden = false;
+	var count = 0;
 
 	function _config(pObj, pEvent, pHandler)
@@ -23,35 +24,28 @@
 	}
 
+	function hdObject()
+	{
+		if( _last_displayed )
+		{
+			_last_displayed.style.display = 'none';
+			_last_displayed = false;
+		}
+	}
+
 	function _hidden()
 	{
-		_show(_last_displayed);
-	}
-
-	function _wait(e)
-	{
-		var el = ( e.target ) ? e.target : e.srcElement;
-		if ( e.type.indexOf('mouseover') != -1 )
-			clearTimeout(_timeout);
-		else
-			_timeout = setTimeout(_hidden, _delay);
+		if( arguments.length > 0 )
+		{
+			if( arguments[0] )
+				clearTimeout(_timeout);
+			else
+				_timeout = setTimeout( hdObject, _delay);
+		}
 	}
 
 	function _show(_element)
 	{
-		if ( _last_displayed )
-			_last_displayed.style.display = 'none';
-
-		if ( _timeout )
-			clearTimeout(_timeout);
-
-		if ( _element != _last_displayed )
-		{
-			_last_displayed = _element;
-			_element.style.display = 'block';
-			_config(_element,_event_show,_wait);
-			_config(_element,_event_hidden,_wait);
-		}
-		else
-			_last_displayed = false;
+		_element.style.display = 'block';
+		_last_displayed = _element;
 	}
 
@@ -94,8 +88,5 @@
 
 				if ( _element )
-				{
 					_show(_element);
-					_timeout = setTimeout(_hidden, _delay);
-				}
 			}
 		}
@@ -108,4 +99,5 @@
 
 	ShowHidden.prototype.action  = _view;
+	ShowHidden.prototype.hiddenObject = _hidden;
     window.ShowHidden = ShowHidden;
 }
Index: /trunk/jabberit_messenger/js/load.js
===================================================================
--- /trunk/jabberit_messenger/js/load.js	(revision 624)
+++ /trunk/jabberit_messenger/js/load.js	(revision 697)
@@ -1,11 +1,14 @@
 (function()
 {
+	var _autoStatusTime = 60000; // 1 minuto
+	var _autoStatus;
 	var _conn   = new JITConnector(path_jabberit);
 	var _xtools = new JITXTools(path_jabberit);
-	var _showhidden = new ShowHidden(1500);
+	var _showhidden = new ShowHidden(1000);
 	var myWindow	  = '';
 	var flagMouseOver = '';
 	var flagOpenIM	  = '';
 	var flagOpenPopup = '';
+	var flagAwayIM	  = '';
     
 	// Sniffer Browser
@@ -40,4 +43,9 @@
 	var _ldap	= new JITLdap( _conn, _xtools, _window);
 
+	function addContacts()
+	{
+		_ldap.add();
+	}
+
 	function addIcon()
 	{
@@ -84,12 +92,14 @@
 
 			var _menu;
-				_menu = top.document.createElement('span');
+				_menu = top.document.createElement('div');
 				_menu.setAttribute('id','fast_menu_jabberit');
 				_menu.style.backgroundColor = 'cecece';
+				_menu.style.border = '1px dashed #000';
 				_menu.style.display = 'none';
 				_menu.style.margin = '20px 5px 0px -15px';
 				_menu.style.position = 'absolute';
 				_menu.style.zIndex = '99999';
-				_menu.style.border = '1px dashed #000';
+				_menu.onmouseout = function(){ _showhidden.hiddenObject(false); };
+				_menu.onmouseover = function(){ _showhidden.hiddenObject(true); };
 				
 			divJabber.insertBefore(_menu, divJabber.firstChild);
@@ -124,8 +134,9 @@
 						['Add Contacts',addContacts],
 						['Help',helpJabberit],
-						['Preferences', preferences]
+						['Preferences', preferences],
+						['Change Status', subMenuChangeStatus]
 					];
 
-					var _style_text = 'cursor: pointer; padding:2px 2px 2px 15px; background: no-repeat url(' + jabberit_group_close.src + ');';					
+					var _style_text = 'cursor: pointer; padding:2px 2px 2px 15px; border-bottom:1px solid #dedede; background: no-repeat url(' + jabberit_group_close.src + ');';					
 
 					var _xml = _xtools.xml('menu');
@@ -165,16 +176,49 @@
 						);
 					}
-				}
-			);
-
-
-
-		//
-		}
-	}
-
-	function addContacts()
-	{
-		_ldap.add();
+				});
+		}
+	}
+
+	function autoStatus()
+	{
+		
+		if ( _autoStatus )
+			clearTimeout(_autoStatus);
+
+		var _div_status = document.getElementById('status_Jabber_Expresso');
+		if ( _div_status )
+		{
+			var _status = _div_status.style.backgroundImage;
+			_status = _status.substr(_status.lastIndexOf('/') + 1);
+			_status = _status.substr(0, _status.indexOf('.'));
+			if ( _status == 'xa' && _div_status.getAttribute('autoStatus') )
+			{
+				_div_status.removeAttribute('autoStatus');
+				changeStatusJava("2");
+			}
+		}
+
+		var TimeStatus = flagAwayIM.split(':');
+
+		if( TimeStatus[1] )
+			_autoStatus = setTimeout(autoStatusHandler, parseInt(TimeStatus[1])*_autoStatusTime);
+		else
+			_autoStatus = setTimeout(autoStatusHandler, parseInt(_autoStatusTime));
+	}
+
+	function autoStatusHandler()
+	{
+		var _div_status = document.getElementById('status_Jabber_Expresso');
+		if ( _div_status )
+		{
+			var _status = _div_status.style.backgroundImage;
+			_status = _status.substr(_status.lastIndexOf('/') + 1);
+			_status = _status.substr(0, _status.indexOf('.'));
+			if ( _status == 'available' )
+			{
+				_div_status.setAttribute('autoStatus','true');
+				changeStatusJava("5");
+			}
+		}
 	}
 
@@ -190,4 +234,31 @@
 				element.innerHTML = "Nome do Contato .: ";
 		}
+	}
+
+	function changeStatusJava()
+	{
+  		if(arguments.length > 0 )
+  		{
+	 		try
+	 		{
+	 			// If Layer;
+	 			if( elementIframe = document.getElementById('iframe_applet_jabberit') )
+	 			{
+					if( !is_ie )
+						elementIframe.contentDocument.applets[0].changeStatusfromExpresso(arguments[0]);
+					else
+						elementIframe.contentWindow.document.applets[0].changeStatusfromExpresso(arguments[0]);
+				}
+				else // If Pop-Up
+				{
+					myWindow.document.applets[0].changeStatusfromExpresso(arguments[0]);
+				}
+			}
+			catch(e)
+			{
+				if( confirm('Deseja conectar o IM ?') )
+					showWindow();
+			}
+	   	}		
 	}
 
@@ -225,10 +296,11 @@
 							var autoConnect = '';
 							flagOpenIM = data;
-							
+
 							if( data.indexOf(';') != -1)
 							{
 								var temp = data.split(';');
 								autoConnect = flagOpenIM = temp[0];
-
+								
+								// Open as Pop-Up
 								flagOpenPopup = 'openWindowJabberitPopUp:false';
 								
@@ -238,4 +310,12 @@
 										flagOpenPopup = temp[1];
 								}
+								
+								// Away
+								flagAwayIM = 'flagAwayIM:5';
+								
+								if( temp[2] )
+								{
+									flagAwayIM = temp[2];
+								}
 							}
 							else
@@ -243,5 +323,5 @@
 								autoConnect = flagOpenIM;
 							}
-	
+							
 							if( autoConnect == 'openWindowJabberit:true' )
 							{
@@ -401,4 +481,6 @@
 				_splash.style.zIndex = '99999';
 				_splash.style.border = '2px outset #000';
+				_splash.onmouseout = function(){ _showhidden.hiddenObject(false); };
+				_splash.onmouseover = function(){ _showhidden.hiddenObject(true); };
 			
 				for(var i = 0; i < orgPartExternal.length; i++)
@@ -415,5 +497,5 @@
 		{
 			var _win_preferences = _window.load('jabberit_preferences');
-				_win_preferences.size(320,250);
+				_win_preferences.size(400,310);				
 				_win_preferences.position(150,100);
 				_win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.');
@@ -447,7 +529,10 @@
 						   'lang7' : jabberitGetLang('Cancel'),
 						   'lang8' : jabberitGetLang('Window'),
-						   'lang9' : jabberitGetLang('Open as Pop-Up Window'),						   
+						   'lang9' : jabberitGetLang('Open as Pop-Up Window'),
+						   'lang10' : jabberitGetLang('Away'),
+						   'lang11' : jabberitGetLang('Set status to away after'),
+						   'lang12' : jabberitGetLang('minutes'),						   
 						   'langYes': jabberitGetLang('Yes'),
-						   'langNo':  jabberitGetLang('No')											   
+						   'langNo' : jabberitGetLang('No')											   
 						  };
 			_win_preferences.content(_xtools.parse(_xtools.xml('preferences_jabberit'), 'preferences_jabberit.xsl', _params));
@@ -462,5 +547,5 @@
 			_win_preferences.size(320,250);
 		}
-
+		
 		// Element openWindowJabberit
 		var value1 = flagOpenIM.split(':');
@@ -472,6 +557,6 @@
 				element1.options[i].selected = true;
 
-
-		// Element userOfflineJabberit
+		
+		// Element openWindowJabberitPopUp
 		var value2 = flagOpenPopup.split(':');
 		var element2 = document.getElementById(value2[0]);
@@ -481,4 +566,9 @@
 			if( element2.options[i].value == valueSelect2 )
 				element2.options[i].selected = true;
+				
+		// Element flagAwayIM
+		var value3 = flagAwayIM.split(':');
+		var element3 = document.getElementById(value3[0]);
+		element3.value = value3[1];
 		
 	}
@@ -521,5 +611,19 @@
 				flagOpenPopup = 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value;
 			}
-			
+		
+		// Element flagAwayIM
+		var elementFlagIM = document.getElementById('flagAwayIM');
+		
+		if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 )
+		{
+			flagAwayIM = 'flagAwayIM:' + elementFlagIM.value;
+			value += '&preferences3=flagAwayIM:' + elementFlagIM.value;
+		}
+		else
+		{
+			alert(jabberitGetLang('Enter a value greater than or equal to 1!'));
+			return false;
+		}
+
 		_conn.go('$this.db_im.setPreferences',
 				 function(data)
@@ -552,5 +656,5 @@
 		var _win_contacts = _window.get('jabberit_contacts');
 		
-		if( flagOpenPopup == 'openWindowJabberitPopUp:true' )
+		if( flagOpenPopup === 'openWindowJabberitPopUp:true' )
 		{
 			openPopup();					
@@ -575,22 +679,97 @@
 	}
 
+	function subMenuChangeStatus()
+	{
+		if(document.getElementById('subMenu_Change_Status_JabberIt') == null )
+		{
+			var _itens  = [
+								['Online', 'loadscript.chstatusJava("2")', 'available_jabberit.src'],
+								['Free For Chat', 'loadscript.chstatusJava("1")', 'chat_jabberit.src'],
+								['Xa', 'loadscript.chstatusJava("3")','xa_jabberit.src'],
+								['Dnd', 'loadscript.chstatusJava("4")','dnd_jabberit.src'],
+								['Away', 'loadscript.chstatusJava("5")','away_jabberit.src'],
+								['Invisible', 'loadscript.chstatusJava("6")','invisible_jabberit.src']
+						  ];
+	
+			var _itensMenu = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>";
+			
+			for(var i in _itens)
+			{
+				if( i == 5 )
+					_itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;' onclick=" + _itens[i][1] + ">";
+				else
+					_itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;border-bottom:1px solid #dedede;' onclick=" + _itens[i][1] + ">";
+				_itensMenu += "<img src='" + eval(_itens[i][2]) + "' style='margin-right:3px;'/>" + jabberitGetLang(_itens[i][0]) + "</dt>";
+			}
+
+			_itensMenu += "</dl>";
+	
+			var _subMenu_div = document.createElement("div");
+				_subMenu_div.setAttribute('id','subMenu_Change_Status_JabberIt');
+				_subMenu_div.style.margin = '-10px 5px 0px 0px';
+				_subMenu_div.style.background = '#cecece';
+				_subMenu_div.style.border = '1px dashed #000';
+				_subMenu_div.style.float = 'left';
+				_subMenu_div.style.position = 'absolute';
+				_subMenu_div.style.left = '55px';
+				_subMenu_div.style.width = '120px';
+				_subMenu_div.style.zindex = '99999';
+				_subMenu_div.innerHTML = _itensMenu; 
+	
+			var elementParent = document.getElementById('fast_menu_jabberit');
+			elementParent.appendChild(_subMenu_div);
+		}
+	}
+
 	function Load()
 	{
 		addIcon();
 		getPreferences();
-	}
-
-	Load.prototype.adIcon	= addIcon;
-	Load.prototype.cLabel	= changeLabel;
-	Load.prototype.closeW	= closeWindow;
+		
+		// AutoStatus Away		
+		autoStatus();
+		configEvents(document, 'onmousemove', autoStatus);
+		configEvents(document, 'onkeypress', autoStatus);
+	}
+
+	Load.prototype.adIcon		= addIcon;
+	Load.prototype.autoStatusIM	= autoStatus;
+	Load.prototype.chstatusJava	= changeStatusJava;
+	Load.prototype.closeW		= closeWindow;
+	Load.prototype.cLabel		= changeLabel;
 	Load.prototype.getElement	= getElementStatus;
 	Load.prototype.keyPress		= keyPressSearch;
 	Load.prototype.openWinParExt = openWindowParticipantsExternal;
-	Load.prototype.search	= searchUser;
-	Load.prototype.setPrefe = setPreferences;
-	Load.prototype.show		= showDiv;
-	Load.prototype.showW	= showWindow;
-
+	Load.prototype.search		= searchUser;
+	Load.prototype.setPrefe 	= setPreferences;
+	Load.prototype.show			= showDiv;
+	Load.prototype.showW		= showWindow;
+	
 	window.loadscript = new Load;
 
 })();
+
+// Functions OnMouseOver e OnMouseOut
+
+function elementOnMouseOut()
+{
+	if( arguments.length > 0 )
+	{
+		var _element = arguments[0];
+			_element.style.backgroundColor = '';
+			_element.style.border = '';
+			if( !arguments[1] )
+				_element.style.borderBottom = '1px solid #dedede';
+	}
+}
+
+function elementOnMouseOver()
+{
+	if( arguments.length > 0 )
+	{
+		var _element = arguments[0];
+			_element.style.backgroundColor = 'white';
+			_element.style.border = '1px solid black';
+	}
+}
+
Index: /trunk/jabberit_messenger/js/ldap.js
===================================================================
--- /trunk/jabberit_messenger/js/ldap.js	(revision 560)
+++ /trunk/jabberit_messenger/js/ldap.js	(revision 697)
@@ -64,21 +64,14 @@
 					if ( !(_name.value) || !(_group.value) )
 					{
-						_status.innerHTML = '<br/>O campo destacado em vermelho é obrigatório!<br/>';
-
 						if ( !(_name.value) )
-						{
-							_name.previousSibling.style.color = "#f00";
-							_status.innerHTML += '<br/>** Informe um "NOME" para o contato.';
-						}
+							alert( jabberitGetLang('ATTENTION') + "!!\nInforme um \"NOME\".");
 
 						if ( !(_group.value) )
-						{
-							_status.innerHTML += '<br/>** Informe um "GRUPO" para o contato.';
-						}
+							alert( jabberitGetLang('ATTENTION') + "!!\nInforme um \"GRUPO\".");							
 					}
 					else
 					{
 						var _uid;
-
+						
 						if ( (_uid = document.getElementById('im_uid')) )
 							_uid = _uid.value;
@@ -87,20 +80,41 @@
 
 						
-						_name.parentNode.style.display = 'none';
-						_name.parentNode.nextSibling.style.display = 'none';
-						_status.innerHTML = '<br/>Adicionando contato, aguarde....<br/>';
-
-						_conn.go(
-							'$this.ujabber.AddNewContact',
-							function()
-							{
-								_status.innerHTML = '<br/>Contato adicionado !<br/>';
-								setTimeout('cleanStatusAddContactIM();',2500);
-							},
-							'uid='+_uid+'&name='+_name.value+'&group='+_group.value
-						);
-
-						_name.value = '';
-						_group.value = '';
+						_conn.go('$this.contacts_im.verifyAddNewContact',
+								 function(data)
+								 {
+									data = eval(data);
+									
+									if( !data )
+									{
+										alert("*********** " + jabberitGetLang("Attention") + "!! ***********\n" + 
+											  jabberitGetLang("This user is part of a small group!") + 
+											  "\n" + jabberitGetLang("Contact was not added!"));
+
+										_name.value = '';
+										_group.value = '';
+											  
+									}
+									else
+									{	
+										
+										_name.parentNode.style.display = 'none';
+										_name.parentNode.nextSibling.style.display = 'none';
+										_status.innerHTML = '<br/>Adicionando contato, aguarde....<br/>';
+				
+										_conn.go(
+											'$this.ujabber.AddNewContact',
+											function()
+											{
+												_status.innerHTML = '<br/>Contato adicionado !<br/>';
+												setTimeout('cleanStatusAddContactIM();',2500);
+											},
+											'uid='+_uid+'&name='+_name.value+'&group='+_group.value
+										);
+
+										_name.value = '';
+										_group.value = '';
+										
+									}
+								 }, "uid="+_uid);
 					}
 				}
