Index: /branches/2.2/jabberit_messenger/jmessenger/js/strophe.mini.js
===================================================================
--- /branches/2.2/jabberit_messenger/jmessenger/js/strophe.mini.js	(revision 4481)
+++ /branches/2.2/jabberit_messenger/jmessenger/js/strophe.mini.js	(revision 4614)
@@ -109,5 +109,5 @@
 {var xhr=null;if(window.XMLHttpRequest){xhr=new XMLHttpRequest();if(xhr.overrideMimeType){xhr.overrideMimeType("text/xml");}}else if(window.ActiveXObject){xhr=new ActiveXObject("Microsoft.XMLHTTP");}
 xhr.onreadystatechange=this.func.prependArg(this);return xhr;}};Strophe.Connection=function(service)
-{this.service=service;this.jid="";this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this._idleTimeout=null;this._disconnectTimeout=null;this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this.paused=false;this.hold=1;this.wait=60;this.window=5;this._data=[];this._requests=[];this._uniqueId=Math.round(Math.random()*10000);this._sasl_success_handler=null;this._sasl_failure_handler=null;this._sasl_challenge_handler=null;this._idleTimeout=setTimeout(this._onIdle.bind(this),100);for(var k in Strophe._connectionPlugins){if(Strophe._connectionPlugins.hasOwnProperty(k)){var ptype=Strophe._connectionPlugins[k];var F=function(){};F.prototype=ptype;this[k]=new F();this[k].init(this);}}};Strophe.Connection.prototype={reset:function()
+{this.service=service;this.jid="";this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this._idleTimeout=null;this._disconnectTimeout=null;this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this.paused=false;this.hold=2;this.wait=20;this.window=5;this._data=[];this._requests=[];this._uniqueId=Math.round(Math.random()*10000);this._sasl_success_handler=null;this._sasl_failure_handler=null;this._sasl_challenge_handler=null;this._idleTimeout=setTimeout(this._onIdle.bind(this),100);for(var k in Strophe._connectionPlugins){if(Strophe._connectionPlugins.hasOwnProperty(k)){var ptype=Strophe._connectionPlugins[k];var F=function(){};F.prototype=ptype;this[k]=new F();this[k].init(this);}}};Strophe.Connection.prototype={reset:function()
 {this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this._requests=[];this._uniqueId=Math.round(Math.random()*10000);},pause:function()
 {this.paused=true;},resume:function()
Index: /branches/2.2/expressoMail1_2/index.php
===================================================================
--- /branches/2.2/expressoMail1_2/index.php	(revision 4449)
+++ /branches/2.2/expressoMail1_2/index.php	(revision 4614)
@@ -24,6 +24,4 @@
 	echo '<script type="text/javascript" src="../phpgwapi/js/wz_dragdrop/wz_dragdrop.js?'.$update_version.'"></script>
 		<script type="text/javascript" src="../phpgwapi/js/dJSWin/dJSWin.js?'.$update_version.'"></script>';
-
-
 
 	
@@ -57,4 +55,5 @@
     $c->read_repository();
     $current_config = $c->config_data;    
+    
 
 	$_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
@@ -138,7 +137,14 @@
     $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_spam'] = $current_config['expressoMail_command_for_spam'];
     $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_use_spam_filter'] = $current_config['expressoMail_use_spam_filter'];   
-    echo '<script> var use_spam_filter = \''.$current_config['expressoMail_use_spam_filter'].'\'
-           var sieve_forward_domains = \''.$current_config['expressoMail_sieve_forward_domains'].'\' </script>';
-	// End Set Anti-Spam options.
+    
+    echo '<script> var use_spam_filter = "'.$current_config['expressoMail_use_spam_filter'].'"</script>'; 
+    echo '<script> var sieve_forward_domains = "'.$current_config['expressoMail_sieve_forward_domains'].'"</script>';
+    // End Set Anti-Spam options.
+    
+    // Begin Search Users characteres shared folders.
+    echo '<script> var sharedFolders_min_num_characters = "'.$current_config['expressoMail_min_num_characters'].'"</script>';
+    echo '<script> var sharedFolders_users_auto_search  = "'.$current_config['expressoMail_users_auto_search'].'"</script>';
+    // End Search Users characteres shared folders.
+    
 
     // Set Imap Folder names options
Index: /branches/2.2/expressoMail1_2/inc/class.ldap_functions.inc.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 3909)
+++ /branches/2.2/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 4614)
@@ -676,38 +676,42 @@
 	function get_available_users2($params)
 	{
-		$this->ldapRootConnect();
-
-		$context= $params['context'];
-		$justthese = array("cn", "uid", "cn");
-		$filter = "(&(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))";
-
-	    if ($this->ds)
+            $this->ldapRootConnect();
+            $context    = $params['context'];
+            $justthese  = array("cn", "uid", "cn");
+            $filter     = ( isset($params['cn']) ) ? "(&(cn=*".$params['cn']."*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))" : 
+                                "(&(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"; 
+            
+            if ($this->ds)
 	    {
-			$sr=ldap_search($this->ds, $context, $filter, $justthese);
-			$entries = ldap_get_entries($this->ds, $sr);
-
-			for ($i=0; $i<$entries["count"]; $i++){
-				if($_SESSION['phpgw_info']['expressomail']['user']['account_lid'] != $entries[$i]["uid"][0]){
-					$u_tmp[$entries[$i]["uid"][0]] = $entries[$i]["cn"][0];
-				}
-			}
-
-			natcasesort($u_tmp);
-
-			$i = 0;
-			$users = array();
-
-			if (count($u_tmp))
-			{
-				foreach ($u_tmp as $uidnumber => $cn)
-				{
-					$options .= "<option value=$uidnumber>$cn</option>";
-				}
-				unset($u_tmp);
-			}
-
-			ldap_close($this->ds);
-    		return $options;
-		}
+                $sr = ldap_search($this->ds, $context, $filter, $justthese);
+                
+                $entries = ldap_get_entries($this->ds, $sr);
+
+                for ($i=0; $i<$entries["count"]; $i++)
+                {
+                    if($_SESSION['phpgw_info']['expressomail']['user']['account_lid'] != $entries[$i]["uid"][0])
+                    {
+                        $u_tmp[$entries[$i]["uid"][0]] = $entries[$i]["cn"][0];
+                    }
+                }
+
+                natcasesort($u_tmp);
+
+                $i = 0;
+                $users = array();
+
+                if (count($u_tmp))
+                {
+                    foreach ($u_tmp as $uidnumber => $cn)
+                    {
+                        $options .= "<option value=$uidnumber>$cn</option>";
+                    }
+                    
+                    unset($u_tmp);
+                }
+
+                ldap_close($this->ds);
+                return $options;
+            }
 	}
 
Index: /branches/2.2/expressoMail1_2/js/sharemailbox.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/sharemailbox.js	(revision 4610)
+++ /branches/2.2/expressoMail1_2/js/sharemailbox.js	(revision 4614)
@@ -4,31 +4,55 @@
 		this.el;
 		this.alert = false;
-	}
-
-	cShareMailbox.prototype.get_available_users = function(context)
-	{
-		var handler_get_available_users = function(data)
-		{
-			select_available_users = document.getElementById('em_select_available_users');
-		
-			//Limpa o select
-			for(var i=0; i<select_available_users.options.length; i++)
-			{
-				select_available_users.options[i] = null;
-				i--;
-			}
-
-			if ((data) && (data.length > 0))
-			{
-				// Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio.
-				select_available_users.innerHTML = '#' + data;
-				select_available_users.outerHTML = select_available_users.outerHTML;
-			
-				select_available_users.disabled = false;
-				select_available_users_clone = document.getElementById('em_select_available_users').cloneNode(true);
-				document.getElementById('em_input_searchUser').value = '';
-			}
-		}
-		cExecute ("$this.ldap_functions.get_available_users2&context="+context, handler_get_available_users);
+                this.context = "";
+	}
+        
+        cShareMailbox.prototype.get_available_users = function(context)
+        {
+            if( sharedFolders_users_auto_search.toString() === "true" )
+            {    
+                this.get_available_users2(context);
+            }
+        }
+
+	cShareMailbox.prototype.get_available_users2 = function()
+	{
+            var context = "";
+            var cn      = "";
+            
+            var handler_get_available_users = function(data)
+            {
+                    select_available_users = document.getElementById('em_select_available_users');
+
+                    //Limpa o select
+                    for(var i=0; i<select_available_users.options.length; i++)
+                    {
+                            select_available_users.options[i] = null;
+                            i--;
+                    }
+
+                    if ((data) && (data.length > 0))
+                    {
+                            // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio.
+                            select_available_users.innerHTML = '#' + data;
+                            select_available_users.outerHTML = select_available_users.outerHTML;
+
+                            select_available_users.disabled = false;
+                            select_available_users_clone = document.getElementById('em_select_available_users').cloneNode(true);
+                            document.getElementById('em_input_searchUser').value = '';
+                    }
+            }
+
+            if( arguments.length > 1 )
+            {
+                context = arguments[0];
+                cn      = arguments[1];
+                cExecute ("$this.ldap_functions.get_available_users2&context="+context+"&cn="+cn, handler_get_available_users);
+            }   
+            else
+            {
+                context = arguments[0];
+                cExecute ("$this.ldap_functions.get_available_users2&context="+context, handler_get_available_users);
+            }
+            
 	}
 
@@ -166,5 +190,5 @@
                                                 '<br/><br/>'+
                                                 '<label>'+get_lang('Search user')+'<span style="margin-left:10px; color:red;" id="em_span_searching">&nbsp;</span><br></label>'+
-                                                '<input id="em_input_searchUser" size="30" autocomplete="off"  onkeyup="javascript:sharemailbox.optionFinderTimeout(this)">'+
+                                                '<input id="em_input_searchUser" size="30" autocomplete="off"  onkeyup="javascript:sharemailbox.optionFinderTimeout(this, event)">'+
                                                 '<div style="margin-top:17px;"><label>'+get_lang('Users')+':</label></div>'+
                                                 '<select id="em_select_available_users" style="width:250px; height:150px" multiple></select></td>'+
@@ -197,8 +221,10 @@
 		}
 
-		var handler_organizations = function(data){
+		var handler_organizations = function(data)
+                {
 			var user_organization = Element('user_organization').value;
 			
-			for(i = 0; i < data.length; i++) {
+			for(i = 0; i < data.length; i++)
+                        {
 				Element('em_combo_org').options[i] = new Option(data[i].ou,data[i].dn);
 				if(data[i].ou.indexOf("dc=") != -1 || user_organization.toUpperCase() == data[i].ou.toUpperCase())
@@ -299,10 +325,65 @@
 	
 	var finderTimeout = '';
-	cShareMailbox.prototype.optionFinderTimeout = function(obj)
-	{
-		clearTimeout(finderTimeout);	
-		var oWait = document.getElementById("em_span_searching");
-		oWait.innerHTML = get_lang('Searching')+"...";
-		var finderTimeout = setTimeout("sharemailbox.optionFinder('"+obj.id+"')",500);
+
+        cShareMailbox.prototype.optionFinderTimeout = function(Obj, Event )
+	{
+		var minNumChar  = sharedFolders_min_num_characters;
+                var oWait       = document.getElementById("em_span_searching");
+                this.context    = document.getElementById('em_combo_org').value;
+                
+                if( ( parseInt(minNumChar) > 0 && minNumChar.toString() != "" ) &&
+                        sharedFolders_users_auto_search.toString() === "false" )
+                {
+			var key             = [8,27,37,38,39,40];
+			var ev              = Event;
+			var _inputSearch    = Obj;
+			
+			var cleanLabel = function(obj)
+			{
+				obj.innerHTML = "";
+			}
+			
+			var getUsers = function( _input, obj )
+			{
+                            var context = sharemailbox.context;
+                            var cn      = _input.value;
+                            
+                            finderTimeout = setTimeout(function()
+                            {
+                                sharemailbox.get_available_users2( context, cn );
+                            }, 500);
+                            
+                            cleanLabel(obj);
+			}
+
+			for( var i in key )
+                        {
+                            if( ev.keyCode == key[i])
+                            {    
+                                return false;
+                            }
+                        }
+
+			if( _inputSearch.value.length < parseInt(minNumChar) )
+			{
+				oWait.innerHTML = " ( Digite mais " + ( parseInt(minNumChar) - _inputSearch.value.length ) + " )";
+				setTimeout(function(){cleanLabel(oWait);}, 2000);
+			}
+			else
+			{
+				oWait.innerHTML = " ( Buscando aguarde .... )";
+				
+				if( finderTimeout )
+					clearTimeout(finderTimeout);
+
+				finderTimeout = setTimeout(function(){ getUsers( _inputSearch, oWait); }, 1000);
+			}	
+                }
+                else
+                {
+                    clearTimeout(finderTimeout);	
+                    oWait.innerHTML = get_lang('Searching')+"...";
+                    var finderTimeout = setTimeout("sharemailbox.optionFinder('"+Obj.id+"')",500);
+                }
 	}
 	
@@ -331,5 +412,6 @@
 			}
 		}
-		oWait.innerHTML = '&nbsp;';
+		
+                oWait.innerHTML = '';
 	}
 	
