Index: trunk/expressoMail1_2/js/search.js
===================================================================
--- trunk/expressoMail1_2/js/search.js	(revision 5506)
+++ trunk/expressoMail1_2/js/search.js	(revision 5533)
@@ -16,5 +16,5 @@
 		this.elementChecked = false;
 	}
-
+	
 	//Monta os forms dentro da janela;
 	searchE.prototype.showForms = function(value)
@@ -442,8 +442,19 @@
 	
 	searchE.prototype.make_tr_message = function(aux,border_id,i) {
+	console.log(aux);
+	/**
+	 * Preenche a estrutura de cache de mensagens para posterior consulta de 
+	 * informações sobre as mensagens no escopo global.
+	 */
+		if (!onceOpenedHeadersMessages[aux.boxname])
+			onceOpenedHeadersMessages[aux.boxname] = {};
+		onceOpenedHeadersMessages[aux.boxname][aux.uid] = aux;	
+	
 		var tr = document.createElement("TR");
 		if(typeof(preferences.line_height) != 'undefined')
 			tr.style.height = preferences.line_height;
-
+			
+		var msg_folder = get_current_folder(); 
+				
 		var mailbox = aux.boxname;
 		var uid_msg = aux.uid;
@@ -455,5 +466,5 @@
 		tr.setAttribute('name',mailbox);
 		tr.name = mailbox;
-
+		
 		if ( aux.flag.match("U") )
 			add_className(tr,'tr_msg_unread');
@@ -466,5 +477,5 @@
 		};
 
-		for(var j=0 ; j <= 10 ; j++)
+		for(var j=0 ; j <= 11 ; j++)
 		{
 			var td = document.createElement("TD");
@@ -519,11 +530,73 @@
 			{
 				td.setAttribute("width", colSizes[1][4]);
+				td.id = "td_message_followup_search_"+uid_msg;
+				td.setAttribute("class","search-result-item");
+				//td1 = "<img src ='../prototype/modules/mail/img/flagDefault.png' title='"+get_lang('Followup')+"'>";
+				td1 = '<div class="flag-edited" style="width:9px;height:6px;"><img src="../prototype/modules/mail/img/flagEditor.png"></div>';
+						
+				$(td).click(function(event, ui){	
+					var messageClickedId = $(this).attr('id').match(/td_message_followup_search_([\d]+)/)[1];
+					var flagged = DataLayer.get('followupflagged', {filter: [
+						'AND', 
+						['=', 'messageNumber', messageClickedId], 
+						['=', 'folderName', mailbox]
+					]});
+					if(flagged == '' || flagged == [] || flagged == 'undefined'){
+						/**
+						* Aplica followupflag de Acompanhamento
+						*/
+						aux.followupflagged = {
+							uid : User.me.id,
+							folderName : mailbox, 
+							messageNumber : messageClickedId, 
+							alarmTime : false, 
+							backgroundColor : '#FF2016',
+							followupflagId: '1',
+							followupflag: DataLayer.get('followupflag', '1')
+						};
+						$(this).find(".flag-edited").css("background", aux.followupflagged.backgroundColor);
+						aux.followupflagged.id = DataLayer.put('followupflagged', aux.followupflagged);
+						
+					}else if(aux.followupflagged.id){
+						/**
+						* Remover followupflag de Acompanhamento (DFD0078:RI25)
+						*/
+						$(this).find(".flag-edited").css("background", "#cccccc");
+
+
+						DataLayer.remove('followupflagged', flagged[0].id);
+						$('#td_message_followup_' + messageClickedId + ', ' + 
+						'#td_message_followup_search_' + messageClickedId).find(".flag-edited")
+						.find("img").attr("src", "../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");
+					} else {
+						//TODO - open dialog
+					}
+					if(!DataLayer.commit()){}
+
+				});				
+			}
+			if (j == 5)
+			{
+				td.setAttribute("width", colSizes[1][5]);
+				td.id = "td_message_labels_search_"+uid_msg;
+				td.setAttribute("class","td-label-search");				
+				
+				if (aux.labels) {
+					td1 = '<img src="../prototype/modules/mail/img/tag.png">';
+					updateLabelsColumn(aux)		
+				} else {
+					td1 = '';
+				}
+			}
+			if (j == 6)
+			{
+				td.setAttribute("width", colSizes[1][6]);
 				td.id = "td_message_sent_"+uid_msg;
 				td1 = '';
 			}
 
-			if ( j == 5 )
-			{
-				td.setAttribute("width", colSizes[1][5]);
+			if ( j == 7 )
+			{
+				td.setAttribute("width", colSizes[1][7]);
 				td.className = "td_resizable";
 				td.onclick = _onclick;
@@ -536,15 +609,12 @@
 
 				var td1  = get_lang(td1).substr(get_lang(td1).length-1) == "*"?td1:get_lang(td1);
-
-									td1 = translateFolder(td1);
-
-
-				if( proxy_mensagens.is_local_folder(td1))
-				{
+				td1 = translateFolder(td1);
+
+				if (proxy_mensagens.is_local_folder(td1)) {
 					var td1 = this.aux_local_folder_display(td1);
 				}
 			}
 
-			if( j == 6 )
+			if( j == 8 )
 			{
 				var name;
@@ -557,5 +627,5 @@
 					name = name.substr(0,29) + "...";
 
-				td.setAttribute("width", colSizes[1][6]);
+				td.setAttribute("width", colSizes[1][8]);
 				td.className = "td_resizable";
 				td.onclick = _onclick;
@@ -566,5 +636,5 @@
 			}
 
-			if( j == 7 )
+			if( j == 9 )
 			{
 				var subject_encode = url_encode(subject);
@@ -575,5 +645,5 @@
 					aux.subject = aux.subject.substr(0,70) + "...";
 
-				td.setAttribute("width", colSizes[1][7]);
+				td.setAttribute("width", colSizes[1][9]);
 				td.className = "td_resizable td_msg_search_subject";
 				td.onclick = _onclick;
@@ -584,7 +654,7 @@
 			}
 
-			if( j == 8 )
-			{
-				td.setAttribute("width", colSizes[1][8]);
+			if( j == 10 )
+			{
+				td.setAttribute("width", colSizes[1][10]);
 				td.className = "td_resizable";
 				td.align		= "center";
@@ -609,5 +679,5 @@
 			}
 
-			if( j == 9 )
+			if( j == 11 )
 			{
 				td.setAttribute("width", "9.4%");//alinhamento dos campos data e tamanho
@@ -623,5 +693,5 @@
 			}
 
-			if( j == 10 )
+			if( j == 12 )
 			{
 				if (aux.flag.match("U"))
@@ -631,6 +701,20 @@
 				var td1 = '';
 			}
-			if (j<10) {
+			if (j<12) {
 				td.innerHTML = td1;
+				
+				//Carregar os followupflag nos resultados.
+				if (aux.followupflagged) {
+					$(td).attr('title', aux.followupflagged.followupflag.name)
+					.find(".flag-edited").css("background",aux.followupflagged.backgroundColor);
+					if(aux.followupflagged.isDone == "1"){
+						$(td).find(".flag-edited").find("img")
+						.attr("src", "../prototype/modules/mail/img/flagChecked.png")
+						.css("margin-left","-3px");
+					}
+				} else {
+					$(td).find(".flag-edited").css("background","#cccccc");
+				}
+				
 				tr.appendChild(td);
 			}
@@ -692,8 +776,9 @@
 			scrollSpeed: 100,
 			containment: "#divAppbox"
-		}).bind("contextmenu", function(){
-			if($(this).find("input:checkbox").attr("checked") != "checked"){
-				$(this).find("input:checkbox").trigger('click');
-				$(this).addClass("selected_msg");
+		}).bind("mouseup", function(event){
+			if(event.button == 2)
+				if($(this).find("input:checkbox").attr("checked") != "checked"){
+					$(this).find("input:checkbox").trigger('click');
+					$(this).addClass("selected_msg");
 			}
 		});
@@ -705,8 +790,7 @@
 	{
 		var data = ( Data['data'] ) ? Data['data'] : Data['data_gears'];
-		
 		if ( data == undefined )
 			return;
-		
+	
 		var cont = parseInt(0);
 
@@ -859,5 +943,7 @@
 		td_element03 = createTDElement(1,3);
 		td_element04 = createTDElement(1,4);
-		td_element1 = createTDElement(1,5,"th_resizable","left");
+		td_element05 = createTDElement(1,5);
+		td_element06 = createTDElement(1,6);
+		td_element1 = createTDElement(1,7,"th_resizable","left");
 		
 		var arrow_ascendant = function(Text)
@@ -865,5 +951,5 @@
 			return "<b>" + Text + "</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>";
 		}
-		
+
 		// Ordernar Pasta
 		if ( sort_type == 'SORTBOX' /*|| sort_type == 'SORTBOX_REVERSE'*/ )
@@ -894,5 +980,5 @@
 		
 		// Ordernar Quem
-		td_element2 = createTDElement(1,6,"th_resizable","left");
+		td_element2 = createTDElement(1,8,"th_resizable","left");
 
 		if (sort_type == 'SORTFROM' || sort_type == 'SORTWHO' /*|| sort_type == 'SORTWHO_REVERSE' || sort_type == 'SORTFROM_REVERSE'*/ )
@@ -923,5 +1009,5 @@
 		
 		// Ordernar Subject
-		td_element3 = createTDElement(1,7,"th_resizable","left");
+		td_element3 = createTDElement(1,9,"th_resizable","left");
 		
 		if (sort_type == 'SORTSUBJECT' /*|| sort_type == 'SORTSUBJECT_REVERSE'*/)
@@ -952,5 +1038,5 @@
 		
 		// Ordernar Data
-		td_element4 = createTDElement(1,8,"th_resizable","center");
+		td_element4 = createTDElement(1,10,"th_resizable","center");
 		
 		if ( sort_type == 'SORTDATE' /*|| sort_type == 'SORTDATE_REVERSE'*/ )
@@ -981,5 +1067,5 @@
 
 		// Ordernar Tamanho
-		td_element5 = createTDElement(1,9,"th_resizable","center");
+		td_element5 = createTDElement(1,11,"th_resizable","center");
 		
 		if ( sort_type == 'SORTSIZE' /*|| sort_type == 'SORTSIZE_REVERSE'*/ )
@@ -1008,4 +1094,7 @@
 			td_element5.innerHTML	= ( sort_type == 'SORTSIZE_REVERSE' ) ? arrow_ascendant(get_lang("size")) : get_lang("size");
 		}
+		
+		//Abrir a Tela de de Configuracao de Acompanhamento
+		
 		
 		tr_element.appendChild(td_element0);
@@ -1014,4 +1103,6 @@
 		tr_element.appendChild(td_element03);
 		tr_element.appendChild(td_element04);
+		tr_element.appendChild(td_element05);
+		tr_element.appendChild(td_element06);
 		tr_element.appendChild(td_element1);
 		tr_element.appendChild(td_element2);
@@ -1022,4 +1113,5 @@
 		table_element.appendChild(tbody_element);
 
+		
 		var colgr_element = buildColGroup(1);
 		colgr_element.setAttribute("id","colgroup_head_"+numBox);
@@ -1624,2 +1716,3 @@
 // Cria o objeto
 var EsearchE = new searchE();
+var EsearchE = new searchE();
