Index: trunk/expressoMail1_2/js/QuickCatalogSearch.js
===================================================================
--- trunk/expressoMail1_2/js/QuickCatalogSearch.js	(revision 271)
+++ trunk/expressoMail1_2/js/QuickCatalogSearch.js	(revision 325)
@@ -35,5 +35,5 @@
 			var cmb = document.createElement("SELECT");
 			cmb.id = "select_QuickCatalogSearch";
-			cmb.style.width = "585px";
+			cmb.style.width = "685px"; // na comunidade valor eh 585px
 			cmb.size = "12";
 			cmb.onkeypress = function (e)
@@ -134,7 +134,10 @@
 			Op.text = data[i].cn + ' (' + data[i].mail + ')';
 			if (data[i].phone != '')
-				Op.text += ' (tel: ' + data[i].phone + ')';
+				Op.text += ' - ' + data[i].phone;
+			if (data[i].ou != '')
+				Op.text += ' - ' + data[i].ou; // adicionado "data[i].ou" para exibir setor (F9)
 			Op.value = '"' + data[i].cn + '" ' + '<' + data[i].mail + '>';
 			cmb.options.add(Op);
+
 		}
 		cmb.options[0].selected = true;
@@ -150,5 +153,5 @@
 							
 		if(! this.arrayWin[div.id]) {
-			div.style.width = "600px";
+			div.style.width = "700px"; //na comunidade valor eh 600px
 			div.style.height = "230px";
 			var title = get_lang('The results were found in the Global Catalog')+':';
@@ -223,5 +226,5 @@
 		el.style.visibility = "hidden";
 		el.style.position = "absolute";
-		el.style.width = "495px";
+		el.style.width = "700px"; // na comunidade valor eh 495px
 		el.style.height = is_ie ? "360px" : "375px";		
 		el.style.left = "0px";
@@ -234,11 +237,12 @@
 					   '<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 id="select_organization" name="select_organization"></select>&nbsp;'+
-  					   '<input type="text" id="search_for" name="search_for" value="" size="17" maxlength="20"/>&nbsp;<input type="button" onclick="QuickCatalogSearch.searchCatalogList(true)" class="button" value="'+get_lang('Search')+'">&nbsp;<input type="button" onclick="QuickCatalogSearch.searchCatalogList(false)" class="button" value="'+get_lang('List All')+'"></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="10" maxlength="15"/>&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;'+
 					   '<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:400px" size="14" id="list_values"></select></span>'+
-				  	   '<span id="user_span"><select multiple style="width:400px" size="14" id="user_values"></select></span>'+
+				  	   '<span id="list_span"><select multiple style="display:none;width:450px" 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>'+
 					   '<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(\'to\')">&nbsp;'+
@@ -291,15 +295,18 @@
 		win.open();
 
-		var handler_organizations = function(data){
-			var user_organization = Element('user_organization').value;
+		var handler_catalogs = function(data){
+			var user_catalog = "Catalogo Geral";
 
 			for(i = 0; i < data.length; i++) {
-				Element('select_organization').options[i] = new Option(data[i],data[i]);
-				if(user_organization.toUpperCase() == data[i].toUpperCase())
-					Element('select_organization').options[i].selected = true;
-			}
-		}
-		cExecute ("$this.ldap_functions.get_organizations&referral=true", handler_organizations);
-		
+			
+				Element('select_catalog').options[i] = new Option(data[i],i);
+				if(user_catalog.toUpperCase() == data[i].toUpperCase())
+					Element('select_catalog').options[i].selected = true;
+			}
+		}
+		cExecute ("$this.ldap_functions.get_catalogs", handler_catalogs);		
+
+		this.update_organizations();
+	
 		var handler_cc_contacts= function(data){
 			if(data && data.length > 0){
@@ -367,4 +374,27 @@
 	}
 
+	emQuickCatalogSearch.prototype.update_organizations = function(){
+
+			
+		while(Element('select_organization').options.length > 0) {
+			Element('select_organization').remove(0);
+		}
+		
+                
+	 	var handler_org = function(data){
+                        Element('select_organization').options[0] = new Option('todos','todos');
+			if (data != null){
+			
+			for(x = 0; x < data.length; x++) {
+				Element('select_organization').options[x+1] = new Option(data[x],data[x]);
+				}
+			}
+			
+		}
+		
+		cExecute ("$this.ldap_functions.get_organizations&referral=false&catalog="+Element('select_catalog').value, handler_org);
+		
+	}
+
 	emQuickCatalogSearch.prototype.changeOptions = function(type){	
 
@@ -428,6 +458,6 @@
 	emQuickCatalogSearch.prototype.searchCatalogList = function (itemSearch){
 
-		if(itemSearch && Element('search_for').value.length == 0){
-			alert(get_lang('No data to search'));
+		if(itemSearch && Element('search_for').value.length < 4){
+			alert(get_lang('your search argument must be longer than 4 characters.'));
 			Element('search_for').focus();
 			return false;
@@ -435,5 +465,6 @@
 		var organization = Element('select_organization').value;		
 		var search		 = itemSearch ? Element('search_for').value : '';
-		var max_result 	 = 2000;
+		var catalog		 = Element('select_catalog').value;
+		var max_result 	 = 300;
 
 		var handler_searchResults = function(data){
@@ -477,8 +508,39 @@
 			
 			for(i = 0; data.users && i < data.users.length; i++) {			
-				if(is_ie)
+				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>';
-				else
-					user.options[i] = new Option(data.users[i].name+' ('+data.users[i].email+')','"'+data.users[i].name+'" <'+data.users[i].email+'>');
+				}
+				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;
+				}
 			}
 	
@@ -488,5 +550,5 @@
 
 		Element('msg_search').style.visibility = 'visible';
-		cExecute ("$this.ldap_functions.catalogsearch&max_result="+max_result+"&organization="+organization+"&search_for="+search, handler_searchResults);
+		cExecute ("$this.ldap_functions.catalogsearch&max_result="+max_result+"&organization="+organization+"&search_for="+search+"&catalog="+catalog, handler_searchResults);
 	}
 
