Index: trunk/prototype/modules/mail/css/foldertree.css
===================================================================
--- trunk/prototype/modules/mail/css/foldertree.css	(revision 7542)
+++ trunk/prototype/modules/mail/css/foldertree.css	(revision 7543)
@@ -3,6 +3,6 @@
 #content_folders .foldertree-skin-prognus span.trash {background-image: url(../img/bin.png);}
 #content_folders .foldertree-skin-prognus span.drafts {background-image: url(../img/folder_page_white.png);}
-#content_folders .foldertree-skin-prognus span.spam {background-image: url(../img/folder_delete.png);}
-#content_folders .foldertree-skin-prognus span.sent {background-image: url(../img/folder_go.png);}
+#content_folders .foldertree-skin-prognus span.spam {background-image: url(../img/mail-sprites.png); background-position: 0 -989px;}
+#content_folders .foldertree-skin-prognus span.sent {background-image: url(../img/mail-sprites.png); background-position: 0 -1055px;}
 #content_folders .foldertree-skin-prognus span.folder {display: block;padding-bottom: 1px;padding-left: 18px;padding-right: 0;padding-top: 1px; font-family : Lucida Grande, Lucida Sans, Arial, sans-serif;}
 #content_folders .treeview .closed {display:block;}
Index: trunk/prototype/modules/mail/js/followupflag.js
===================================================================
--- trunk/prototype/modules/mail/js/followupflag.js	(revision 7247)
+++ trunk/prototype/modules/mail/js/followupflag.js	(revision 7543)
@@ -253,5 +253,5 @@
 						flagged.find("img").attr("src", "../prototype/modules/mail/img/flagChecked.png").css("margin-left","-3px");
 					}else{
-						flagged.find("img").attr("src", "../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");			
+						flagged.css({"background-image":"url(../prototype/modules/mail/img/mail-sprites.png)","background-position":"0 -864px","margin-left":"0"});			
 					}
 					
@@ -361,9 +361,9 @@
 						$('#td_message_followup_' + messageNumber + ', ' + 
 							'tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_' + messageNumber).find(".flag-edited")
-							.find("img").attr("src", "../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");
+							.css({"background-image":"url(../prototype/modules/mail/img/mail-sprites.png)","background-position":"0 -864px","margin-left":"0"});
 					}else{
 						$('tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_' + messageNumber).attr('title', '').find(".flag-edited").css("background", '#CCC');
 						$('tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_' + messageNumber).find(".flag-edited")
-							.find("img").attr("src", "../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");
+							.css({"background-image":"url(../prototype/modules/mail/img/mail-sprites.png)","background-position":"0 -864px","margin-left":"0"});
 					}
 					updateCacheFollowupflag(messageNumber, folder_name, false);
Index: trunk/prototype/modules/mail/js/followupflag.min.js
===================================================================
--- trunk/prototype/modules/mail/js/followupflag.min.js	(revision 7538)
+++ trunk/prototype/modules/mail/js/followupflag.min.js	(revision 7543)
@@ -1,49 +1,78 @@
-MsgsCallbackFollowupflag={"#FollowupflagMessageIdError":function(){alert("N\u00e3o foi poss\u00edvel sinalizar esta mensagem. \nDetalhes do erro: mensagem n\u00e3o cont\u00e9m o atributo message-id.")},"#FollowupflagLimitError":function(){alert("N\u00e3o foi poss\u00edvel sinalizar esta mensagem. \nDetalhes do erro: limite de flags atingido para esta pasta.")},"#FollowupflagParamsError":function(){alert("N\u00e3o foi poss\u00edvel sinalizar esta mensagem. \nDetalhes do erro: mensagem n\u00e3o cont\u00e9m todos os atributos necess\u00e1rios.")}};
-function updateCacheFollowupflag(msgNumber,msgFolder,op){if(op){if(typeof msgNumber=="object")var extend=DataLayer.get("followupflagged",{filter:["AND",["IN","messageNumber",msgNumber],["IN","folderName",msgFolder]],criteria:{deepness:1}},true);else var extend=DataLayer.get("followupflagged",{filter:["AND",["=","messageNumber",msgNumber],["=","folderName",msgFolder]],criteria:{deepness:1}},true);if(extend!=""||extend!="undefined"||extend!=[])for(var i=0;i<extend.length;i++){if(!onceOpenedHeadersMessages[extend[i].folderName])onceOpenedHeadersMessages[extend[i].folderName]=
-{};if(!onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber])onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber]=[];onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber]["followupflagged"]={};DataLayer.merge(onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber]["followupflagged"],extend[i])}}else onceOpenedHeadersMessages[msgFolder][msgNumber]["followupflagged"]=undefined}
-function init_followup(data){winElement=data.window;selectedMessageIds=data.selectedMessages;folder=current_folder;(function($){$.widget("ui.combobox",{_create:function(){var self=this,select=this.element.hide(),selected=select.children(":selected"),value=selected.val()?selected.text():"";var input=this.input=$("<input>").insertAfter(select).val(value).autocomplete({delay:0,minLength:0,source:function(request,response){var matcher=new RegExp($.ui.autocomplete.escapeRegex(request.term),"i");response(select.children("option").map(function(){var text=
-$(this).text();if(this.value&&(!request.term||matcher.test(text)))return{label:text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+$.ui.autocomplete.escapeRegex(request.term)+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>"),value:text,option:this}}))},select:function(event,ui){ui.item.option.selected=true;self._trigger("selected",event,{item:ui.item.option})},change:function(event,ui){if(!ui.item){var matcher=new RegExp("^"+$.ui.autocomplete.escapeRegex($(this).val())+"$","i"),valid=false;select.children("option").each(function(){if($(this).text().match(matcher)){this.selected=
-valid=true;return false}});if(!valid)if(select.has('option[value="custom"]').length>0)select.find("option:last").val("custom").html($(this).val()).attr("selected","selected");else{select.append(select.find("option:last").clone().val("custom").html($(this).val()));select.find('option[value="custom"]').attr("selected","selected")}}}}).addClass("ui-widget ui-widget-content ui-corner-left");input.data("autocomplete")._renderItem=function(ul,item){return $("<li></li>").data("item.autocomplete",item).append("<a>"+
-item.label+"</a>").appendTo(ul)};this.button=$("<button type='button'>&nbsp;</button>").attr("tabIndex",-1).attr("title","Show All Items").insertAfter(input).button({icons:{primary:"ui-icon-triangle-1-s"},text:false}).removeClass("ui-corner-all").addClass("ui-corner-right ui-button-icon").click(function(){if(input.autocomplete("widget").is(":visible")){input.autocomplete("close");return}$(this).blur();input.autocomplete("search","");input.focus()})},destroy:function(){this.input.remove();this.button.remove();
-this.element.show();$.Widget.prototype.destroy.call(this)}})})(jQuery);winElement.find('input[name="alarmDate"]').change(function(event){winElement.find('input[name="alarmTime"]').attr("disabled",$(this).val()==""?"disabled":false)});winElement.find('input[name="alarmDate"]').keyup(function(event){winElement.find('input[name="alarmTime"]').attr("disabled",$(this).val()==""?"disabled":false).val("")});winElement.find(".button").button().filter(".menu-configure-followupflag .cancel").click(function(){winElement.dialog("close")}).end().filter(".menu-configure-followupflag .save").click(function(){var saveFollowupflagged=
-function(){var idFollowupflagged=winElement.find('[name="followupflagId"]').val();idFollowupflagged=idFollowupflagged.split(",");for(x=0;x<idFollowupflagged.length;x++)idFollowupflagged[x]=="false"?idFollowupflagged[x]=false:idFollowupflagged;for(i=0;i<selectedMessageIds.length;i++){var isDone=winElement.find('[name="done"]').is(":checked")?1:0;var alarmDate=false;var doneDate=false;var folder_name;var folders=[];var messages=[];var roles=get_selected_messages_search_role().split(",");for(var i=0;i<
-selectedMessageIds.length;i++){if(currentTab==0){folder_name=current_folder;var messageNumber=selectedMessageIds[i]}else{var tr=$('[role="'+roles[i]+'"]');folder_name=$(tr).attr("name");var id=$(tr).attr("id");var messageNumber=id.replace(/_[a-zA-Z0-9]+/,"")}folders.push(folder_name);var followupflagged=DataLayer.merge({uid:User.me.id,followupflagId:followupflagId,folderName:folder_name,messageNumber:messageNumber,isDone:isDone,isSent:0,backgroundColor:backgroundColor},!!idFollowupflagged[i]?{id:idFollowupflagged[i]}:
-{});if(alarmDate=winElement.find('[name="alarmDate"]').datepicker("getDate")){if(alarmTime=winElement.find('[name="alarmTime"]').datepicker("getDate"))alarmDate.set({hour:alarmTime.getHours(),minute:alarmTime.getMinutes()});followupflagged.alarmDeadline=alarmDate.toString("yyyy-MM-dd HH:mm:ss")}if(doneDate=winElement.find('[name="doneDate"]').datepicker("getDate")){if(doneTime=winElement.find('[name="doneTime"]').datepicker("getDate"))doneDate.set({hour:doneTime.getHours(),minute:doneTime.getMinutes()});
-followupflagged.doneDeadline=doneDate.toString("yyyy-MM-dd HH:mm:ss")}if(current_folder==folder_name)var flagged=$("#td_message_followup_"+messageNumber+', tr[role="'+messageNumber+"_"+folder_name+'"] #td_message_followup_search_'+messageNumber).find(".flag-edited");else var flagged=$('tr[role="'+messageNumber+"_"+folder_name+'"] #td_message_followup_search_'+messageNumber).find(".flag-edited");if(isDone)flagged.find("img").attr("src","../prototype/modules/mail/img/flagChecked.png").css("margin-left",
-"-3px");else flagged.find("img").attr("src","../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");var followupflagName=winElement.find('[name="name"] option:selected').text();if(current_folder==folder_name)$("#td_message_followup_"+messageNumber+", "+'tr[role="'+messageNumber+"_"+folder_name+'"] #td_message_followup_search_'+messageNumber).attr("title",followupflagName).find(".flag-edited").css("background",backgroundColor);else $('tr[role="'+messageNumber+"_"+folder_name+'"] #td_message_followup_search_'+
-messageNumber).attr("title",followupflagName).find(".flag-edited").css("background",backgroundColor);DataLayer.put("followupflagged",followupflagged)}DataLayer.commit(false,false,function(data){winElement.find(".menu-configure-followupflag .delete").button("option","disabled",false);updateCacheFollowupflag(selectedMessageIds,folders,true);winElement.dialog("close");alarmFollowupflagged("followupflagAlarms");var fail="success";$.each(data,function(index,value){if(typeof value=="string")fail=value});
-if(fail=="#FollowupflagMessageIdError")alert("Uma ou mais mensagens n\u00e3o puderam ser sinalizadas. \nDetalhes do erro: mensagem n\u00e3o cont\u00e9m o atributo message-id.");else if(fail=="#FollowupflagLimitError")alert("Uma ou mais mensagens n\u00e3o puderam ser sinalizadas. \nDetalhes do erro: limite de flags atingido para esta pasta.");$.each(selectedMessageIds,function(index,value){var flagged=DataLayer.get("followupflagged",{filter:["AND",["=","messageNumber",value],["=","folderName",folder_name]]});
-if(!flagged)$("#td_message_followup_"+value).find(".flag-edited").css("background","#cccccc")})});winElement.find(".menu-configure-followupflag .save").button("option","disabled",true)}selectAllFolderMsgs(false)};winElement.find('[name="name"]').next().data("autocomplete")._trigger("change");var backgroundColor=winElement.find('[name="backgroundColor"]').val();var followupflagId=winElement.find('[name="name"] option:selected').val();if(followupflagId=="custom"){DataLayer.put("followupflag",{name:winElement.find('[name="name"] option:selected').text(),
-uid:User.me.id});DataLayer.commit(false,false,function(data){$.each(data,function(index,value){if(typeof value=="object")followupflagId=value.id});winElement.find('[name="name"] option[value="custom"]').val(followupflagId);saveFollowupflagged()})}else saveFollowupflagged()}).end().filter(".menu-configure-followupflag .delete").click(function(){if(selectedMessageIds.length==0)$(this).button("option","disabled",true);DataLayer.remove("followupflagged",false);DataLayer.get("followupflagged");var roles=
-get_selected_messages_search_role().split(",");for(var i=0;i<selectedMessageIds.length;i++){if(currentTab==0){folder_name=current_folder;var messageNumber=selectedMessageIds[i]}else{var tr=$('[role="'+roles[i]+'"]');folder_name=$(tr).attr("name");var id=$(tr).attr("id");var messageNumber=id.replace(/_[a-zA-Z0-9]+/,"")}if(onceOpenedHeadersMessages[folder_name][messageNumber]["followupflagged"])if(onceOpenedHeadersMessages[folder_name][messageNumber]["followupflagged"].id){var flag_id=onceOpenedHeadersMessages[folder_name][messageNumber]["followupflagged"].id;
-DataLayer.remove("followupflagged",flag_id);if(current_folder==folder_name){$("#td_message_followup_"+messageNumber+", "+'tr[role="'+messageNumber+"_"+folder_name+'"] #td_message_followup_search_'+messageNumber).attr("title","").find(".flag-edited").css("background","#CCC");$("#td_message_followup_"+messageNumber+", "+'tr[role="'+messageNumber+"_"+folder_name+'"] #td_message_followup_search_'+messageNumber).find(".flag-edited").find("img").attr("src","../prototype/modules/mail/img/flagEditor.png").css("margin-left",
-"0")}else{$('tr[role="'+messageNumber+"_"+folder_name+'"] #td_message_followup_search_'+messageNumber).attr("title","").find(".flag-edited").css("background","#CCC");$('tr[role="'+messageNumber+"_"+folder_name+'"] #td_message_followup_search_'+messageNumber).find(".flag-edited").find("img").attr("src","../prototype/modules/mail/img/flagEditor.png").css("margin-left","0")}updateCacheFollowupflag(messageNumber,folder_name,false)}}DataLayer.commit(false,false,function(){winElement.dialog("close");alarmFollowupflagged("followupflagAlarms")});
-selectAllFolderMsgs(false)});winElement.find(":input").change(function(event){if(event.keyCode!="27"&&event.keyCode!="13")winElement.find(".menu-configure-followupflag .save").button("option","disabled",false)}).keydown(function(event){if(event.keyCode!="27"&&event.keyCode!="13")winElement.find(".menu-configure-followupflag .save").button("option","disabled",false)});winElement.find(".date").datepicker();winElement.find(".time").timepicker({});winElement.find('[name="name"]').combobox().next().next().click(function(event,
-ui){$(".ui-autocomplete.ui-menu li").css("position","relative");$(".ui-autocomplete.ui-menu li a:gt(5)").append("<span class='ui-icon ui-icon-only ui-icon-close delete_followupflag'></span>").find("span").click(function(event){var id=$(".followupflag-configure").find("option")[$(this).parents("li").index()].value;var nameFollowupflag=$(".followupflag-configure").find("option")[$(this).parents("li").index()].text;var removeLi=$(this).parents("li");$.Zebra_Dialog(get_lang("All messages flagged with the flag type ")+
-"<strong>"+nameFollowupflag+"</strong>"+get_lang(" will be removed. This action cannot be undone. Want to continue?"),{"type":"question","custom_class":is_ie?"configure-zebra-dialog":"","title":"Aten\u00e7\u00e3o","buttons":["Sim","N\u00e3o"],"overlay_opacity":"0.5","onClose":function(caption){if(caption=="Sim"){var listFollowupflag=DataLayer.get("followupflagged",["=","followupflagId",id]);for(var i=0;i<listFollowupflag.length;i++)DataLayer.remove("followupflagged",listFollowupflag[i].id);DataLayer.remove("followupflag",
-false);DataLayer.get("followupflag");DataLayer.remove("followupflag",""+id);DataLayer.commit(false,false,function(data){$('[title="'+nameFollowupflag+'"]').attr("title","").find("div").css({backgroundColor:"#CCC"});$(removeLi).remove();$('option[value="'+id+'"]').remove();$(".ui-autocomplete.ui-menu li:first");$(".followupflag-configure").find("option:first").attr("selected","selected");$(".ui-autocomplete-input").val($(".followupflag-configure").find("option:selected").text());for(var i=0;i<listFollowupflag.length;i++)if(listFollowupflag[i].id==
-winElement.find('[name="followupflagId"]').val())winElement.find('[name="followupflagId"]').val("")});event.stopImmediatePropagation()}}});if(is_ie)$(".ZebraDialogOverlay").css("z-index","1006")})});winElement.find(".ui-corner-right.ui-button-icon").attr("title",get_lang("Show All Items"));winElement.find('[name="alarmDate"],[name="alarmTime"]').attr("disabled","disabled");winElement.find(".menu-configure-followupflag .delete").button("option","disabled",true);var idFollowupflag=winElement.find('[name="followupflagId"]').val();
-idFollowupflag=idFollowupflag.split(",");$.each(idFollowupflag,function(index,value){if(value!="false")winElement.find(".menu-configure-followupflag .delete").button("option","disabled",false)});winElement.find('[name="alarm"]').click(function(){if($(this).is(":checked"))winElement.find('[name="alarmDate"]').removeAttr("disabled");else winElement.find('[name="alarmDate"],[name="alarmTime"]').attr("disabled","disabled").val("")});if(winElement.find('[name="alarm"]').is(":checked"))winElement.find('[name="alarmDate"],[name="alarmTime"]').removeAttr("disabled");
-winElement.find('[name="done"]').click(function(){if($(this).is(":checked"))winElement.find(".input-done input").attr("disabled","disabled");else winElement.find(".input-done input").removeAttr("disabled")});winElement.find(".followupflag-color-fields").hide();winElement.find(".followupflag-color.sample-list .sample-item").click(function(){winElement.find(".menu-configure-followupflag .save").button("enable");winElement.find(".followupflag-color.sample-list .sample-item").removeClass("selected");
-$(this).addClass("selected");var color=$(this).attr("alt");winElement.find('[name="backgroundColor"]').css("background-color",color).val(color)});winElement.find(".followupflag-color.sample-list .sample-item.selected").trigger("click");winElement.find('[name="setColor"]').change(function(){if(winElement.find('[name="setColor"]').val()=="default"){winElement.find(".followupflag-color.sample-list").show("fast");winElement.find(".followupflag-color-fields").hide();winElement.find(".followupflag-color.sample-list .sample-item.selected").trigger("click")}else if(winElement.find('[name="setColor"]').val()==
-"custom"){winElement.find(".followupflag-color-fields").show("fast");winElement.find(".followupflag-color.sample-list").hide();winElement.find(".colorwell").focus()}});if(winElement.find('[name="setColor"] option:selected').val()=="custom")winElement.find('[name="setColor"]').trigger("change");var colorpickerPreviewChange=function(color){winElement.find(".menu-configure-followupflag .save").button("enable");winElement.find(".colorwell-selected").val(color).css("background-color",color);winElement.find(".flag-color-preview").css("background",
-color)};var f=$.farbtastic(winElement.find(".colorpicker"),colorpickerPreviewChange);var selected;winElement.find(".colorwell").each(function(){f.linkTo(this)}).focus(function(){if(selected)$(selected).removeClass("colorwell-selected");$(selected=this).addClass("colorwell-selected");f.linkTo(this,colorpickerPreviewChange);f.linkTo(colorpickerPreviewChange)});if(winElement.find('[name="setColor"] option:selected').val()=="custom")winElement.find(".colorwell").focus()}
-function alarmFollowupflagged(alert_type,filter_list){var currentDate=(new Date).toString("dd/MM/yyyy");var data={alarmDeadline:false,doneDeadline:false,filtersAlarms:false};switch(alert_type){case "followupflagAlarms":$(".doneDeadline").remove();$(".alarmDeadline").remove();data.alarmDeadline=$.cookie("fadeAlarm")!=currentDate?true:false;data.doneDeadline=$.cookie("fadeCompleted")!=currentDate?true:false;break;case "filtersAlarms":$(".filtersDeadline").remove();data.filtersAlarms=$.cookie("fadeFilterAlarm")!=
-currentDate?true:false;break;default:$(".gray").remove();data.alarmDeadline=$.cookie("fadeAlarm")!=currentDate?true:false;data.doneDeadline=$.cookie("fadeCompleted")!=currentDate?true:false;data.filtersAlarms=$.cookie("fadeFilterAlarm")!=currentDate?true:false;break}var startDate=(new Date).set({hour:0,minute:0,second:0}).toString("yyyy-MM-dd 00:00:00");var endDate=(new Date).set({hour:0,minute:0,second:0}).addHours(24).toString("yyyy-MM-dd 00:00:00");if(data.alarmDeadline){var decodeAlarms={"sent":[],
-"task":[]};alarms=DataLayer.get("followupflagged",{filter:["AND",["<","alarmDeadline",endDate],["=","isSent","0"],["=","isDone","0"]],criteria:{deepness:1}});if(alarms.length>0){var itens=[];for(var i=0;i<alarms.length;i++){var date=Date.parseExact(alarms[i]["alarmDeadline"],"yyyy-MM-dd HH:mm:ss");alarms[i]["alarmDeadline"]=date.toString("dd/MM HH:mm");var nameFollowupflag=alarms[i]["followupflag"]["id"]<7?get_lang(alarms[i]["followupflag"]["name"]):alarms[i]["followupflag"]["name"];var li_alarm=
-alarms[i]["alarmDeadline"]+" - "+nameFollowupflag+" - "+alarms[i]["message"]["headers"]["subject"];if(alarms[i]["doneDeadline"]!=""){var dateDone=Date.parseExact(alarms[i]["doneDeadline"],"yyyy-MM-dd HH:mm:ss");if(dateDone.getTime()<$.now())continue}if(date.getTime()<=$.now())decodeAlarms.sent.push({"msg_number":alarms[i]["messageNumber"],"msg_folder":alarms[i]["folderName"],"a":truncate(li_alarm,34),"id":alarms[i].id});else decodeAlarms.task.push({a:truncate(li_alarm,34),sentTime:date.getTime()/
-1E3,id:alarms[i].id,"msg_folder":alarms[i].folderName,"msg_number":alarms[i].messageNumber})}if(decodeAlarms.task.length)alarmDeadline.load(decodeAlarms.task);if(decodeAlarms.sent.length)data.alarmDeadline={alarms:decodeAlarms.sent,title:get_lang("Follow ups"),caption:itens.length==1?get_lang("You have one undone message today:"):get_lang("You have %1 follow ups due for today:",decodeAlarms.sent.length),type:"alarmDeadline"};else data.alarmDeadline=false}else data.alarmDeadline=false}if(data.doneDeadline){alarms=
-DataLayer.get("followupflagged",{filter:["AND",[">","doneDeadline",startDate],["<","doneDeadline",endDate]],criteria:{deepness:1}});if(alarms.length>0){var itens=[];for(var i=0;i<alarms.length;i++){var date=Date.parseExact(alarms[i]["doneDeadline"],"yyyy-MM-dd HH:mm:ss");alarms[i]["doneDeadline"]=date.toString("dd/MM HH:mm");var nameFollowupflag=alarms[i]["followupflag"]["id"]<7?get_lang(alarms[i]["followupflag"]["name"]):alarms[i]["followupflag"]["name"];var li_alarm=alarms[i]["doneDeadline"]+" - "+
-nameFollowupflag+" - "+truncate(alarms[i]["message"]["headers"]["subject"],15);itens.push({a:truncate(li_alarm,34),id:alarms[i].id,"msg_folder":alarms[i].folderName,"msg_number":alarms[i].messageNumber})}data.doneDeadline={alarms:itens,title:get_lang("Done"),caption:itens.length==1?get_lang("You have one undone message today:"):get_lang("You have %1 follow ups due for today:",itens.length),type:"doneDeadline"}}else data.doneDeadline=false}if(data.filtersAlarms){alarms=filter_list;if(alarms.length>
-0){var itens=[];for(var i=0;i<alarms.length;i++){alarms[i]["udate"]=(new Date(alarms[i]["udate"]*1E3)).toString("dd/MM HH:mm");var li_alarm=alarms[i]["udate"]+" - "+alarms[i]["from"]+" - "+alarms[i]["subject"];itens.push({"msg_number":alarms[i]["msg_number"],"msg_folder":alarms[i]["msg_folder"],a:truncate(html_entities(li_alarm),34),id:alarms[i].id})}data.filtersAlarms={alarms:itens,title:get_lang("Filter by sender"),caption:itens.length==1?get_lang("You have an archived message:"):get_lang("You have %1 messages archived:",
-itens.length),type:"filtersDeadline",captions:{singular:"You have one undone message today:",plural:"You have %1 undone messages today:"}}}else data.filtersAlarms=false}for(var i in data)if(data[i]!=false)showAlarmsModal(data[i]);$(".gray").find(".content-alarm").hide();$(".gray").find('.header-alarm [name="header-icon"]').removeClass("minimize-alarm").addClass("maximize-alarm");if($(".gray").length>0)if($(".gray").hasClass("filtersDeadline")){$(".filtersDeadline").find(".content-alarm").show();$('.filtersDeadline .header-alarm [name="header-icon"]').removeClass("maximize-alarm").addClass("minimize-alarm")}else if($(".gray").hasClass("alarmDeadline")){$(".alarmDeadline").find(".content-alarm").show();
-$('.alarmDeadline .header-alarm [name="header-icon"]').removeClass("maximize-alarm").addClass("minimize-alarm")}else if($(".gray").hasClass("doneDeadline")){$(".doneDeadline").find(".content-alarm").show();$('.doneDeadline .header-alarm [name="header-icon"]').removeClass("maximize-alarm").addClass("minimize-alarm")}}
-function showAlarmsModal(alarm){var ok_function=function(event,type,type_cookie){if($(event.target).parents("."+type).find('[name="stopAlert"]').is(":checked"))$.cookie(type_cookie,(new Date).toString("dd/MM/yyyy"),{expires:1})};var dialogText=DataLayer.render("../prototype/modules/mail/templates/followupflag_alarm_list.ejs",alarm);var titulo='<div class="header-alarm"><span class="img_title"></span><span class="title-alarm"><strong>'+alarm.title+'</strong></span><span name="header-icon" class="maximize-alarm"></span></div>';
-$("#freeow").freeow(titulo,dialogText,{classes:["gray",alarm.type],autoHide:false,startStyle:null,onClick:function(event){var type="";var type_cookie="";if($(this).hasClass("alarmDeadline")){type="alarmDeadline";type_cookie="fadeAlarm"}else if($(this).hasClass("doneDeadline")){type="doneDeadline";type_cookie="fadeCompleted"}else if($(this).hasClass("filtersDeadline")){type="filtersDeadline";type_cookie="fadeFilterAlarm"}if($(event.target).hasClass("stop-alert-alarm"))return;if($(event.target).hasClass("minimize-alarm")){$("."+
-type).find(".content-alarm").hide();$(event.target).removeClass("minimize-alarm").addClass("maximize-alarm");return}if($(event.target).hasClass("maximize-alarm")){$("."+type).find(".content-alarm").show();$(event.target).removeClass("maximize-alarm").addClass("minimize-alarm");return}if($(!!$.browser.safari?event.target.parentElement:event.target).hasClass("confirm-alarm")){ok_function(event,type,type_cookie);$("."+type).remove();return}return false}});$(".gray .background .content p").remove();$(".gray .icon").remove();
-$(".gray .close").remove();$("div.gray.alarmDeadline .button.delete").button({text:false,icons:{primary:"ui-icon-close"}});$(".content-alarm button").button()}
-function cancelAlarm(element,idAlarm,messageNumber,folderName){$(element).parents("li").remove();var view="div.gray.alarmDeadline";var length=$(view).find("ul.message-list li").length;if(length>0){var msg="";if(length==1)msg=get_lang("You have a follow up due for today:");else msg=get_lang("You have %1 follow ups due for today:",length);$(view).find("span.subtitle-alarm strong").html(msg)}else $(view).remove();DataLayer.put("followupflagged",{id:idAlarm,isSent:"1",folderName:folderName,messageNumber:messageNumber,
-uid:User.me.uid});DataLayer.commit()}
-alarmDeadline={load:function(alarm){var currentDate=(new Date).toString("dd/MM/yyyy");if($.cookie("fadeAlarm")!=currentDate)for(var i=0;i<alarm.length;i++)this.addAlarm(alarm[i])},addAlarm:function(alarm){DataLayer.task(parseInt(alarm["sentTime"]),function(timestamp){var view="div.gray.alarmDeadline";if(!$(view+" li.message-item."+alarm.id).length){var currentDate=(new Date).toString("dd/MM/yyyy");if($.cookie("fadeAlarm")!=currentDate)if($("div.gray.alarmDeadline").length){$(view).find("ul.message-list").append(DataLayer.render("../prototype/modules/mail/templates/followupflag_alarmDeadline_add_item_list.ejs",alarm));
-var length=$(view).find("ul.message-list li").length;var msg="";if(length==1)msg=get_lang("You have a follow up due for today:");else msg=get_lang("You have %1 follow ups due for today:",length);$(view).find("span.subtitle-alarm strong").html(msg);$(view+" .button.delete").button({text:false,icons:{primary:"ui-icon-close"}})}else{var item={alarms:[alarm],title:get_lang("Follow ups"),caption:get_lang("You have one undone message today:"),type:"alarmDeadline"};showAlarmsModal(item)}}})}};
-$("#main_table").ready(function(){handlerMessageFilter=function(data){alarmFollowupflagged(null,data)};cExecute("$this.imap_functions.getFlaggedAlertMessages&folders="+fromRules,handlerMessageFilter)});
+
+MsgsCallbackFollowupflag={'#FollowupflagMessageIdError':function(){alert('NÃ£o foi possÃ­vel sinalizar esta mensagem. \nDetalhes do erro: mensagem nÃ£o contÃ©m o atributo message-id.');},'#FollowupflagLimitError':function(){alert('NÃ£o foi possÃ­vel sinalizar esta mensagem. \nDetalhes do erro: limite de flags atingido para esta pasta.');},'#FollowupflagParamsError':function(){alert('NÃ£o foi possÃ­vel sinalizar esta mensagem. \nDetalhes do erro: mensagem nÃ£o contÃ©m todos os atributos necessÃ¡rios.');}}
+function updateCacheFollowupflag(msgNumber,msgFolder,op){if(op){if(typeof msgNumber=='object'){var extend=DataLayer.get('followupflagged',{filter:['AND',['IN','messageNumber',msgNumber],['IN','folderName',msgFolder]],criteria:{deepness:1}},true);}else{var extend=DataLayer.get('followupflagged',{filter:['AND',['=','messageNumber',msgNumber],['=','folderName',msgFolder]],criteria:{deepness:1}},true);}
+if(extend!=""||extend!='undefined'||extend!=[]){for(var i=0;i<extend.length;i++){if(!(onceOpenedHeadersMessages[extend[i].folderName])){onceOpenedHeadersMessages[extend[i].folderName]={};}
+if(!(onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber])){onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber]=[];}
+onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber]['followupflagged']={};DataLayer.merge(onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber]['followupflagged'],extend[i]);}}}else{onceOpenedHeadersMessages[msgFolder][msgNumber]['followupflagged']=undefined;}}
+function init_followup(data){winElement=data.window;selectedMessageIds=data.selectedMessages;folder=current_folder;(function($){$.widget("ui.combobox",{_create:function(){var self=this,select=this.element.hide(),selected=select.children(":selected"),value=selected.val()?selected.text():"";var input=this.input=$("<input>").insertAfter(select).val(value).autocomplete({delay:0,minLength:0,source:function(request,response){var matcher=new RegExp($.ui.autocomplete.escapeRegex(request.term),"i");response(select.children("option").map(function(){var text=$(this).text();if(this.value&&(!request.term||matcher.test(text)))
+return{label:text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+
+$.ui.autocomplete.escapeRegex(request.term)+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>"),value:text,option:this};}));},select:function(event,ui){ui.item.option.selected=true;self._trigger("selected",event,{item:ui.item.option});},change:function(event,ui){if(!ui.item){var matcher=new RegExp("^"+$.ui.autocomplete.escapeRegex($(this).val())+"$","i"),valid=false;select.children("option").each(function(){if($(this).text().match(matcher)){this.selected=valid=true;return false;}});if(!valid){if(select.has('option[value="custom"]').length>0){select.find('option:last').val('custom').html($(this).val()).attr('selected','selected');}else{select.append(select.find('option:last').clone().val('custom').html($(this).val()));select.find('option[value="custom"]').attr('selected','selected');}}}}}).addClass("ui-widget ui-widget-content ui-corner-left");input.data("autocomplete")._renderItem=function(ul,item){return $("<li></li>").data("item.autocomplete",item).append("<a>"+item.label+"</a>").appendTo(ul);};this.button=$("<button type='button'>&nbsp;</button>").attr("tabIndex",-1).attr("title","Show All Items").insertAfter(input).button({icons:{primary:"ui-icon-triangle-1-s"},text:false}).removeClass("ui-corner-all").addClass("ui-corner-right ui-button-icon").click(function(){if(input.autocomplete("widget").is(":visible")){input.autocomplete("close");return;}
+$(this).blur();input.autocomplete("search","");input.focus();});},destroy:function(){this.input.remove();this.button.remove();this.element.show();$.Widget.prototype.destroy.call(this);}});})(jQuery);winElement.find('input[name="alarmDate"]').change(function(event){winElement.find('input[name="alarmTime"]').attr('disabled',($(this).val()==""?'disabled':false));});winElement.find('input[name="alarmDate"]').keyup(function(event){winElement.find('input[name="alarmTime"]').attr('disabled',($(this).val()==""?'disabled':false)).val('');});winElement.find('.button').button().filter('.menu-configure-followupflag .cancel').click(function(){winElement.dialog("close");}).end().filter('.menu-configure-followupflag .save').click(function(){var saveFollowupflagged=function(){var idFollowupflagged=winElement.find('[name="followupflagId"]').val();idFollowupflagged=idFollowupflagged.split(',');for(x=0;x<idFollowupflagged.length;x++){(idFollowupflagged[x]=="false")?idFollowupflagged[x]=false:idFollowupflagged;}
+for(i=0;i<selectedMessageIds.length;i++){var isDone=winElement.find('[name="done"]').is(':checked')?1:0;var alarmDate=false;var doneDate=false;var folder_name;var folders=[];var messages=[];var roles=get_selected_messages_search_role().split(',');for(var i=0;i<selectedMessageIds.length;i++){if(currentTab==0){folder_name=current_folder;var messageNumber=selectedMessageIds[i];}else{var tr=$('[role="'+roles[i]+'"]');folder_name=$(tr).attr('name');var id=$(tr).attr('id');var messageNumber=id.replace(/_[a-zA-Z0-9]+/,"");}
+folders.push(folder_name);var followupflagged=DataLayer.merge({uid:User.me.id,followupflagId:followupflagId,folderName:folder_name,messageNumber:messageNumber,isDone:isDone,isSent:0,backgroundColor:backgroundColor},!!idFollowupflagged[i]?{id:idFollowupflagged[i]}:{});if(alarmDate=winElement.find('[name="alarmDate"]').datepicker("getDate")){if(alarmTime=winElement.find('[name="alarmTime"]').datepicker("getDate")){alarmDate.set({hour:alarmTime.getHours(),minute:alarmTime.getMinutes()});}
+followupflagged.alarmDeadline=alarmDate.toString('yyyy-MM-dd HH:mm:ss');}
+if(doneDate=winElement.find('[name="doneDate"]').datepicker("getDate")){if(doneTime=winElement.find('[name="doneTime"]').datepicker("getDate")){doneDate.set({hour:doneTime.getHours(),minute:doneTime.getMinutes()});}
+followupflagged.doneDeadline=doneDate.toString('yyyy-MM-dd HH:mm:ss');}
+if(current_folder==folder_name){var flagged=$('#td_message_followup_'+messageNumber+', tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_'+messageNumber).find(".flag-edited");}else{var flagged=$('tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_'+messageNumber).find(".flag-edited");}
+if(isDone){flagged.find("img").attr("src","../prototype/modules/mail/img/flagChecked.png").css("margin-left","-3px");}else{flagged.css({"background-image":"url(../prototype/modules/mail/img/mail-sprites.png)","background-position":"0 -864px","margin-left":"0"});}
+var followupflagName=winElement.find('[name="name"] option:selected').text();if(current_folder==folder_name){$('#td_message_followup_'+messageNumber+', '+'tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_'+messageNumber).attr('title',followupflagName).find(".flag-edited").css("background",backgroundColor);}else{$('tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_'+messageNumber).attr('title',followupflagName).find(".flag-edited").css("background",backgroundColor);}
+DataLayer.put('followupflagged',followupflagged);}
+DataLayer.commit(false,false,function(data){winElement.find('.menu-configure-followupflag .delete').button("option","disabled",false);updateCacheFollowupflag(selectedMessageIds,folders,true);winElement.dialog("close");alarmFollowupflagged('followupflagAlarms');var fail='success';$.each(data,function(index,value){if(typeof value=='string'){fail=value;}});if(fail=='#FollowupflagMessageIdError'){alert('Uma ou mais mensagens nÃ£o puderam ser sinalizadas. \nDetalhes do erro: mensagem nÃ£o contÃ©m o atributo message-id.');}
+else if(fail=='#FollowupflagLimitError'){alert('Uma ou mais mensagens nÃ£o puderam ser sinalizadas. \nDetalhes do erro: limite de flags atingido para esta pasta.');}
+$.each(selectedMessageIds,function(index,value){var flagged=DataLayer.get('followupflagged',{filter:['AND',['=','messageNumber',value],['=','folderName',folder_name]]});if(!flagged)
+$('#td_message_followup_'+value).find(".flag-edited").css("background","#cccccc");});});winElement.find('.menu-configure-followupflag .save').button("option","disabled",true);}
+selectAllFolderMsgs(false);}
+winElement.find('[name="name"]').next().data("autocomplete")._trigger("change");var backgroundColor=winElement.find('[name="backgroundColor"]').val();var followupflagId=winElement.find('[name="name"] option:selected').val();if(followupflagId=='custom'){DataLayer.put('followupflag',{name:winElement.find('[name="name"] option:selected').text(),uid:User.me.id});DataLayer.commit(false,false,function(data){$.each(data,function(index,value){if(typeof value=='object'){followupflagId=value.id;}});winElement.find('[name="name"] option[value="custom"]').val(followupflagId);saveFollowupflagged();});}else{saveFollowupflagged();}}).end().filter('.menu-configure-followupflag .delete').click(function(){if(selectedMessageIds.length==0)$(this).button("option","disabled",true);DataLayer.remove('followupflagged',false);DataLayer.get('followupflagged');var roles=get_selected_messages_search_role().split(',');for(var i=0;i<selectedMessageIds.length;i++){if(currentTab==0){folder_name=current_folder;var messageNumber=selectedMessageIds[i];}else{var tr=$('[role="'+roles[i]+'"]');folder_name=$(tr).attr('name');var id=$(tr).attr('id');var messageNumber=id.replace(/_[a-zA-Z0-9]+/,"");}
+if(onceOpenedHeadersMessages[folder_name][messageNumber]['followupflagged']){if(onceOpenedHeadersMessages[folder_name][messageNumber]['followupflagged'].id){var flag_id=onceOpenedHeadersMessages[folder_name][messageNumber]['followupflagged'].id;DataLayer.remove('followupflagged',flag_id);if(current_folder==folder_name){$('#td_message_followup_'+messageNumber+', '+'tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_'+messageNumber).attr('title','').find(".flag-edited").css("background",'#CCC');$('#td_message_followup_'+messageNumber+', '+'tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_'+messageNumber).find(".flag-edited").css({"background-image":"url(../prototype/modules/mail/img/mail-sprites.png)","background-position":"0 -864px","margin-left":"0"});}else{$('tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_'+messageNumber).attr('title','').find(".flag-edited").css("background",'#CCC');$('tr[role="'+messageNumber+'_'+folder_name+'"] #td_message_followup_search_'+messageNumber).find(".flag-edited").css({"background-image":"url(../prototype/modules/mail/img/mail-sprites.png)","background-position":"0 -864px","margin-left":"0"});}
+updateCacheFollowupflag(messageNumber,folder_name,false);}}}
+DataLayer.commit(false,false,function(){winElement.dialog("close");alarmFollowupflagged('followupflagAlarms');});selectAllFolderMsgs(false);});winElement.find(':input').change(function(event){if(event.keyCode!='27'&&event.keyCode!='13')
+winElement.find('.menu-configure-followupflag .save').button("option","disabled",false);}).keydown(function(event){if(event.keyCode!='27'&&event.keyCode!='13')
+winElement.find('.menu-configure-followupflag .save').button("option","disabled",false);});winElement.find('.date').datepicker();winElement.find('.time').timepicker({});winElement.find('[name="name"]').combobox().next().next().click(function(event,ui){$(".ui-autocomplete.ui-menu li").css("position","relative");$(".ui-autocomplete.ui-menu li a:gt(5)").append("<span class='ui-icon ui-icon-only ui-icon-close delete_followupflag'></span>").find("span").click(function(event){var id=$('.followupflag-configure').find('option')[$(this).parents('li').index()].value;var nameFollowupflag=$('.followupflag-configure').find('option')[$(this).parents('li').index()].text;var removeLi=$(this).parents("li");$.Zebra_Dialog(get_lang('All messages flagged with the flag type ')+'<strong>'+nameFollowupflag+'</strong>'+get_lang(' will be removed. This action cannot be undone. Want to continue?'),{'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'){var listFollowupflag=DataLayer.get('followupflagged',['=','followupflagId',id]);for(var i=0;i<listFollowupflag.length;i++)
+DataLayer.remove('followupflagged',listFollowupflag[i].id);DataLayer.remove('followupflag',false);DataLayer.get('followupflag');DataLayer.remove('followupflag',''+id);DataLayer.commit(false,false,function(data){$('[title="'+nameFollowupflag+'"]').attr('title','').find('div').css({backgroundColor:'#CCC'});$(removeLi).remove();$('option[value="'+id+'"]').remove();$('.ui-autocomplete.ui-menu li:first');$('.followupflag-configure').find('option:first').attr("selected","selected");$('.ui-autocomplete-input').val($('.followupflag-configure').find('option:selected').text());for(var i=0;i<listFollowupflag.length;i++){if(listFollowupflag[i].id==winElement.find('[name="followupflagId"]').val()){winElement.find('[name="followupflagId"]').val("");}}});event.stopImmediatePropagation();}}});if(is_ie)
+$(".ZebraDialogOverlay").css("z-index","1006");});});winElement.find('.ui-corner-right.ui-button-icon').attr('title',get_lang('Show All Items'));winElement.find('[name="alarmDate"],[name="alarmTime"]').attr("disabled","disabled");winElement.find('.menu-configure-followupflag .delete').button("option","disabled",true);var idFollowupflag=winElement.find('[name="followupflagId"]').val();idFollowupflag=idFollowupflag.split(',');$.each(idFollowupflag,function(index,value){if(value!="false"){winElement.find('.menu-configure-followupflag .delete').button("option","disabled",false);}});winElement.find('[name="alarm"]').click(function(){if($(this).is(":checked")){winElement.find('[name="alarmDate"]').removeAttr("disabled");}else{winElement.find('[name="alarmDate"],[name="alarmTime"]').attr("disabled","disabled").val('');}});if(winElement.find('[name="alarm"]').is(":checked")){winElement.find('[name="alarmDate"],[name="alarmTime"]').removeAttr("disabled");}
+winElement.find('[name="done"]').click(function(){if($(this).is(":checked")){winElement.find(".input-done input").attr("disabled","disabled");}else{winElement.find(".input-done input").removeAttr("disabled");}});winElement.find(".followupflag-color-fields").hide();winElement.find(".followupflag-color.sample-list .sample-item").click(function(){winElement.find('.menu-configure-followupflag .save').button("enable");winElement.find(".followupflag-color.sample-list .sample-item").removeClass("selected");$(this).addClass("selected");var color=$(this).attr('alt');winElement.find('[name="backgroundColor"]').css('background-color',color).val(color)});winElement.find(".followupflag-color.sample-list .sample-item.selected").trigger('click');winElement.find('[name="setColor"]').change(function(){if(winElement.find('[name="setColor"]').val()=="default"){winElement.find(".followupflag-color.sample-list").show("fast");winElement.find(".followupflag-color-fields").hide();winElement.find(".followupflag-color.sample-list .sample-item.selected").trigger('click');}else if(winElement.find('[name="setColor"]').val()=="custom"){winElement.find(".followupflag-color-fields").show("fast");winElement.find(".followupflag-color.sample-list").hide();winElement.find(".colorwell").focus();}});if(winElement.find('[name="setColor"] option:selected').val()=="custom"){winElement.find('[name="setColor"]').trigger("change");}
+var colorpickerPreviewChange=function(color){winElement.find('.menu-configure-followupflag .save').button("enable");winElement.find('.colorwell-selected').val(color).css('background-color',color);winElement.find('.flag-color-preview').css('background',color);}
+var f=$.farbtastic(winElement.find('.colorpicker'),colorpickerPreviewChange);var selected;winElement.find('.colorwell').each(function(){f.linkTo(this);}).focus(function(){if(selected){$(selected).removeClass('colorwell-selected');}
+$(selected=this).addClass('colorwell-selected');f.linkTo(this,colorpickerPreviewChange);f.linkTo(colorpickerPreviewChange);});if(winElement.find('[name="setColor"] option:selected').val()=="custom"){winElement.find(".colorwell").focus();}}
+function alarmFollowupflagged(alert_type,filter_list){var currentDate=new Date().toString("dd/MM/yyyy");var data={alarmDeadline:false,doneDeadline:false,filtersAlarms:false};switch(alert_type){case'followupflagAlarms':$('.doneDeadline').remove();$('.alarmDeadline').remove();data.alarmDeadline=$.cookie("fadeAlarm")!=currentDate?true:false;data.doneDeadline=$.cookie("fadeCompleted")!=currentDate?true:false;break;case'filtersAlarms':$('.filtersDeadline').remove();data.filtersAlarms=$.cookie("fadeFilterAlarm")!=currentDate?true:false;break;default:$('.gray').remove();data.alarmDeadline=$.cookie("fadeAlarm")!=currentDate?true:false;data.doneDeadline=$.cookie("fadeCompleted")!=currentDate?true:false;data.filtersAlarms=$.cookie("fadeFilterAlarm")!=currentDate?true:false;break;};var startDate=(new Date()).set({hour:0,minute:0,second:0}).toString('yyyy-MM-dd 00:00:00');var endDate=(new Date()).set({hour:0,minute:0,second:0}).addHours(24).toString('yyyy-MM-dd 00:00:00');if(data.alarmDeadline){var decodeAlarms={'sent':[],'task':[]};alarms=DataLayer.get('followupflagged',{filter:['AND',['<','alarmDeadline',endDate],['=','isSent','0'],['=','isDone','0']],criteria:{deepness:1}});if(alarms.length>0){var itens=[];for(var i=0;i<alarms.length;i++){var date=Date.parseExact(alarms[i]['alarmDeadline'],'yyyy-MM-dd HH:mm:ss');alarms[i]['alarmDeadline']=date.toString('dd/MM HH:mm');var nameFollowupflag=alarms[i]['followupflag']['id']<7?get_lang(alarms[i]['followupflag']['name']):alarms[i]['followupflag']['name'];var li_alarm=alarms[i]['alarmDeadline']+' - '+nameFollowupflag+' - '+alarms[i]['message']['headers']['subject'];if(alarms[i]['doneDeadline']!=''){var dateDone=Date.parseExact(alarms[i]['doneDeadline'],'yyyy-MM-dd HH:mm:ss');if(dateDone.getTime()<$.now())
+continue;}
+if(date.getTime()<=$.now())
+decodeAlarms.sent.push({"msg_number":alarms[i]['messageNumber'],"msg_folder":alarms[i]['folderName'],"a":truncate(li_alarm,34),'id':alarms[i].id});else
+decodeAlarms.task.push({a:truncate(li_alarm,34),sentTime:date.getTime()/1000,id:alarms[i].id,'msg_folder':alarms[i].folderName,'msg_number':alarms[i].messageNumber});}
+if(decodeAlarms.task.length)
+alarmDeadline.load(decodeAlarms.task);if(decodeAlarms.sent.length)
+data.alarmDeadline={alarms:decodeAlarms.sent,title:get_lang('Follow ups'),caption:(itens.length==1)?get_lang('You have one undone message today:'):get_lang('You have %1 follow ups due for today:',decodeAlarms.sent.length),type:'alarmDeadline'};else
+data.alarmDeadline=false;}else
+data.alarmDeadline=false;}
+if(data.doneDeadline){alarms=DataLayer.get('followupflagged',{filter:['AND',['>','doneDeadline',startDate],['<','doneDeadline',endDate]],criteria:{deepness:1}});if(alarms.length>0){var itens=[];for(var i=0;i<alarms.length;i++){var date=Date.parseExact(alarms[i]['doneDeadline'],'yyyy-MM-dd HH:mm:ss');alarms[i]['doneDeadline']=date.toString('dd/MM HH:mm');var nameFollowupflag=alarms[i]['followupflag']['id']<7?get_lang(alarms[i]['followupflag']['name']):alarms[i]['followupflag']['name'];var li_alarm=alarms[i]['doneDeadline']+' - '+nameFollowupflag+' - '+truncate(alarms[i]['message']['headers']['subject'],15);itens.push({a:truncate(li_alarm,34),id:alarms[i].id,'msg_folder':alarms[i].folderName,'msg_number':alarms[i].messageNumber});}
+data.doneDeadline={alarms:itens,title:get_lang('Done'),caption:(itens.length==1)?get_lang('You have one undone message today:'):get_lang('You have %1 follow ups due for today:',itens.length),type:'doneDeadline'};}else
+data.doneDeadline=false;}
+if(data.filtersAlarms){alarms=filter_list;if(alarms.length>0){var itens=[];for(var i=0;i<alarms.length;i++){alarms[i]['udate']=new Date(alarms[i]['udate']*1000).toString('dd/MM HH:mm');var li_alarm=alarms[i]['udate']+' - '+alarms[i]['from']+' - '+alarms[i]['subject'];itens.push({'msg_number':alarms[i]['msg_number'],'msg_folder':alarms[i]['msg_folder'],a:truncate(html_entities(li_alarm),34),id:alarms[i].id});}
+data.filtersAlarms={alarms:itens,title:get_lang('Filter by sender'),caption:(itens.length==1)?get_lang('You have an archived message:'):get_lang('You have %1 messages archived:',itens.length),type:'filtersDeadline',captions:{singular:'You have one undone message today:',plural:"You have %1 undone messages today:"}};}else
+data.filtersAlarms=false;}
+for(var i in data)
+if(data[i]!=false)
+showAlarmsModal(data[i]);$('.gray').find('.content-alarm').hide();$('.gray').find('.header-alarm [name="header-icon"]').removeClass('minimize-alarm').addClass('maximize-alarm');if($('.gray').length>0){if($('.gray').hasClass('filtersDeadline')){$('.filtersDeadline').find('.content-alarm').show();$('.filtersDeadline .header-alarm [name="header-icon"]').removeClass('maximize-alarm').addClass('minimize-alarm');}else if($('.gray').hasClass('alarmDeadline')){$('.alarmDeadline').find('.content-alarm').show();$('.alarmDeadline .header-alarm [name="header-icon"]').removeClass('maximize-alarm').addClass('minimize-alarm');}else if($('.gray').hasClass('doneDeadline')){$('.doneDeadline').find('.content-alarm').show();$('.doneDeadline .header-alarm [name="header-icon"]').removeClass('maximize-alarm').addClass('minimize-alarm');}}}
+function showAlarmsModal(alarm){var ok_function=function(event,type,type_cookie){if($(event.target).parents('.'+type).find('[name="stopAlert"]').is(':checked')){$.cookie(type_cookie,(new Date).toString("dd/MM/yyyy"),{expires:1});}}
+var dialogText=DataLayer.render("../prototype/modules/mail/templates/followupflag_alarm_list.ejs",alarm);var titulo='<div class="header-alarm"><span class="img_title"></span><span class="title-alarm"><strong>'+alarm.title+'</strong></span><span name="header-icon" class="maximize-alarm"></span></div>';$("#freeow").freeow(titulo,dialogText,{classes:["gray",alarm.type],autoHide:false,startStyle:null,onClick:function(event){var type='';var type_cookie='';if($(this).hasClass('alarmDeadline')){type='alarmDeadline';type_cookie='fadeAlarm';}else if($(this).hasClass('doneDeadline')){type='doneDeadline';type_cookie='fadeCompleted';}else if($(this).hasClass('filtersDeadline')){type='filtersDeadline';type_cookie='fadeFilterAlarm';}
+if($(event.target).hasClass('stop-alert-alarm')){return;}
+if($(event.target).hasClass('minimize-alarm')){$('.'+type).find('.content-alarm').hide();$(event.target).removeClass('minimize-alarm').addClass('maximize-alarm');return;}
+if($(event.target).hasClass('maximize-alarm')){$('.'+type).find('.content-alarm').show();$(event.target).removeClass('maximize-alarm').addClass('minimize-alarm');return;}
+if($((!!$.browser.safari)?event.target.parentElement:event.target).hasClass('confirm-alarm')){ok_function(event,type,type_cookie);$('.'+type).remove();return;}
+return false;}});$('.gray .background .content p').remove();$('.gray .icon').remove();$('.gray .close').remove();$('div.gray.alarmDeadline .button.delete').button({text:false,icons:{primary:'ui-icon-close'}})
+$('.content-alarm button').button();}
+function cancelAlarm(element,idAlarm,messageNumber,folderName){$(element).parents('li').remove();var view='div.gray.alarmDeadline';var length=$(view).find('ul.message-list li').length;if(length>0){var msg='';if(length==1)
+msg=get_lang('You have a follow up due for today:');else
+msg=get_lang('You have %1 follow ups due for today:',length);$(view).find('span.subtitle-alarm strong').html(msg);}else
+$(view).remove();DataLayer.put('followupflagged',{id:idAlarm,isSent:'1',folderName:folderName,messageNumber:messageNumber,uid:User.me.uid});DataLayer.commit();}
+alarmDeadline={load:function(alarm){var currentDate=new Date().toString("dd/MM/yyyy")
+if($.cookie("fadeAlarm")!=currentDate)
+for(var i=0;i<alarm.length;i++)
+this.addAlarm(alarm[i]);},addAlarm:function(alarm){DataLayer.task(parseInt(alarm['sentTime']),function(timestamp){var view='div.gray.alarmDeadline';if(!$(view+' li.message-item.'+alarm.id).length){var currentDate=new Date().toString("dd/MM/yyyy")
+if($.cookie("fadeAlarm")!=currentDate)
+if($('div.gray.alarmDeadline').length){$(view).find('ul.message-list').append(DataLayer.render("../prototype/modules/mail/templates/followupflag_alarmDeadline_add_item_list.ejs",alarm))
+var length=$(view).find('ul.message-list li').length;var msg='';if(length==1)
+msg=get_lang('You have a follow up due for today:');else
+msg=get_lang('You have %1 follow ups due for today:',length);$(view).find('span.subtitle-alarm strong').html(msg);$(view+' .button.delete').button({text:false,icons:{primary:'ui-icon-close'}});}else{var item={alarms:[alarm],title:get_lang('Follow ups'),caption:get_lang('You have one undone message today:'),type:'alarmDeadline'};showAlarmsModal(item);}}});}}
+$('#main_table').ready(function(){handlerMessageFilter=function(data){alarmFollowupflagged(null,data);}
+cExecute("$this.imap_functions.getFlaggedAlertMessages&folders="+fromRules,handlerMessageFilter);});
Index: trunk/prototype/modules/mail/templates/followupflag_configure.ejs
===================================================================
--- trunk/prototype/modules/mail/templates/followupflag_configure.ejs	(revision 6996)
+++ trunk/prototype/modules/mail/templates/followupflag_configure.ejs	(revision 7543)
@@ -114,6 +114,5 @@
 				<label class="flag-label"><%= get_lang("Color")%>: </label>
 				<input type="text" name="backgroundColor" class="colorwell background-color" value="<%=(followupflagged.backgroundColor) ? followupflagged.backgroundColor : '#00820F' %>" readonly="readonly" />
-				<div class="flag-edit flag-color-preview" style="background: <%=(followupflagged.backgroundColor) ? followupflagged.backgroundColor : '#00820F' %>">
-					<img src="../prototype/modules/mail/img/flagEditor.png">
+				<div class="flag-edit flag-color-preview" style="background: <%=(followupflagged.backgroundColor) ? followupflagged.backgroundColor : '#00820F' %> background-image:url(../prototype/modules/mail/img/mail-sprites.png);background-position: 0 -864px;">
 				</div>
 			</div>
Index: trunk/prototype/modules/attach_message/attach_message.js
===================================================================
--- trunk/prototype/modules/attach_message/attach_message.js	(revision 7414)
+++ trunk/prototype/modules/attach_message/attach_message.js	(revision 7543)
@@ -138,5 +138,5 @@
 			classes += '<span class="flags followupflagged" title="'+nameFollowupflag+'" style="background:'+rowObject.followupflagged.backgroundColor+';"><img style=" margin-left:-3px;" src="../prototype/modules/mail/img/flagChecked.png"></span>';
 		}else{			
-			classes += '<span class="flags followupflagged" title="'+nameFollowupflag+'" style="background:'+rowObject.followupflagged.backgroundColor+';"><img src="../prototype/modules/mail/img/flagEditor.png"></span>';
+			classes += '<span class="flags followupflagged" title="'+nameFollowupflag+'" style="background:'+rowObject.followupflagged.backgroundColor+';background-image:url(../prototype/modules/mail/img/mail-sprites.png);background-position: 0 -864px;"</span>';
 		}
 		
