Index: /trunk/expressoMail1_2/setup/setup.inc.php
===================================================================
--- /trunk/expressoMail1_2/setup/setup.inc.php	(revision 373)
+++ /trunk/expressoMail1_2/setup/setup.inc.php	(revision 381)
@@ -12,5 +12,5 @@
 	$setup_info['expressoMail1_2']['name']      	= 'expressoMail1_2';
 	$setup_info['expressoMail1_2']['title']     	= 'ExpressoMail 1.2';
-	$setup_info['expressoMail1_2']['version']   	= '1.230';
+	$setup_info['expressoMail1_2']['version']   	= '1.231';
 	$setup_info['expressoMail1_2']['app_order'] 	= 2;
 //	$setup_info['expressoMail1_2']['tables'][]    	= 'phpgw_expressoMail1_2';
Index: /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 371)
+++ /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 381)
@@ -150,5 +150,5 @@
 					$return = array();
 					$return['status'] = false;
-					$return['error'] = "many results";
+					$return['error'] = "many results";					
 					return $return;
 				}
@@ -393,5 +393,5 @@
 		$error = False;
 		
-		$this->ldapConnect(false,$catalog);
+		$this->ldapConnect(true,$catalog);
 		
 		$params['organization'] == 'all' ? $user_context = $this->ldap_context :$user_context = $this->branch."=".$params['organization'].",".$this->ldap_context;		
@@ -410,11 +410,11 @@
 			}
 			
-			$sr=@ldap_search($this->ds, $user_context, $filter, $justthese, 0, $this->max_result+1);
+			$sr=@ldap_search($this->ds, $user_context, $filter, $justthese, 0, $max_result+1);
 			if(!$sr)
 				return null;
 			$count_entries = ldap_count_entries($this->ds,$sr);
-			if ($count_entries > $this->max_result){
+			if ($count_entries > $max_result){
 				$info = null;
-				$error = True;						
+				$error = True;					
 			}
 			else
@@ -430,5 +430,5 @@
 					//aqui eh feita a concatenacao do departamento ao cn;
 					$u_tmp[$info[$i]["mail"][0]] = utf8_decode($info[$i]["cn"][0]). '%' . $info[$i]["ou"][0];
-				else
+				if((!$catalog==0)||(strtoupper($info[$i]["phpgwaccounttype"][0]) == 'L') && ($info[$i]["phpgwaccountvisible"][0] != '-1'))							
 					$g_tmp[$info[$i]["mail"][0]] = utf8_decode($info[$i]["cn"][0]);
 			}										
@@ -655,5 +655,5 @@
 			
 			if($entry) {						
-				$obj =  array("cn" => utf8_decode(ldap_get_values($ds, $entry, "cn")),
+				$obj =  array("cn" => utf8_decode(current(ldap_get_values($ds, $entry, "cn"))),
 						  "email" => $params['email'],
 						  "uid" => ldap_get_values($ds, $entry, "uid"),
Index: /trunk/expressoMail1_2/js/common_functions.js
===================================================================
--- /trunk/expressoMail1_2/js/common_functions.js	(revision 365)
+++ /trunk/expressoMail1_2/js/common_functions.js	(revision 381)
@@ -662,5 +662,5 @@
 
 function exist_className(obj, className){
-	if ( obj.className.indexOf(className) != -1 )
+	if ( obj && obj.className.indexOf(className) != -1 )
 		return true;
 	return false;
Index: /trunk/expressoMail1_2/js/QuickCatalogSearch.js
===================================================================
--- /trunk/expressoMail1_2/js/QuickCatalogSearch.js	(revision 353)
+++ /trunk/expressoMail1_2/js/QuickCatalogSearch.js	(revision 381)
@@ -10,5 +10,4 @@
 		id = '1';
 		_this = this;
-
 		var el = document.createElement("DIV");
 		el.style.visibility = "hidden";
@@ -236,11 +235,11 @@
 					   '<table border="0" cellpading="0" cellspacing="0">'+
 					   '<tr><td>'+get_lang("Select an organization and click on button <b>Search</b>")+'&nbsp;:</td></tr>'+
-  					'<tr><td><select style="width:150px" id="select_catalog" name="select_catalog" onchange="javascript:QuickCatalogSearch.update_organizations();"></select>&nbsp'+
-					'<select id="select_organization" style="width:100px" name="select_organization"></select>&nbsp;'+   
-					'<input type="text" id="search_for" name="search_for" value="" size="30" maxlength="20"/>&nbsp;<input type="button" onclick="QuickCatalogSearch.searchCatalogList(true)" class="button" value="'+get_lang('Search')+'">&nbsp;<input style="display:none" type="button" onclick="QuickCatalogSearch.searchCatalogList(false)" class="button" value="'+get_lang('List All')+'"></td></tr>'+
-					   //'<tr><td><input onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" id="type" type="radio" name="type" value="l"/>'+get_lang('Public Lists')+'&nbsp;&nbsp;<input type="radio" name="type" value="u" onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" checked/>'+get_lang('Users')+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
+  					'<tr><td><select style="display:none;width:150px" id="select_catalog" name="select_catalog" onchange="javascript:QuickCatalogSearch.update_organizations();"></select>&nbsp'+
+					'<select id="select_organization" style="width:150px" name="select_organization"></select>&nbsp;'+   
+					'<input type="text" id="search_for" name="search_for" value="" size="30" maxlength="30"/>&nbsp;<input type="button" onclick="QuickCatalogSearch.searchCatalogList(true)" class="button" value="'+get_lang('Search')+'">&nbsp;<input style="display:visible" type="button" onclick="QuickCatalogSearch.searchCatalogList(false)" class="button" value="'+get_lang('List All')+'"></td></tr>'+
+					   '<tr><td><input onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" id="type_l" type="radio" name="type" value="l"/>'+get_lang('Public Lists')+'&nbsp;&nbsp;<input type="radio" id="type_u" name="type" value="u" onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" checked/>'+get_lang('Users')+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
 					   '<span style="visibility:hidden;background:#cc4444" id=msg_search>&nbsp;&nbsp;<font face="Verdana" size="1" color="WHITE">'+get_lang('Search in Catalog')+'...</font>&nbsp;</span></td></tr>'+
 					   '<tr><td>'+
-				  	   '<span id="list_span"><select multiple style="display:none;width:450px" size="14" id="list_values"></select></span>'+
+				  	   '<span id="list_span"><select multiple style="display:none;width:580px" size="14" id="list_values"></select></span>'+
 				  	   '<span id="user_span"><select multiple style="width:580px" size="14" id="user_values"></select></span>'+
 				 	   '</td></tr>'+
@@ -255,8 +254,8 @@
 					   '<table border="0" cellpading="0" cellspacing="0">'+
 					   '<tr><td>'+get_lang("Select the type of contact that you want to view")+'&nbsp;:</td></tr>'+
-					   '<tr><td><input onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" id="type" type="radio" name="type" value="p"/>' + get_lang('People') + '&nbsp;&nbsp;<input type="radio" name="type" value="g" onclick="javascript:QuickCatalogSearch.changeOptions(this.value)"/>' + get_lang('Groups') + ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
+					   '<tr><td><input onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" type="radio" name="type" value="p"/>' + get_lang('People') + '&nbsp;&nbsp;<input type="radio" name="type" value="g" onclick="javascript:QuickCatalogSearch.changeOptions(this.value)"/>' + get_lang('Groups') + ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
 					   '<tr><td>'+
-				  	   '<span id="personal_span"><select multiple style="width:400px" size="14" id="list_personal"></select></span>'+
-				  	   '<span id="groups_span"><select multiple style="display:none;width:400px" size="14" id="list_groups"></select></span>'+
+				  	   '<span id="personal_span"><select multiple style="width:580px" size="14" id="list_personal"></select></span>'+
+				  	   '<span id="groups_span"><select multiple style="display:none;width:580px" size="14" id="list_groups"></select></span>'+
 				 	   '</td></tr>'+
 					   '<tr><td nowrap><center>'+get_lang('Click here to add into the fields')+':&nbsp;<input type="button" class="button" value="'+get_lang('TO')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'to1\')">&nbsp;'+
@@ -295,9 +294,7 @@
 
 		var handler_catalogs = function(data){
-			var user_catalog = "Catalogo Geral";
-
-			if(data.length <= 1) 
-				Element('select_catalog').style.display = 'none';
-			else {
+			var user_catalog = get_lang("Global Catalog");
+			if(data.length > 1) {
+				Element('select_catalog').style.display = '';
 				for(i = 0; i < data.length; i++) {		
 					Element('select_catalog').options[i] = new Option(data[i],i);
@@ -380,12 +377,13 @@
 		}
 	 	var handler_org = function(data){
-                        Element('select_organization').options[0] = new Option(get_lang('all'),'all');
+			Element('select_organization').options[0] = new Option(get_lang('all'),'all');
 			if (data != null){
-			
-			for(x = 0; x < data.length; x++) {
-				Element('select_organization').options[x+1] = new Option(data[x].toUpperCase(),data[x]);
-				}
-			}
-			
+				var user_organization = Element('user_organization').value;
+				for(x = 0; x < data.length; x++) {
+					Element('select_organization').options[x+1] = new Option(data[x].toUpperCase(),data[x]);
+					if(user_organization.toUpperCase() == data[x].toUpperCase())
+						Element('select_organization').options[x+1].selected = true;
+				}
+			}
 		}		
 		cExecute ("$this.ldap_functions.get_organizations&referral=false&catalog="+Element('select_catalog').value, handler_org);		
@@ -461,13 +459,15 @@
 		var search		 = itemSearch ? Element('search_for').value : '';
 		var catalog		 = Element('select_catalog').value;
-		var max_result 	 = 300;
+		var max_result	= 300;
 
 		var handler_searchResults = function(data){
-
 			Element('msg_search').style.visibility = 'hidden';
 			if(data.error){
 				alert(get_lang('More than %1 results. Please, try to refine your search.',max_result));
 				return false;
-			}
+			}else if(data.users.length == 0 && data.groups.length == 0){
+				alert(get_lang('None result was found.'));
+			}
+
 			
 			var group = Element('list_span');
@@ -487,7 +487,7 @@
 
 			var arr 	= new Array(max_result);
-			var display	= Element('type').value == 'l'? 'display:none;' : '';
-
-			for(i = 0; data.groups && i < data.groups.length; i++) {			
+
+			for(i = 0; data.groups && i < data.groups.length; i++) {
+				// Maneiras diferentes de se montar uma tag OPTION, pois no IE o objeto Option é muito lento.
 				if(is_ie)
 					arr[i] = '<option value="'+'&quot;'+data.groups[i].name+'&quot; &lt;'+data.groups[i].email+'&gt;">'+data.groups[i].name+' ('+data.groups[i].email+')'+'</option>';
@@ -496,48 +496,36 @@
 			}
 	
+			
 			if(is_ie)
-				group.innerHTML = '<select multiple style="'+display+'width:400px" size="14" id="list_values">'+ arr.join() +'</select>';
+				group.innerHTML = '<select multiple style="display:none;width:580px" size="14" id="list_values">'+ arr.join() +'</select>';
 
 			arr = new Array(max_result);
-			display = display ? "" : "display:none;";
-			
-			for(i = 0; data.users && i < data.users.length; i++) {			
+			
+			for(i = 0; data.users && i < data.users.length; i++) {
+			/*******************************************************************************************/
+			/* O resultado pratico do bloco de codigo a seguir eh a exibicao dos valores em tela,
+			ja que vai verificar se o departamento e o email estao vazios ou nulos e a partir dai o
+			resultado apresentado em tela sera exibido de maneira mais apresentavel;
+			*/
+				//verifica se departamento eh null ou nao;
+				var department = data.users[i].department ? " - " + data.users[i].department : "";
+				//verifica se email eh null ou nao;
+				var email = data.users[i].email ? data.users[i].email : "";
+
+				// Maneiras diferentes de se montar uma tag OPTION, pois no IE o objeto Option é muito lento.
 				if(is_ie)
-					arr[i] = '<option value="'+'&quot;'+data.users[i].name+'&quot; &lt;'+data.users[i].email+'&gt;">'+data.users[i].name+' ('+data.users[i].email+')'+'</option>';
+					arr[i] = '<option value="'+'&quot;'+data.users[i].name+'&quot; &lt;'+email+'&gt;">'+data.users[i].name+' ('+email+')'+department+'</option>';
 				else {
-				/*******************************************************************************************/
-				/* O resultado pratico do bloco de codigo a seguir eh a exibicao dos valores em tela,
-				ja que vai verificar se o departamento e o email estao vazios ou nulos e a partir dai o
-				resultado apresentado em tela sera exibido de maneira mais apresentavel;
-				*/
-					//verifica se departamento eh null ou nao;
-					var departamento_nulo = 'false';
-					if((data.users[i].department == null) || (data.users[i].department == '')) {
-						data.users[i].department = '';
-						departamento_nulo = 'true';
-					}
-					else {
-						data.users[i].department = ' - ' + data.users[i].department;
-					}
-
-					//verifica se email eh null ou nao;
-					if((data.users[i].email == null) || (data.users[i].email == '')) {
-						if(departamento_nulo = 'true') {
-							data.users[i].email = '';
-						}
-						else {
-							data.users[i].email = ' - ';
-						}
-					}
-					else {
-						data.users[i].email = ' (' + data.users[i].email + ') ';
-					}
-
-					user.options[i] = new Option(data.users[i].name+data.users[i].email+data.users[i].department,'"'+data.users[i].name+'" <'+data.users[i].email+'>'); // incluido data.users[i].department para exibir setor na opcao "Pesquisar" do email;
+					user.options[i] = new Option(data.users[i].name+' ('+email+')'+department,'"'+data.users[i].name+'" <'+email+'>'); // incluido data.users[i].department para exibir setor na opcao "Pesquisar" do email;
 				}
 			}
 	
 			if(is_ie)
-				user.innerHTML = '<select multiple style="'+display+'width:400px" size="14" id="user_values">'+ arr.join() +'</select>';
+				user.innerHTML = '<select multiple style="width:580px" size="14" id="user_values">'+ arr.join() +'</select>';
+
+			// Display entries found.
+			var type = (data.groups.length > 0 && data.users.length == 0) ? 'l' : 'u';
+			Element("type_"+type).checked = true;
+			QuickCatalogSearch.changeOptions(type);
 		}
 
Index: /trunk/expressoMail1_2/index.php
===================================================================
--- /trunk/expressoMail1_2/index.php	(revision 373)
+++ /trunk/expressoMail1_2/index.php	(revision 381)
@@ -28,5 +28,5 @@
 		'nonavbar' => False,
 		'currentapp' => 'expressoMail1_2',
-		'update_version'	=> '1.230',
+		'update_version'	=> '1.231',
 		'enable_nextmatchs_class' => True
 	);
