Index: /trunk/prototype/modules/mail/css/label.css
===================================================================
--- /trunk/prototype/modules/mail/css/label.css	(revision 5537)
+++ /trunk/prototype/modules/mail/css/label.css	(revision 5547)
@@ -95,5 +95,5 @@
 }
 #MyMarckersList.list-label .status-list-labels{display:inline-block; position: absolute;}
-#MyMarckersList.list-label ul {height: 60%; margin: 5px 0 0 6px; padding:0; list-style:none; }
+#MyMarckersList.list-label ul {height: auto; margin: 5px 0 0 6px; padding:0; list-style:none; }
 #MyMarckersList.list-label.acc-list ul li{ border-radius:3px;  padding:2px 2px 3px 2px;}
 #MyMarckersList.list-label li{ background: #FFF; margin:2px 2px 0 12px; border:1px solid #CCC; width: 150px; height:13px; }
Index: /trunk/prototype/modules/mail/js/label.js
===================================================================
--- /trunk/prototype/modules/mail/js/label.js	(revision 5537)
+++ /trunk/prototype/modules/mail/js/label.js	(revision 5547)
@@ -1,2 +1,19 @@
+function configureLabel(event, ui){
+	var idmarkernow = $(this).find('[name="labelItemId"]').val();
+	winElement.find('.edit-label').val(idmarkernow);
+	winElement.find('.input-nome').val($(this).find("span").text());
+	
+	var colorpicker = winElement.find('.lebals-colorpicker');
+	colorpicker.find('input[name="backgroundColor"]').val(rgb2hex($(this).css("backgroundColor")))
+	.css("background-color", $(this).css("backgroundColor")).focus().end()
+	.find('input[name="fontColor"]').val(rgb2hex($(this).css("color"))).css("background-color", $(this).css("color")).focus().end()
+	.find('input[name="borderColor"]').val(rgb2hex($(this).css("border-left-color"))).css("background-color", $(this).css("border-left-color")).focus().end()
+	.find('.preview-label-outer').css({
+		'background-color':$(this).css("backgroundColor"),
+		'color':$(this).css("color"),
+		'border-color':$(this).css("border-left-color")
+	})		
+	winElement.find(".preview-label-inner").text($(this).text());
+}
 function editLabel(){	
 	var conteudoSpan = $(this).parent().find(".text-list").text();
@@ -43,21 +60,5 @@
   ("0" + parseInt(rgb[3],10).toString(16)).slice(-2);
 }
-function configureLabel(event, ui){
-	var idmarkernow = $(this).find('[name="labelItemId"]').val();
-	winElement.find('.edit-label').val(idmarkernow);
-	winElement.find('.input-nome').val($(this).find("span").text());
-	
-	var colorpicker = winElement.find('.lebals-colorpicker');
-	colorpicker.find('input[name="backgroundColor"]').val(rgb2hex($(this).css("backgroundColor")))
-	.css("background-color", $(this).css("backgroundColor")).focus().end()
-	.find('input[name="fontColor"]').val(rgb2hex($(this).css("color"))).css("background-color", $(this).css("color")).focus().end()
-	.find('input[name="borderColor"]').val(rgb2hex($(this).css("border-left-color"))).css("background-color", $(this).css("border-left-color")).focus().end()
-	.find('.preview-label-outer').css({
-		'background-color':$(this).css("backgroundColor"),
-		'color':$(this).css("color"),
-		'border-color':$(this).css("border-left-color")
-	})		
-	winElement.find(".preview-label-inner").text($(this).text());
-}
+
 function confirmDelete(id){
 	$.Zebra_Dialog('<strong>Deseja excluir esse marcador?</strong>', {
@@ -112,11 +113,11 @@
 	}		
 }
-function new_label(nameLabel){
+function new_label(nameLabel, isNew){
 	var labelCreated = {
 		uid: User.me.id,
 		name : nameLabel,
-		backgroundColor : winElement.find("input[name='backgroundColor']").val(),
-		fontColor : winElement.find("input[name='fontColor']").val(),
-		borderColor : winElement.find("input[name='borderColor']").val()
+		backgroundColor : !!isNew ? '#ebebeb' : winElement.find("input[name='backgroundColor']").val(),
+		fontColor : !!isNew ? '#000000' : winElement.find("input[name='fontColor']").val(),
+		borderColor :!!isNew ? '#000000' : winElement.find("input[name='borderColor']").val()
 	}
 	DataLayer.put('label', labelCreated);
@@ -132,7 +133,7 @@
 			name : labels[labels.length- 1].name,
 			uid: User.me.id,
-			bgColor : winElement.find("input[name='backgroundColor']").val(),
-			fontColor : winElement.find("input[name='fontColor']").val(),
-			borderColor : winElement.find("input[name='borderColor']").val()
+			bgColor : !!isNew ? '#ebebeb' : winElement.find("input[name='backgroundColor']").val(),
+			fontColor : !!isNew ? '#000000' : winElement.find("input[name='fontColor']").val(),
+			borderColor : !!isNew ? '#000000' : winElement.find("input[name='borderColor']").val()
 		};
 
@@ -197,22 +198,5 @@
 
 	winElement = data.window;
-
-	/* var configureLabel = function(event, ui){
-		var idmarkernow = $(this).find('[name="labelItemId"]').val();
-		winElement.find('.edit-label').val(idmarkernow);
-		winElement.find('.input-nome').val($(this).find("span").text());
-		
-		var colorpicker = winElement.find('.lebals-colorpicker');
-		colorpicker.find('input[name="backgroundColor"]').val(rgb2hex($(this).css("backgroundColor")))
-		.css("background-color", $(this).css("backgroundColor")).focus().end()
-		.find('input[name="fontColor"]').val(rgb2hex($(this).css("color"))).css("background-color", $(this).css("color")).focus().end()
-		.find('input[name="borderColor"]').val(rgb2hex($(this).css("border-left-color"))).css("background-color", $(this).css("border-left-color")).focus().end()
-		.find('.preview-label-outer').css({
-			'background-color':$(this).css("backgroundColor"),
-			'color':$(this).css("color"),
-			'border-color':$(this).css("border-left-color")
-		})		
-		winElement.find(".preview-label-inner").text($(this).text());
-	} */
+	
 	//TODO Mudar quando API abstrair atualizações no cache
 	DataLayer.remove('label',false);
@@ -320,5 +304,5 @@
 		var nameLabel = winElement.find(".insert-label").val();
 		if(nameLabel.length >= 2){
-			new_label(nameLabel);
+			new_label(nameLabel, true);
 			$.Watermark.ShowAll();
 			winElement.find(".insert-label").val("");
@@ -421,5 +405,5 @@
 			var nameLabel = winElement.find(".input-nome").val();
 			if(nameLabel.length >= 2){
-				new_label(nameLabel);				
+				new_label(nameLabel, false);				
 				winElement.find(".insert-label").val("");
 				$.Watermark.ShowAll();				
Index: /trunk/prototype/modules/mail/js/followupflag.js
===================================================================
--- /trunk/prototype/modules/mail/js/followupflag.js	(revision 5533)
+++ /trunk/prototype/modules/mail/js/followupflag.js	(revision 5547)
@@ -279,5 +279,6 @@
 			var messageNumber   = selectedMessageIds[i];
 			//var followupflag = DataLayer.get('followupflag', followupflagId.toString()),
-			var followupflagged = {
+			var idFollowupflagged = winElement.find('.id-followup').val();
+			var followupflagged = DataLayer.merge({
 				uid : User.me.id,
 				followupflagId : followupflagId, 
@@ -288,5 +289,5 @@
 				isDone: isDone,
 				backgroundColor : backgroundColor
-			}
+			}, !!idFollowupflagged ? {id: idFollowupflagged} : {});
 			
 			if (alarmDate = winElement.find('[name="alarmDate"]').datepicker("getDate")) {
@@ -304,9 +305,9 @@
 			}
 			
+			var flagged = $('#td_message_followup_' + messageNumber + ', ' + '#td_message_followup_search_' + messageNumber).find(".flag-edited");
 			if(isDone){
-				$('#td_message_followup_' + messageNumber + ', ' + 
-				'#td_message_followup_search_' + messageNumber).find(".flag-edited")
-				.find("img").attr("src", "../prototype/modules/mail/img/flagChecked.png")
-				.css("margin-left","-3px");
+				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");			
 			}
 			
@@ -316,5 +317,9 @@
 			DataLayer.put('followupflagged', followupflagged);
 		}
-		DataLayer.commit();
+		DataLayer.commit(false, false, function(data){
+			followupflags = DataLayer.get('followupflagged',{criteria:{order: 'id'}}, true);		
+			var id = followupflags[followupflags.length - 1].id;
+			winElement.find('.id-followup').val(id);
+		});		
 		
 		//onceOpenedHeadersMessages[current_folder][followupflagged.messageNumber]['followupflagged']['followupflag'] = {};
@@ -335,10 +340,8 @@
 			var messageNumber   = selectedMessageIds[i];
 			var flag_id = onceOpenedHeadersMessages[current_folder][messageNumber]['followupflagged'].id;
+			var flagged = $('#td_message_followup_' + messageNumber + ', ' + '#td_message_followup_search_' + messageNumber).find(".flag-edited");
 			DataLayer.remove('followupflagged', flag_id);
-			$('#td_message_followup_' + messageNumber + ', ' + 
-			  '#td_message_followup_search_' + messageNumber).find(".flag-edited").css("background", '#CCC');
-			$('#td_message_followup_' + messageNumber + ', ' + 
-				'#td_message_followup_search_' + messageNumber).find(".flag-edited")
-				.find("img").attr("src", "../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");;
+			flagged.css("background", '#cccccc');
+			flagged.find("img").attr("src", "../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");
 		}
 		DataLayer.commit();
Index: /trunk/prototype/modules/mail/templates/followupflag_configure.ejs
===================================================================
--- /trunk/prototype/modules/mail/templates/followupflag_configure.ejs	(revision 5545)
+++ /trunk/prototype/modules/mail/templates/followupflag_configure.ejs	(revision 5547)
@@ -47,4 +47,5 @@
 		<legend><%= get_lang("Basic")%></legend>
 		<div class="followupflag-configure">
+			<input type="hidden" class="id-followup" value="" name="followupFlag">
 			<label class="label-name"><%= get_lang("Flag as")%>:</label> 
 			<select name="name">
Index: /trunk/expressoMail1_2/setup/tables_current.inc.php
===================================================================
--- /trunk/expressoMail1_2/setup/tables_current.inc.php	(revision 1035)
+++ /trunk/expressoMail1_2/setup/tables_current.inc.php	(revision 5547)
@@ -33,5 +33,51 @@
             'ix' => array(),
             'uc' => array()
+		),
+		
+		'expressomail_label' => array(
+			'fd' => array(
+				'id' => array('type' => 'auto','nullable' => False),
+				'user_id' => array('type' => 'int', 'precision' => '8','nullable' => true),
+				'name' => array('type' => 'varchar','precision' => '255','nullable' => true),
+				'border_color' => array('type' => 'varchar','precision' => '7','nullable' => true),
+				'background_color' => array('type' => 'varchar','precision' => '7','nullable' => true),
+				'font_color' => array('type' => 'varchar','precision' => '7','nullable' => true)
+			),
+			'pk' => array('id'),
+			'fk' => array(),
+			'ix' => array(),
+			'uc' => array()
+		),
+
+		'expressomail_followupflag' => array(
+			'fd' => array(
+				'id' => array('type' => 'auto','nullable' => False),
+				'user_id' => array('type' => 'int', 'precision' => '8','nullable' => true),
+				'name' => array('type' => 'varchar','precision' => '255','nullable' => False)
+			),
+			'pk' => array('id'),
+			'fk' => array(),
+			'ix' => array(),
+			'uc' => array()
+		),
+	
+		'expressomail_message_followupflag' => array(
+			'fd' => array(
+				'id' => array('type' => 'auto','nullable' => False),
+				'followupflag_id' => array('type' => 'int', 'precision' => '8','nullable' => False),					
+				'border_color' => array('type' => 'varchar','precision' => '7','nullable' => true),
+				'background_color' => array('type' => 'varchar','precision' => '7','nullable' => true),
+				'font_color' => array('type' => 'varchar','precision' => '7','nullable' => true),
+				'alarm_deadline' => array('type' => 'timestamp', 'nullable' => true),
+				'done_deadline' => array('type' => 'timestamp', 'nullable' => true),
+				'is_done' => array('type' => 'int', 'precision' => '8','nullable' => true)
+			),
+			'pk' => array('id'),
+			'fk' => array(),
+			'ix' => array(),
+			'uc' => array()
+			)
 		)
+		
 	);
 ?>
Index: /trunk/expressoMail1_2/setup/tables_update.inc.php
===================================================================
--- /trunk/expressoMail1_2/setup/tables_update.inc.php	(revision 5311)
+++ /trunk/expressoMail1_2/setup/tables_update.inc.php	(revision 5547)
@@ -141,3 +141,63 @@
  	    return $setup_info['expressoMail1_2']['currentver']; 
  	}
+	$test[] = '2.4.0';
+	function expressoMail1_2_upgrade2_4_0() {
+    	$oProc = $GLOBALS['phpgw_setup']->oProc;            
+            $oProc->CreateTable('expressomail_label',array(
+				'fd' => array(
+					'id' => array('type' => 'auto','nullable' => False),
+					'user_id' => array('type' => 'int', 'precision' => '8','nullable' => true),
+					'name' => array('type' => 'varchar','precision' => '255','nullable' => true),
+					'border_color' => array('type' => 'varchar','precision' => '7','nullable' => true),
+					'background_color' => array('type' => 'varchar','precision' => '7','nullable' => true),
+					'font_color' => array('type' => 'varchar','precision' => '7','nullable' => true)
+				),
+				'pk' => array('id'),
+				'fk' => array(),
+				'ix' => array(),
+				'uc' => array()
+				)
+			);
+			$oProc->CreateTable('expressomail_followupflag',array(
+				'fd' => array(
+					'id' => array('type' => 'auto','nullable' => False),
+					'user_id' => array('type' => 'int', 'precision' => '8','nullable' => true),
+					'name' => array('type' => 'varchar','precision' => '255','nullable' => False)
+				),
+				'pk' => array('id'),
+				'fk' => array(),
+				'ix' => array(),
+				'uc' => array()
+				)
+			);
+			$oProc->CreateTable('expressomail_message_followupflag',array(
+				'fd' => array(
+					'id' => array('type' => 'auto','nullable' => False),
+					'followupflag_id' => array('type' => 'int', 'precision' => '8','nullable' => False),					
+					'border_color' => array('type' => 'varchar','precision' => '7','nullable' => true),
+					'background_color' => array('type' => 'varchar','precision' => '7','nullable' => true),
+					'font_color' => array('type' => 'varchar','precision' => '7','nullable' => true),
+					'alarm_deadline' => array('type' => 'timestamp', 'nullable' => true),
+					'done_deadline' => array('type' => 'timestamp', 'nullable' => true),
+					'is_done' => array('type' => 'int', 'precision' => '8','nullable' => true)
+				),
+				'pk' => array('id'),
+				'fk' => array(),
+				'ix' => array(),
+				'uc' => array()
+				)
+			);			
+			$oProc->query("ALTER TABLE expressomail_message_followupflag ADD CONSTRAINT expressomail_message_followupflag_followupflag_id_fkey FOREIGN KEY (followupflag_id) REFERENCES expressomail_followupflag (id);");
+			$oProc->query("INSERT INTO expressomail_followupflag(name) VALUES ('Follow up'), ('Read'), ('Forward'), ('Answer'), ('Don''t forward'), ('Don''t answer');");
+			
+			//Insert reservados para as labels padrões referentes ao thunderbir
+			$oProc->query("INSERT INTO expressomail_label(name, font_color, border_color, background_color) VALUES ('Important', '#ff0000', '#ff0000', '#ffffff');"); 
+			$oProc->query("INSERT INTO expressomail_label(name, font_color, border_color, background_color) VALUES ('Work', '#ff9900', '#ff9900', '#ffffff');"); 
+			$oProc->query("INSERT INTO expressomail_label(name, font_color, border_color, background_color) VALUES ('personal', '#009900', '#009900', '#ffffff');"); 
+			$oProc->query("INSERT INTO expressomail_label(name, font_color, border_color, background_color) VALUES ('todo', '#3333ff', '#3333ff', '#ffffff');"); 
+			$oProc->query("INSERT INTO expressomail_label(name, font_color, border_color, background_color) VALUES ('later', '#993399', '#993399', '#ffffff');");
+						
+		$GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '2.4.1';
+        return $GLOBALS['setup_info']['expressoMail1_2']['currentver'];
+	}	
 ?>
Index: /trunk/expressoMail1_2/setup/setup.inc.php
===================================================================
--- /trunk/expressoMail1_2/setup/setup.inc.php	(revision 5298)
+++ /trunk/expressoMail1_2/setup/setup.inc.php	(revision 5547)
@@ -12,8 +12,13 @@
 	$setup_info['expressoMail1_2']['name']      	= 'expressoMail1_2';
 	$setup_info['expressoMail1_2']['title']     	= 'Expresso Mail';
-	$setup_info['expressoMail1_2']['version']   	= '2.4.0';
+	$setup_info['expressoMail1_2']['version']   	= '2.4.1';
 	$setup_info['expressoMail1_2']['app_order'] 	= 2;
 	$setup_info['expressoMail1_2']['tables'][]		= 'phpgw_expressomail_contacts';
     $setup_info['expressoMail1_2']['tables'][]		= 'phpgw_certificados';
+	
+	$setup_info['expressoMail1_2']['tables'][]		= 'expressomail_label';
+	$setup_info['expressoMail1_2']['tables'][]		= 'expressomail_followupflag';
+	$setup_info['expressoMail1_2']['tables'][]		= 'expressomail_message_followupflag';
+	
 	$setup_info['expressoMail1_2']['enable']    	= 1;
 
