Index: branches/2.4/expressoMail1_2/js/QuickCatalogSearch.js
===================================================================
--- branches/2.4/expressoMail1_2/js/QuickCatalogSearch.js	(revision 6631)
+++ branches/2.4/expressoMail1_2/js/QuickCatalogSearch.js	(revision 6754)
@@ -14,5 +14,5 @@
 		});
 	});	   
-
+	
 	/* showlist */	
 	emQuickCatalogSearch.prototype.showList = function(data, begin, end, ID, field)
@@ -125,7 +125,7 @@
 		switch(data_['type_catalog']) {
 			case 'G':
-				  if(data_['extra_ldap_fields'] != undefined){ 
- 	                                  if(data_['extra_ldap_fields'].length != 0) 
- 	                                          var extra_fields = (data_['extra_ldap_fields']).split("#");  
+				if(data_['extra_ldap_fields'] != undefined){
+					if(data_['extra_ldap_fields'].length != 0)
+						var extra_fields = (data_['extra_ldap_fields']).split("#");   
 					else
 						var extra_fields = [];  
@@ -149,4 +149,16 @@
 					}
 				}
+				if (data_[id_contact].vacationactive == "TRUE"){
+					details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>');	
+					if ( data_[id_contact].vacationinfo ){
+						details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data_[id_contact].vacationinfo +'</span></div></div>');
+						if ( $('.outoffice-inner').height() > $('.outoffice').height() ){						
+							var link = $('<a>').html('Ver mais');
+							link.attr('id','more');
+							link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();});
+							details.append(link);
+						}
+					}
+				}
 				break;
 			case 'P':
@@ -157,9 +169,21 @@
                 if(data_[id_contact].telephonenumber != null)
                     details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + data_[id_contact].telephonenumber + '</span></p>');
+				if (data_[id_contact].vacationactive == "TRUE"){
+					details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>');	
+					if (data_[id_contact].vacationinfo){
+						details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data_[id_contact].vacationinfo +'</span></div></div>');
+						if ( $('.outoffice-inner').height() > $('.outoffice').height() ){
+							var link = $('<a>').html('Ver mais');
+							link.attr('id','more');
+							link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();});
+							details.append(link);
+						}
+					}
+				}	
 				break;
 			default:
-				if(data_['extra_ldap_fields'] != undefined){ 
- 	                                if(data_['extra_ldap_fields'].length != 0) 
- 	                                        var extra_fields = (data_['extra_ldap_fields']).split("#");    
+				if(data_['extra_ldap_fields'] != undefined){
+					if(data_['extra_ldap_fields'].length != 0)
+						var extra_fields = (data_['extra_ldap_fields']).split("#");   
 					else
 						var extra_fields = [];   
@@ -190,4 +214,16 @@
 					}
 				}
+				if (data_[id_contact].vacationactive == "TRUE"){
+					details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>');	
+					if (data_[id_contact].vacationinfo){
+						details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data_[id_contact].vacationinfo +'</span></div></div>');
+						if ( $('.outoffice-inner').height() > $('.outoffice').height() ){
+							var link = $('<a>').html('Ver mais');
+							link.attr('id','more');
+							link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();});
+							details.append(link);
+						}
+					}	
+				}				
 			break;
 		}				
@@ -255,6 +291,11 @@
 			var signal = "+";
 			var btnClass = "add";
-			var emailList = content.find(field_).val();
-			var emails_adicionados = emailList.split(",");
+			emails_adicionados = "";
+			var emailList = content.find(field_).filter("input").parent().find("div input");
+			//	var array = content.find(".to-tr").find(".box");
+			$.each(emailList, function(index, value){
+				emails_adicionados += $(value).val() + ",";
+			});
+			emails_adicionados = emails_adicionados.split(",");
 			for(aux=0; aux<emails_adicionados.length -1; aux++) {
 				if(emails_adicionados[aux].match(/<([^<]*)>[\s]*$/)){
@@ -279,5 +320,8 @@
 			else if(contact_name.toLowerCase().indexOf(data.search_for.toLowerCase()) != -1 && data.search_for.indexOf(" ") == -1 && data.search_for.indexOf("@") == -1)									
 				contact_name = contact_name.substring(0, contact_name.toLowerCase().indexOf(data.search_for.toLowerCase())) + "<u>" + contact_name.substr(contact_name.toLowerCase().indexOf(data.search_for.toLowerCase()), data.search_for.length) + "</u>" + contact_name.substring(contact_name.toLowerCase().indexOf(data.search_for.toLowerCase()) + data.search_for.length);
-			var line = '<span class="menu-control"><button class="'+btnClass+'" id="actions_'+i+'" onClick="'+exist+'(document.getElementById(\'contact_' + i + '\').innerHTML, this, \'contact_' + i + '\')">'+ signal +'</button></span><div id="contact_' + i + '" onDblClick="'+exist+'(this.innerHTML, document.getElementById(\'actions_'+i+'\'), \'contact_' + i + '\')"><div class="name_contact"><strong class="name">' + contact_name + '</strong><em class="email">' + ((utf8_decoder(data[i-1].mail) != undefined)? (utf8_decoder(data[i-1].mail) == 'undefined' ? get_lang("No mail") : utf8_decoder(data[i-1].mail)) : get_lang("No mail")) + '</em></div></div>';
+			var vacationImg = '';
+			if (data[i-1].vacationactive == "TRUE")
+				vacationImg = '<img src="templates/default/images/mala-small.png"/>';	
+			var line = '<span class="menu-control"><button class="'+btnClass+'" id="actions_'+i+'" onClick="'+exist+'(document.getElementById(\'contact_' + i + '\').innerHTML, this, \'contact_' + i + '\')">'+ signal +'</button></span><div id="contact_' + i + '" onDblClick="'+exist+'(this.innerHTML, document.getElementById(\'actions_'+i+'\'), \'contact_' + i + '\')"><div class="name_contact"><strong class="name">' + contact_name +' '+ vacationImg +'</strong><em class="email">' + ((utf8_decoder(data[i-1].mail) != undefined)? (utf8_decoder(data[i-1].mail) == 'undefined' ? get_lang("No mail") : utf8_decoder(data[i-1].mail)) : get_lang("No mail")) + '</em></div></div>';
 			Op.innerHTML = line;
             $(Op).val(i - 1);
@@ -317,5 +361,17 @@
 						}
 					}
-				}			
+				}
+				if (data[first_contact].vacationactive == "TRUE"){
+					details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>');	
+					if ( data[first_contact].vacationinfo ){
+						details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[first_contact].vacationinfo +'</span></div></div>');
+						if ( $('.outoffice-inner').height() > $('.outoffice').height() ){						
+							var link = $('<a>').html('Ver mais');
+							link.attr('id','more');
+							link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();});
+							details.append(link);
+						}	
+					}	
+				}							
 				break;
 			case 'P':
@@ -326,4 +382,16 @@
                 if(data[first_contact].telephonenumber != null)
 					details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + data[first_contact].telephonenumber  + '</span></p>');
+				if (data[first_contact].vacationactive == "TRUE"){
+					details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>');	
+					if ( data[first_contact].vacationinfo ){
+						details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[first_contact].vacationinfo +'</span></div></div>');
+						if ( $('.outoffice-inner').height() > $('.outoffice').height() ){
+							var link = $('<a>').html('Ver mais');
+							link.attr('id','more');
+							link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();});
+							details.append(link);
+						}	
+					}
+				}				
 				break;
 			default:	
@@ -358,8 +426,20 @@
 					}
 				}
+				if (data[first_contact].vacationactive == "TRUE"){
+					details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>');	
+					if ( data[first_contact].vacationinfo ){
+						details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[first_contact].vacationinfo +'</span></div></div>');
+						if ( $('.outoffice-inner').height() > $('.outoffice').height() ){						
+							var link = $('<a>').html('Ver mais');
+							link.attr('id','more');
+							link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();});
+							details.append(link);
+						}	
+					}
+				}				
 				break;
 		}
-		var string_results = sliderValue + " " + get_lang("of") + " " + paginas + " (" + data.length + " " + get_lang("Results") + ")"; 
- 	        $( "#amount-text" ).val( string_results ).attr('readonly', true);
+		var string_results = sliderValue + " " + get_lang("of") + " " + paginas + " (" + data.length + " " + get_lang("Results") + ")";
+		$( "#amount-text" ).val( string_results ).attr('readonly', true);
 		$("button").button();
 		//$("button.remove").button({icons:{primary:"ui-icon-close"}, text: false});
@@ -389,7 +469,7 @@
 									}else
 										var extra_fields = [];   
-									if(preferences.default_fields_quick_search != 0 && data[this.value] ) {
-											details.append('<p><label class="attribute">' + utf8_decoder(data[this.value].cn[0]) + "</label>" + '<span class="value">' + (data[this.value].mail ? data[this.value].mail[0] : "")+ "</span></p>");
-										if(data[this.value].telephonenumber )
+									if(preferences.default_fields_quick_search != 0 && data[this.value] ) { 
+ 	                                    details.append('<p><label class="attribute">' + utf8_decoder(data[this.value].cn[0]) + "</label>" + '<span class="value">' + (data[this.value].mail ? data[this.value].mail[0] : "")+ "</span></p>");
+ 										if(data[this.value].telephonenumber )
 											details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + (data[this.value].telephonenumber ? data[this.value].telephonenumber[0] : "")+ "</span></p>");
 									}
@@ -405,4 +485,16 @@
 										}
 									}
+									if (data[this.value].vacationactive == "TRUE"){
+										details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>');	
+										if ( data[this.value].vacationinfo ){
+											details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[this.value].vacationinfo +'</span></div></div>');
+											if ( $('.outoffice-inner').height() > $('.outoffice').height() ){											
+												var link = $('<a>').html('Ver mais');
+												link.attr('id','more');
+												link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();});
+												details.append(link);
+											}
+										}
+									}									
 									break;
 								case 'P':
@@ -413,9 +505,21 @@
 									if(data[this.value].telephonenumber != null)
 										details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + data[this.value].telephonenumber + "</span></p>");
+									if (data[this.value].vacationactive == "TRUE"){
+										details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>');	
+										if ( data[this.value].vacationinfo ){
+											details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[this.value].vacationinfo +'</span></div></div>');
+											if ( $('.outoffice-inner').height() > $('.outoffice').height() ){
+												var link = $('<a>').html('Ver mais');
+												link.attr('id','more');
+												link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();});
+												details.append(link);
+											}	
+										}
+									}									
 									break;
 								default:
-  									if(this.value == undefined) 
- 		                                                                break; 
-
+									if(this.value == undefined)
+										break;
+										
 									if(data['extra_ldap_fields'].length != 0)
 										var extra_fields = (data['extra_ldap_fields']).split("#");   
@@ -447,4 +551,16 @@
 										}
 									}
+									if (data[this.value].vacationactive == "TRUE"){
+										details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>');	
+										if ( data[this.value].vacationinfo ){
+											details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[this.value].vacationinfo +'</span></div></div>')
+											if ( $('.outoffice-inner').height() > $('.outoffice').height() ){
+												var link = $('<a>').html('Ver mais');
+												link.attr('id','more');
+												link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();});
+												details.append(link);
+											}
+										}	
+									}									
 									break;
 							}
@@ -587,5 +703,4 @@
 		var nome = $(contact).clone().find('.name').text();
 		var email = $(contact).clone().find('.email').text();
-		
 		if(email == get_lang("No mail")){
 			alert(get_lang("It is not possible to add this contact as a recipient because it does not have email"));
@@ -594,30 +709,22 @@
 			return;
 		}
-		
 		verifyEmails(email, divs);
-		
-		final_contact = "\""+nome +"\" <"+email+">, ";
-		
-		var emailList      = content.find(field_).val();
-		//remove os caracteres da busca
-		emailList = emailList.substr(0,emailList.lastIndexOf(',')+1); 
-		
-        if (emailList[0] != '"' && emailList.indexOf(",") < 0)
-			emailList = emailList.substr(end_);
-        if(emailList.lastIndexOf(",") > 0){
-		if(emailList.substr(emailList.length-1, emailList.length) == "," || emailList.substr(emailList.length-2, 1) == ","){
-			emailList = emailList.substr(0, emailList.lastIndexOf(",") + 1);
-        	} else {
-			emailList = emailList.substr(0, emailList.lastIndexOf("") + 1);		
-			final_contact = ","+final_contact;
+		final_contact = "\""+nome +"\" <"+email+">";
+
+		final_contact = final_contact.replace(/\/n/, ""); 
+		var index = parseInt(divs.split("_")[1])-1;
+		if(data_[index].type_contact == "G"){
+			var ldap_id = preferences.expressoMail_ldap_identifier_recipient;
+			if(ldap_id){
+				draw_email_box(
+					(data_[index][ldap_id.toLowerCase()] ? data_[index][ldap_id.toLowerCase()][0] : final_contact)
+					, content.find(field_).filter("input")
+				);
+			}else{
+				draw_email_box(final_contact, content.find(field_).filter("input"));
+			}
+		}else{
+			draw_email_box((data_[index].id_contact ? data_[index].id_contact : data_[index].id), content.find(field_).filter("input"), (data_[index].id_contact ? true : "G"));
 		}
-	}
-
-		final_contact = final_contact.replace(/\/n/, "");
-		new_emailList = emailList + final_contact;    
-        content.find(field_).val(new_emailList);
-		
-		content.find(field_).trigger("update");
-		
 		content.find(field_).filter("input").val("");
 		button.onclick = function(){
@@ -625,9 +732,7 @@
 		};
 		var div = document.getElementById(divs);
-		
 		div.ondblclick = function(){
 			remove_contact_field(div.innerHTML, button, divs);
 		};
-		
 		button.innerHTML = '<span class="ui-button-text" style="">x</span>';
     }
@@ -639,43 +744,21 @@
 	function remove_contact_field(contact, button, divs) {
 		var email = $(contact).clone().find('.email').text();
-		var exist = false;
-		
-		var emailList = content.find(field_).val();
-		var emails_adicionados = emailList.split(",");
-		
-		verifyEmails(email, divs);
-		
-		for(i=0; i<emails_adicionados.length -1; i++) {
-
-			if(emails_adicionados[i].match(/<([^<]*)>[\s]*$/)){
-				if(emails_adicionados[i].match(/<([^<]*)>[\s]*$/)[1].toLowerCase() == email.toLowerCase()) {
-					emails_adicionados[i] = "%";
-					exist = true;
-				}
-			}else{
-				if(emails_adicionados[i].toLowerCase() == email.toLowerCase()) {
-					emails_adicionados[i] = "%";
-					exist = true;
-				}
-			}
-		}
-		
-		if (exist == false) 
-			return false;
-		var novos_contatos = emails_adicionados.join(",");  
-		novos_contatos = novos_contatos.replace(/%,/g, "");
-		content.find(field_).val(novos_contatos);
-		
+		var array = content.find(field_).parent().find("div input");
+		$.each(array, function(index, value){
+			var validated_email = $(value).val();
+			if(validated_email.match(/<([^<]*)>[\s]*$/)){
+				if(validated_email.match(/<([^<]*)>[\s]*$/)[1].toLowerCase() == email.toLowerCase()) {
+					$(value).parent().remove();
+				}
+			}
+		});
+	
 		button.onclick = function(){
 			add_contact_field(document.getElementById(divs).innerHTML, button, divs);
 		};
-		
 		var div = document.getElementById(divs);
-		
 		div.ondblclick = function(){
 			add_contact_field(div.innerHTML, button, divs);
 		};
-		
-		content.find(field_).trigger("update");
 		button.innerHTML = '<span class="ui-button-text" style="">+</span>';
 	}
