Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 6487)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 6528)
@@ -1495,5 +1495,5 @@
 		if ((headers_msgs.Forwarded == 'F')  || (headers_msgs.Draft == 'X' && headers_msgs.Answered == 'A')){
 			td_element21.onclick=function(){search_emails(headers_msgs.subject.replace(/^(re: ?|fw: ?|enc: ?|res: ?|fwd: ?)*/gi,''),true);};
-                        td_element21.innerHTML = "<img src ='templates/"+template+"/images/forwarded.gif' title='"+get_lang('Forwarded')+"'>";
+                        td_element21.innerHTML = "<img src ='templates/"+template+"/images/forwarded.png' title='"+get_lang('Forwarded')+"'>";
 			headers_msgs.Draft = ''
 			headers_msgs.Answered = '';
@@ -1501,8 +1501,8 @@
 		}
 		else if (headers_msgs.Draft == 'X')
-			td_element21.innerHTML = "<img src ='templates/"+template+"/images/draft.gif' title='"+get_lang('Draft')+"'>";
+			td_element21.innerHTML = "<img src ='templates/"+template+"/images/draft.png' title='"+get_lang('Draft')+"'>";
 		else if (headers_msgs.Answered == 'A'){
                         td_element21.onclick=function(){search_emails(headers_msgs.subject.replace(/^(re: ?|fw: ?|enc: ?|res: ?|fwd: ?)*/gi,''),true);};
-			td_element21.innerHTML = "<img src ='templates/"+template+"/images/answered.gif' title='"+get_lang('Answered')+"'>";
+			td_element21.innerHTML = "<img src ='templates/"+template+"/images/answered.png' title='"+get_lang('Answered')+"'>";
                     }else
 			td_element21.innerHTML = "&nbsp;&nbsp;&nbsp;";
@@ -3540,54 +3540,521 @@
 }
 
-function input_binds(input, ID){
-	var mySource = new Array();
-	var myArray = contacts.split(",");
-	for(var i in myArray){
-		var teste = myArray[i].split(";");
-		if(teste.length > 1)
-			mySource.push({name : teste[0], email: teste[1], value : (teste[0] +" - "+teste[1])});
-		else
-			mySource.push({name : "", email: teste[0], value :teste[0]});
-	}
-	input.bind( "keydown", function( event ) {
-		if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) {
-			event.preventDefault();
-		}
-		if((event.keyCode) == 120){
+//DESENHO DAS CAIXA DE EMAIL
+function draw_email_box(input_data, location, personal){
+	if($.trim(input_data) != ""){
+		var box_data = valid_emails(input_data);
+		DataLayer.render("../prototype/modules/mail/templates/emailBox.ejs", box_data, function(html){
+			var newBox = location.before(html).prev();
+			box_actions(newBox);
+			if((preferences.expressoMail_ldap_identifier_recipient || personal)&& $(newBox).hasClass("invalid-email-box")){
+				//$(newBox).find(".loading").css("background-image", "../prototype/modules/mail/img/ajax-loader.gif");
+				show_detais(newBox, input_data, personal);
+			}else{
+				$(newBox).find(".box-loading").remove();
+			}
+		});
+	}
+}
+
+function valid_emails(email){
+	var ContactBox = {name:"", email:"", valid : false};
+	var reSimpleEmail = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[_a-z0-9-]+(\.[_a-z0-9-]+)+$/;
+	var reComplexEmail = /<([^<]*)>[\s]*$/;
+	var validation = email.split('"');
+	
+	//FUNÇÃO QUE VALIDA OS DADOS QUANDO O EMAIL É DIGITADO COM ("NOME SOBRENOME" <Email@dominio.com>)
+	var complexValidation = function(complexMail){
+		var Objct = {};
+		if($.trim(complexMail[1]).match(reComplexEmail)){
+			if($.trim(complexMail[1]).match(reComplexEmail).length){
+				Objct['email'] = $.trim(complexMail[1]).match(reComplexEmail)[1];
+			}
+		}else{
+			Objct['email'] = $.trim(complexMail[1]);
+		}
+		Objct['name'] = complexMail[0];
+		Objct['valid'] = reSimpleEmail.test(Objct['email'].toLowerCase());
+		return Objct;
+	}
+	switch (validation.length) {
+		//PEGA TODO O CONTEUDO E SETA COMO SE FOSSE O EMAIL
+		case 1:
+			validation.unshift("");
+			ContactBox = complexValidation(validation);
+			break;
+		//CORRIGI ERRO DE DIGITAÇÃO COMO ( huahua"<huhau@hauhau.com>) ou (hahahaha"huahua@email.com) ou ainda (hahahaha"huahua@ema  il.com)
+		case 2: 
+			ContactBox = complexValidation(validation);
+			break;
+		//RECEBE O EMAIL CORRETAMENTE SÓ VALIDA POSSIVEIS ERROS COMO O DE CIMA E OS CORRIGI CASO ACONTEÇAM
+		case 3:
+			//RETIRA O PRIMEIRO INDICE QUE FICOU "INUTIL"
+			validation.shift();
+			ContactBox = complexValidation(validation);
+			break;
+		//SE EXISTIREM MAIS DO QUE 2 (")
+		default:
+			if($.trim(validation[validation.length-1]).match(reComplexEmail)){
+				if($.trim(validation[validation.length-1]).match(reComplexEmail).length){
+					ContactBox.mail = $.trim(validation[validation.length-1]).match(reComplexEmail)[1];
+				}
+			}else{
+				ContactBox.mail = $.trim(complexMail[1]);
+			}
+			ContactBox.valid = reSimpleEmail.test(ContactBox.mail.toLowerCase());	
+	}
+	return ContactBox;
+}
+
+//EVENTO DOS INPUTS PARA - CC - CCO
+function input_keydowns(input, ID){
+	var f9 = false;
+	input.keydown(function(e){
+		f9 = false;
+		var focusing = input.parent().find(".email-text");
+		//SE OS CONTATOS DINAMICOS ESTAO ATIVOS
+		if(parseInt(preferences.use_dynamic_contacts) && !input.hasClass("box-input")){
+			//SELECIONA O CONTATO E EVITA OUTROS COMANDOS
+			if ( e.keyCode === $.ui.keyCode.TAB && $( this ).data( "catcomplete" ).menu.active ) {
+				e.preventDefault();
+				return false;
+			}		
+			
+			//FECHA OS CONTATOS DINÂMICOS
+			if( (e.keyCode == 27) && $( this ).data( "catcomplete" ).menu.active ){
+				   e.stopPropagation();
+				   e.preventDefault();
+			}
+			
+			//SELECIONA O CONTATO E EVITA OUTROS COMANDOS
+			if(e.keyCode == $.ui.keyCode.ENTER && $( this ).data( "catcomplete" ).menu.active){
+				e.preventDefault();
+				return false;
+			}
+			
+			if(e.keyCode == $.ui.keyCode.DELETE && $( this ).data( "catcomplete" ).menu.active){
+				if($($( this ).data( "catcomplete" ).menu.element).find(".ui-state-hover").parents("li:first").hasClass("dynamic-recent"))
+					$($( this ).data( "catcomplete" ).menu.element).find(".ui-state-hover").next().trigger("click");
+				return false;
+			}
+		}
+		//BUSCA COM A TECLA F9
+		if((e.keyCode) == 120){
+			f9 = true;
 			emQuickSearch($(this).val(), "."+$(this).parents("tr:first").attr('class').split("-")[0], ID, undefined, true);
-		}else if( (event.keyCode == 27) && $( this ).data( "autocomplete" ).menu.active ){
-			   event.stopPropagation();
-               event.preventDefault();
-		}
-	}).autocomplete({
-		minLength: 0,			
-		source: function( request, response ) {
-			response( $.ui.autocomplete.filter(
-				mySource, extractLast( request.term ) ) );
+			e.preventDefault();
+			return false;
+		}
+
+		//AO DIGITAR ENTER, ";", "," "	"
+		if(e.keyCode == 13 || e.keyCode == 9 || (e.keyCode == 188 && !e.shiftKey) || (e.keyCode == 191 && !e.shiftKey) ){
+			if(e.keyCode == 13){
+				e.preventDefault();
+			}
+			if(input.val() != ""){
+				if(e.keyCode != 9)
+					e.preventDefault();
+				draw_email_box(input.val(), input);
+				if(input.hasClass("box-input")){
+					input.remove();
+					focusing.focus();
+					return;
+				}
+			}
+			if(input.length)
+				input.val("");
+		}
+		if((e.keyCode == 8 || e.keyCode == 37) && input.val() == "" && input.prev().hasClass("box")){
+			e.preventDefault();
+			input.prev().focus();
+			return;
+		}
+		//AO DIGITAR " "
+		if(e.keyCode == 32){
+			if(!input.val().length){
+				e.preventDefault();
+				return;
+			}else{
+				var texto = input.val();
+				texto = texto.substring(0, getPosition(input[0]));
+				if(texto.split('"').length-1 == 0){
+					if(input.val().split('"').length-1 == 0){
+						e.preventDefault();
+						e.stopPropagation();
+						draw_email_box(input.val(), input);
+						input.val("");
+						if(input.hasClass("box-input")){
+							input.remove();
+							focusing.focus();
+							return;
+						}
+						return;
+					}
+				}
+			}
+		}
+		//AO DIGITAR ">"
+		if(e.keyCode == 190 && e.shiftKey && input.val().length == getPosition(input[0])){
+			input.val(input.val()+">");
+			draw_email_box(input.val(), input);
+			e.preventDefault();
+			input.val("");
+			if(input.hasClass("box-input")){
+				input.remove();
+				focusing.focus();
+				return;
+			}
+		}
+		
+		//INPUT AUTO RESIZE	
+		setTimeout(function(){
+			input.css("width", 15+(input.val().length * 9));	
+			input.parent().scrollTo(":last");	
+		}, 100);
+	})
+	//AO SAIR DO FOCO MONTAGEM DA CAIXA DE EMAIL
+	.focusout(function(){
+		if(!$(this).data('is_open')){
+			if(!(f9 || $(this).parents("tr:first").find("button").hasClass("ui-state-active"))){
+				if($(input).val() != "")
+					draw_email_box(input.val(), input);
+				if(input.hasClass("box-input"))
+					input.remove();
+			}
+		
+			input_search = $(input).val();
+			$(input).val("");
+		}
+	})
+	//AO COLAR UM TEXTO NO CAMPO
+	.bind("paste", function(e){
+		$(this).trigger("keydown");
+		var pthis = $(this);
+		setTimeout(function() {
+			var str = pthis.val().replace(/[,;\t\n]/gi, ",");
+			str = str.split(",");
+			$.each(str, function(index, value){
+				draw_email_box(value, pthis);
+			});
+			pthis.val("");
+		}, 50);
+	});
+	//SE FOR EDIÇÃO DE EMAILS RECALCULA O INPUT E SETA O FOCO
+	if(input.hasClass("box-input")){
+		input.trigger("keydown");
+		input.focus();
+	}
+}
+var input_search = "";
+//EVENTOS DA CAIXA
+function box_actions(box){
+	//AO PRESSIONAR UMA TECLA COM A CAIXA SELECIONADA	
+	box.keydown(function(e){
+		switch (e.keyCode) {
+			case $.ui.keyCode.LEFT:
+				//VERIFICA SE EXISTE ALGUMA CAIXA A ESQUERDA
+				if($(this).prev().hasClass("box"))
+					$(this).removeClass("box-selected").prev().focus();
+				break;
+			case $.ui.keyCode.RIGHT:
+				//VERIFICA SE EXISTE ALGUMA CAIXA A DIREITA 
+				if($(this).next().hasClass("box"))
+					$(this).removeClass("box-selected").next().focus();
+				//SENAO FOCO O INPUT DO EMAIL
+				else
+					$(this).removeClass("box-selected").next().focus();
+				break;
+			case $.ui.keyCode.HOME:
+				//SELECIONO A PRIMEIRA CAIXA
+				e.preventDefault();
+				$(this).parents(".email-area").find("div:first").focus();
+				break;
+			case $.ui.keyCode.END:
+				//SELECIONO A ULTIMA CAIXA
+				e.preventDefault();
+				$(this).parents(".email-area").find("div:last").focus();
+				break;
+			case $.ui.keyCode.DELETE:
+				//VERIFICA SE EXISTE ALGUMA CAIXA A DIREITA
+				if($(this).next().hasClass("box"))
+					$(this).next().focus();
+				//SENAO FOCO O INPUT DO EMAIL
+				else
+					$(this).next().focus();
+				//REMOVO ESTA CAIXA
+				$(this).remove();
+				break;
+			case $.ui.keyCode.BACKSPACE:
+				//VERIFICA SE EXISTE ALGUMA CAIXA A ESQUERDA
+				if($(this).prev().hasClass("box"))
+					$(this).removeClass("box-selected").prev().focus();
+				//SENAO HOUVER VERIFICA SE EXISTE ALGUMA CAIXA A DIREITA
+				else if($(this).next().hasClass("box"))
+					$(this).next().focus();
+				//SENAO HOUVER NEM A DIREITA NEM A ESQUERDA SETO O FOCO NO INPUT DO EMAIL
+				else
+					$(this).next().focus();
+				//REMOVO ESTA CAIXA	
+				$(this).remove();
+				e.preventDefault();
+				break;
+			case $.ui.keyCode.ENTER:
+				e.preventDefault();
+				$(this).trigger("dblclick");
+				break;
+		}
+	})
+	//AO FAZER UM DUPLO CLICK NA CAIXA
+	.dblclick(function(e){
+		var input = $(this).find("input").clone();
+		input.css("display" , "inline-block");
+		$(this).before(input);
+		input_keydowns(input, currentTab);
+		$(this).remove();
+	//CLICK SIMPLES NA CAIXA
+	}).click(function(){
+		$(this).focus();
+	//AO DAR O FOCO NA CAIXA
+	}).focus(function(){
+		$(this).parent().find("div").removeClass("box-selected");
+		$(this).addClass("box-selected");
+	}).focusout(function(){
+		$(this).removeClass("box-selected");
+	}).draggable({
+		revert: 'invalid',
+		helper : 'clone',
+		stack: "body",
+		containment : ".new-msg-head-data",
+		start: function(e, ui){
+			$(this).parent().droppable( "disable" );
 		},
-		focus: function() {
-			return false;
-		},
-		select: function( event, ui ) {
-			var terms = mySplit( this.value );
-			terms.pop();
-			terms.push( (ui.item.name != "" ? "\""+ui.item.name+"\" " : "") + (ui.item.email ? "<"+ui.item.email+">" : ""));
-			terms.push( "" );
-			this.value = terms.join( ", " );
-			return false;
-		},
-		autoFocus: true
-	}).data( "autocomplete" )._renderItem = function( ul, item ) {
-		ul.css({"max-height" : "115px", "overflow-y" : "auto"});
-		if( $(ul).find("li").length > 10 ){
-			return;
-		}
-		return $( "<li></li>" )
-			.data( "item.autocomplete", item )
-			.append( "<a>" + item.name + " - " + item.email + "</a>" )
-			.appendTo( ul );
-	};
-	input.parents("tr:first").find("button").button().click(function(){
-		emQuickSearch($(this).parents("tr:first").find("textarea").val(), "."+$(this).parents("tr:first").attr('class').split("-")[0], ID, undefined, true);
+		stop : function(e, ui){
+			$(this).parent().droppable( "enable" );
+		}
+	});
+}
+
+//MOSTRA OS DETALHES DAS CAIXA DE EMAIL NOS CAMPOS PARA - CC - CCO
+function show_detais(box, value, personal){
+	var ldap_id = preferences.expressoMail_ldap_identifier_recipient;
+	var group = (personal != undefined ? (personal == "G" ? true : false) : false);
+	
+	if(group){
+		REST.get("/group/"+value, {}, function(data){
+			if(!data.error){
+				if(data.collection.error)
+					box.find(".box-loading").remove();
+				else{
+					//box.find(".box-loading").css("background-image", "url(templates/default/images/information.png) no-repeat! !important");
+					box.find(".box-loading").removeClass("box-loading").addClass("box-info");
+					box.addClass("box-"+value).removeClass("invalid-email-box");
+					loadGroupBox(data.collection, ".box-"+value);
+					box.unbind("dblclick").bind("dblclick", function(e){
+						new $.Zebra_Dialog('<strong>Impossivel editar</strong> um contato do catálogo pessoal\n' +
+							'<strong>Porém</strong> é possivel remove-lo', {
+							'buttons':  false,
+							'modal': false,
+							'position': ['right - 20', 'top + 20'],
+							'auto_close': 3000
+						});
+					}).find(".box-input").val("\""+data.collection.data[1].value+"\" <"+data.collection.data[1].value+">");
+					box.find(".email-box-value").html( (data.collection.data[1].value.length > 18 ? data.collection.data[1].value.substring(0, 15)+"...": data.collection.data[1].value))
+				}
+			}else{
+				box.find(".box-loading").remove();
+			}
+		});
+		return;
+	}
+	
+	if(personal){
+		REST.get("/contact/"+value, {}, function(data){
+			if(!data.error){
+				if(data.collection.error)
+					box.find(".box-loading").remove();
+				else{
+					//box.find(".box-loading").css("background-image", "url(templates/default/images/information.png) no-repeat! !important");
+					box.find(".box-loading").removeClass("box-loading").addClass("box-info");
+					box.addClass("box-"+value).removeClass("invalid-email-box");
+					loadExtraLDAPBox(data.collection.data, ".box-"+value);
+					box.unbind("dblclick").bind("dblclick", function(e){
+						new $.Zebra_Dialog('<strong>Impossivel editar</strong> um contato do catálogo pessoal\n' +
+							'<strong>Porém</strong> é possivel remove-lo', {
+							'buttons':  false,
+							'modal': false,
+							'position': ['right - 20', 'top + 20'],
+							'auto_close': 3000
+						});
+					}).find(".box-input").val("\""+data.collection.data[0].value+"\" <"+data.collection.data[1].value+">");
+					box.find(".email-box-value").html( (data.collection.data[0].value.length > 18 ? data.collection.data[0].value.substring(0, 15)+"...": data.collection.data[0].value))
+				}
+			}else{
+				box.find(".box-loading").remove();
+			}
+		});
+		return;
+	}
+	
+	REST.get("/usersldap", {field : ldap_id,value: value}, function(data){
+		if(!data.error){
+			if(data.collection.error)
+				box.find(".box-loading").remove();
+			else{
+				//box.find(".box-loading").css("background-image", "url(templates/default/images/information.png) no-repeat! !important");
+				box.find(".box-loading").removeClass("box-loading").addClass("box-info");
+				box.addClass("box-"+value).removeClass("invalid-email-box");
+				loadExtraLDAPBox(data.collection.itens[0].data, ".box-"+value);
+				box.unbind("dblclick").bind("dblclick", function(e){
+					new $.Zebra_Dialog('<strong>Impossivel editar</strong> um contato do catálogo geral\n' +
+						'<strong>Porém</strong> é possivel remove-lo', {
+						'buttons':  false,
+						'modal': false,
+						'position': ['right - 20', 'top + 20'],
+						'auto_close': 3000
+					});
+				}).find(".box-input").val("\""+data.collection.itens[0].data[0].value+"\" <"+data.collection.itens[0].data[1].value+">");
+				box.find(".email-box-value").html( (data.collection.itens[0].data[0].value.length > 18 ? data.collection.itens[0].data[0].value.substring(0, 15)+"...": data.collection.itens[0].data[0].value))
+			}
+		}else{
+			box.find(".box-loading").remove();
+		}
+	});
+}
+
+//FUNÇÃO QUE "SETA" OS BINDS DOS CAMPOS PARA - CC - CCO
+function input_binds(div, ID){
+
+	//AO CLICAR NA DIV SETA O FOCO NO INPUT
+	div.click(function(e){
+		if(e.target == $(this)[0]){
+			$(this).find("input:last").focus();
+			$(this).find("div").removeClass("box-selected");
+		}
+	})
+	
+	//AO SAIR DO FOCO DA DIV ELE RETIRA TODAS AS CLASSES DE CAIXAS SELECIONADAS
+	.focusout(function(e){
+		if(!$(e.target).parents(".email-area:first").length)
+			$(this).find("div").removeClass("box-selected");
+	}).droppable({
+		hoverClass: "box-draggable-hover",
+		accept : ".box",
+		drop : function(e, ui){
+			ui.draggable.parent().droppable( "enable" );
+			var box = ui.draggable.clone();
+			box_actions(box);
+			if(box.find(".box-info").length){
+				box.unbind("dblclick").bind("dblclick", function(e){
+					new $.Zebra_Dialog('<strong>Impossivel editar</strong> um contato do ldap\n' +
+						'<strong>Porém</strong>é possivel remove-lo', {
+						'buttons':  false,
+						'modal': false,
+						'position': ['right - 20', 'top + 20'],
+						'auto_close': 3000
+					});
+				});
+			}
+			$(this).prepend(box);
+			ui.draggable.remove();
+		}
+	});
+	
+	//MAKE KEYDOWN
+	input_keydowns(div.find("input"), ID);
+	
+	
+	//VERIFICA PREFERENCIA DE CONTATOS DINÂMICOS ESTA ATIVA
+	if(parseInt(preferences.use_dynamic_contacts)){
+		//PREPARAÇÃO DA ARRAY DOS CONTATOS DINÂMICOS
+
+		$.widget( "custom.catcomplete", $.ui.autocomplete, {
+			_renderMenu: function( ul, items ) {
+				var self = this,
+				currentType = "";
+				$.each( items, function( index, item ) {
+					if ( item.type != currentType) {
+						if(item.type == "G" && $(ul).find(".dynamic-recent").length)
+							self._renderItem( ul, {name:"", value:"", type:"linha"} );
+						if(item.type == "P" && $(ul).find(".dynamic-group").length)
+							self._renderItem( ul, {name:"", value:"", type:"linha"} );	
+						currentType = item.type;
+					}
+					self._renderItem( ul, item );
+					$(ul).find("li:last").find(".dynamic-stars").raty({
+						readOnly : true,
+						half : true,
+						hints : ['','','','',''],
+						score    : ((parseInt(item.qtd)*5)/topContact),
+						starOn  : '../../prototype/plugins/jq-raty/img/star-on.png',
+						starOff : '../../prototype/plugins/jq-raty/img/star-off.png',
+						starHalf : '../../prototype/plugins/jq-raty/img/star-half.png'
+					});
+				});
+			}
+		});
+		//INSERÇÃO DO AUTO COMPLETE AO INPUT
+		div.find("input").catcomplete({
+			minLength: 1,			
+			source: function(request, response){
+				response( $.ui.autocomplete.filter(dynamicContactList, request.term ) );
+			},
+			focus: function() {
+				return false;
+			},
+			
+			//EVENTO AO SELECIONAR UM CONTATO DINÂMICO
+			select: function( event, ui ) {
+				event.preventDefault();
+				$(this).val("");
+				if(ui.item.type == "P")
+					draw_email_box(""+ui.item.id, $(this), true);
+				else if(ui.item.type == "G")
+					draw_email_box(""+ui.item.id, $(this), "G");
+				else
+					draw_email_box(ui.item.name ? "\""+ui.item.name+"\" <"+ui.item.email+">" : ui.item.email, $(this));
+				return false;
+			},
+			autoFocus: true,
+			position : { my: "left top", at: "left bottom", collision: "fit" }
+		}).bind('catcompleteopen', function(event, ui) {
+			$(this).data('is_open',true);
+		}).bind('catcompleteclose', function(event, ui) {
+			$(this).data('is_open',false);
+		})
+		
+		//MONTAGEM DA LISTA DE CONTATOS DINÂMICOS DO AUTO COMPLETE
+		.data( "catcomplete" )._renderItem = function( ul, item ) {
+			ul.css({"min-width":"400px", "width":"50%", "max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"});
+			var listContacts = DataLayer.render("../prototype/modules/mail/templates/listContacts.ejs", item);
+			return $(listContacts).data( "item.autocomplete", item ).appendTo( ul ).find("span:last").button({
+					icons : {
+					primary : "ui-icon-close"
+				},
+				text: false
+			}).click(function(){
+				var removeLi = $(this).parents("li:first");
+				$.Zebra_Dialog('Deseja remover <b>'+(item.name ? item.name+" - " : "")+ item.email+'</b>?', {
+						'type':     'question',
+						'custom_class': (is_ie ? 'configure-zebra-dialog' : ''),
+						'title':    'Atenção',
+						'buttons': ['Sim','Não'],		
+						'overlay_opacity': '0.5',
+						'onClose':  function(caption) {
+							if(caption == 'Sim'){
+								$(removeLi).remove();
+								REST.delete("/dynamiccontact/"+item.id);
+								updateDynamicContact();
+								updateDynamicContactList();
+							}
+						}
+				});
+			});
+		};
+	}
+	
+	//FUNÇÃO DOS BOTÕES PARA - CC - CCO
+	div.parents("tr:first").find("button").button().click(function(){
+		if(!$(":focus").hasClass("new-message-input"))
+			emQuickSearch(($(this).parents("tr:first").find("input").val() ? $(this).parents("tr:first").find("input").val() : input_search), "."+$(this).parents("tr:first").attr('class').split("-")[0], ID, undefined, true);
 	});
 }
@@ -3596,4 +4063,5 @@
 	connector.loadScript("color_palette");
 	connector.loadScript('wfolders');
+	connector.loadScript("ccQuickAdd"); 
 	
 	if(typeof(RichTextEditor) == 'undefined' || typeof(ColorPalette) == 'undefined' || typeof(wfolders) == 'undefined')
@@ -3643,12 +4111,13 @@
 		button.toggleClass("expressomail-button-icon-ative");
 		field.toggle();
-		field.find("textarea").val("").focus();
-		if(!field.find("textarea").hasClass("elastic")){
-			field.find("textarea").css({"max-height" : "115px", "overflow-y" : "auto"}).addClass("elastic").elastic().unbind('blur');	
-			input_binds(field.find("textarea"), ID);
+		field.find("textarea").val("").parent().find("input").focus();
+		field.find(".email-area div").remove();
+		if(!field.find("textarea").hasClass("track")){
+			field.find("textarea").css({"max-height" : "115px", "overflow-y" : "auto"}).addClass("track");	
+			input_binds(field.find(".email-area"), ID);
 		}
 	} 
 	
-	input_binds(content.find('[name="input_to"]').css({"max-height" : "115px", "overflow-y" : "auto"}).addClass("elastic").elastic().unbind('blur').focus(), ID);	
+	input_binds(content.find('[name="input_aux_to"]').css("max-width" , parseInt($(".email-area").css("width"))-5).focus().parent().css({"max-height" : "115px", "overflow-y" : "auto"}), ID);	
 	
 	//Botão TextoRico/TextoSimples
