Index: /trunk/prototype/config/followupflag.ini
===================================================================
--- /trunk/prototype/config/followupflag.ini	(revision 5611)
+++ /trunk/prototype/config/followupflag.ini	(revision 5893)
@@ -6,6 +6,6 @@
 addDefaultElementsFilter = modules/mail/interceptors/Helpers.php
 
-;[before.delete]
-;clearAllFlaggedOfFollowupflag = modules/mail/interceptors/Helpers.php
+[before.delete]
+clearAllFlaggedOfFollowupflag = modules/mail/interceptors/Helpers.php
 
 [PostgreSQL.mapping]
Index: /trunk/prototype/modules/mail/interceptors/Helpers.php
===================================================================
--- /trunk/prototype/modules/mail/interceptors/Helpers.php	(revision 5890)
+++ /trunk/prototype/modules/mail/interceptors/Helpers.php	(revision 5893)
@@ -224,10 +224,12 @@
 	}
 
-/*	
+	//Remove as dependencias de uma followupflag 
 	public function clearAllFlaggedOfFollowupflag( &$uri , &$result , &$criteria , $original ){
-		//TODO - filter
-		return $result;
-	}
-*/	
+		//remove apenas se vier o id da Followupflag
+		if(isset($uri['id']))
+			Controller::deleteALL(array('concept' => 'followupflagged'), null , array('filter' => array('=' , 'followupflagId' , $uri['id'])));
+
+	}
+	
 
 	//followupflagged:PostgreSQL.after.create
Index: /trunk/prototype/modules/mail/css/followupflag.css
===================================================================
--- /trunk/prototype/modules/mail/css/followupflag.css	(revision 5713)
+++ /trunk/prototype/modules/mail/css/followupflag.css	(revision 5893)
@@ -56,4 +56,7 @@
 .colorpicker { float: right; margin: -15px 0 0 0; }
 
+.delete_followupflag{float:right; position:absolute; right:5px; top:2px;}
+.delete_followupflag:hover{border:1px solid #2E6E9E; background-color:#FFFFFF; -moz-border-radius: 5px; -webkit-border-radius:5px; width: 16px; height: 16px;}
+
 .followupflag-configure-win .followupflag-container .menu-configure-followupflag{ 
 	position:absolute; 
Index: /trunk/prototype/modules/mail/js/followupflag.js
===================================================================
--- /trunk/prototype/modules/mail/js/followupflag.js	(revision 5890)
+++ /trunk/prototype/modules/mail/js/followupflag.js	(revision 5893)
@@ -336,5 +336,27 @@
 	winElement.find('.date').datepicker();
 	winElement.find('.time').timepicker({});
-	winElement.find('[name="name"]').combobox();
+	winElement.find('[name="name"]').combobox()
+	//pega o botão criado
+	.next().next().click(function (event, ui){ 	
+		var refreshList = $(this);
+		$(".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 removeLi = $(this).parents("li");
+			DataLayer.remove('followupflag', false);
+			DataLayer.get('followupflag');		
+			DataLayer.remove('followupflag', id);
+			DataLayer.commit(false, false, function(data){
+				$(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());				
+				$(refreshList).trigger("click");
+			});			
+			event.stopImmediatePropagation();			
+		});
+
+	});
 	winElement.find('.ui-corner-right.ui-button-icon').attr('title', get_lang('Show All Items'));
 
@@ -418,40 +440,38 @@
 function alarmFollowupflagged(){
     $('.followupflag-alarm').remove();
-
-    var toIterate = [
-{
-	attrDeadline: 'doneDeadline', 
-	caption: {
-	    singular:'You have one undone message today:', 
-	    plural:"You have %1 undone messages today:"
-	},
-	onOk: function(event){
-	    if($(event.target).parents('.doneDeadline').find('[name="stopAlert"]').is(':checked')){
-		$.cookie("fadeCompleted", (new Date).toString("dd/MM/yyyy"), {
-		    expires: 1
-		});
-	    }
-	},
-	enable: ($.cookie("fadeCompleted") != (new Date).toString("dd/MM/yyyy"))
-    },
-    {
-	attrDeadline: 'alarmDeadline',
-	caption: {
-	    singular:'You have a follow up due for today:', 
-	    plural:'You have %1 follow ups due for today:'
-	},
-	onOk: function(event){
-	    if($(event.target).parents('.alarmDeadline').find('[name="stopAlert"]').is(':checked')){
-		$.cookie("fadeAlarm", (new Date).toString("dd/MM/yyyy"), {
-		    expires: 1
-		});
-	    }
-	},
-	enable: ($.cookie("fadeAlarm") != (new Date).toString("dd/MM/yyyy"))
-    }
-    ];
-    var i = 0;
-    while (it = toIterate.pop()){
-	if (!it.enable) continue;
+	var toIterate = [
+		{
+			attrDeadline: 'doneDeadline', 
+			caption: {singular:'You have one undone message today:', 
+			plural:"You have %1 undone messages today:"
+			},
+			onOk: function(event){
+				if($(event.target).parents('.doneDeadline').find('[name="stopAlert"]').is(':checked')){
+					$.cookie("fadeCompleted", (new Date).toString("dd/MM/yyyy"), { 
+						expires: 1 
+					});
+				}
+			},
+			enable: ($.cookie("fadeCompleted") != (new Date).toString("dd/MM/yyyy"))
+		},
+		{
+			attrDeadline: 'alarmDeadline',
+			caption: {
+				singular:'You have a follow up due for today:', 
+				plural:'You have %1 follow ups due for today:'
+			},
+			onOk: function(event){
+				if($(event.target).parents('.alarmDeadline').find('[name="stopAlert"]').is(':checked')){
+					$.cookie("fadeAlarm", (new Date).toString("dd/MM/yyyy"), { 
+						expires: 1 
+					});
+				}
+			},
+			enable: ($.cookie("fadeAlarm") != (new Date).toString("dd/MM/yyyy"))
+		}
+	];
+	var i = 0;
+	while (it = toIterate.pop()){
+		if (!it.enable) continue;
 
 		var alarmInRange = DataLayer.get('followupflagged', {filter: ['AND', ['>', it.attrDeadline, (new Date()).set({hour:0, minute:0, second:0}).toString('yyyy-MM-dd 00:00:00')], ['<', it.attrDeadline, (new Date()).set({hour:0, minute:0, second:0}).addHours(24).toString('yyyy-MM-dd 00:00:00')]], criteria: {deepness: 1}});
@@ -473,42 +493,36 @@
 				get_lang(it.caption.plural, alarmInRange.length);
 				
-	var data = {
-	    alarmInRange : alarmInRange, 
-	    caption: caption, 
-	    it : it
-	};
-	var dialogText = DataLayer.render("../prototype/modules/mail/templates/followupflag_alarm_list.ejs", data);
+			var data = {
+				alarmInRange : alarmInRange, 
+				caption: caption, 
+				it : it
+			};
+			var dialogText = DataLayer.render("../prototype/modules/mail/templates/followupflag_alarm_list.ejs", data);
 			
-	/**
+			/**
 			 * A última dialog criada é a dialog mais ao alto
 			 */
-	var offsetHeight = $('.ZebraDialog.right-bottom:last').length ? 
-	$(window).height() - $('.ZebraDialog.right-bottom:last').position().top : 0;
-
-	/**
+			var offsetHeight = $('.ZebraDialog.right-bottom:last').length ? 
+				$(window).height() - $('.ZebraDialog.right-bottom:last').position().top : 0;
+
+			/**
 			 * Se for a primeira, desloca para cima do rodapé do grid
 			 * caso contrário desloca para um pouco acima da última dialog criada
 			 */
-	offsetHeight = !offsetHeight ? 35 : offsetHeight + 20 ;
-			
-	var dialog = new $.Zebra_Dialog(dialogText, {
-	    'buttons':  ['Ok'],
-	    'modal': false,
-	    'vcenter_short_message': false,
-	    'position': ['right - 20', 'bottom - ' + offsetHeight.toString() ],
-	    'custom_class': 'right-bottom followupflag-alarm '+it.attrDeadline,
-	}).dialog;
-			
-	$(".ZebraDialog.followupflag-alarm .ZebraDialog_Button0").click(it.onOk);
-			
-	$(".ZebraDialog.followupflag-alarm .display-options .more").click(function(event) {
-	    $(event.target).parents('.followupflag-alarm').find('.message-list').css('height', 'auto');
-	});
-			
-    }		
-}    
-    
+			offsetHeight = !offsetHeight ? 35 : offsetHeight + 20 ;			
+			var dialog = new $.Zebra_Dialog(dialogText, {
+				'buttons':  ['Ok'],
+				'modal': false,
+				'vcenter_short_message': false,
+				'position': ['right - 20', 'bottom - ' + offsetHeight.toString() ],
+				'custom_class': 'right-bottom followupflag-alarm '+it.attrDeadline,
+			}).dialog;
+			$(".ZebraDialog.followupflag-alarm .ZebraDialog_Button0").click(it.onOk);
+			$(".ZebraDialog.followupflag-alarm .display-options .more").click(function(event) {
+				$(event.target).parents('.followupflag-alarm').find('.message-list').css('height', 'auto');
+			});
+		}		
+	}
 }
-
 $('#main_table').ready(function(){
     alarmFollowupflagged();
