Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 5575)
+++ trunk/expressoMail1_2/js/main.js	(revision 5584)
@@ -1309,4 +1309,25 @@
 }
 
+function get_selected_messages_search_role(){
+	var aba = document.getElementById('content_id_'+currentTab);
+	var selected_messages = "";
+	jQuery(function() {
+ 	    jQuery("#"+aba.id+" tr").each(function(i, main_list) { 
+		var check_box = main_list.firstChild.firstChild;
+			if(check_box && check_box.checked) {
+				selected_messages += main_list.role + ',' ;
+			};
+ 	    });              
+ 	     
+	});
+	if (selected_messages != ""){
+		if(selected_messages.indexOf(',') == 0)
+			selected_messages = selected_messages.substring(1,(selected_messages.length));
+		selected_messages = selected_messages.substring(0,(selected_messages.length-1));
+		return selected_messages;
+	}else{
+		return false;
+	}
+}
 
 function get_selected_messages(){
Index: trunk/expressoMail1_2/js/search.js
===================================================================
--- trunk/expressoMail1_2/js/search.js	(revision 5580)
+++ trunk/expressoMail1_2/js/search.js	(revision 5584)
@@ -468,4 +468,8 @@
 		tr.name = mailbox;
 		
+		// set attribute role id_folder
+		tr.setAttribute('role', uid_msg+'_'+mailbox); 
+		tr.role = uid_msg+'_'+mailbox;
+		
 		if ( aux.flag.match("U") )
 			add_className(tr,'tr_msg_unread');
@@ -555,6 +559,10 @@
 							followupflag: DataLayer.get('followupflag', '1')
 						};
-						$('#td_message_followup_' + messageClickedId + ', ' + 
-						'#td_message_followup_search_' + messageClickedId+':first').find(".flag-edited").css("background", aux.followupflagged.backgroundColor);						
+						if(current_folder == mailbox){
+							$('#td_message_followup_' + messageClickedId + ', ' + 
+							'tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css("background", aux.followupflagged.backgroundColor);	
+						}else{
+							$('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css("background", aux.followupflagged.backgroundColor);		
+						}					
 						aux.followupflagged.id = DataLayer.put('followupflagged', aux.followupflagged);
 						
@@ -567,9 +575,15 @@
 
 						DataLayer.remove('followupflagged', flagged[0].id);
-						$('#td_message_followup_' + messageClickedId + ', ' + 
-						  '#td_message_followup_search_' + messageClickedId+':first').find(".flag-edited").css("background", '#CCC');
-						$('#td_message_followup_' + messageClickedId + ', ' + 
-							'#td_message_followup_search_' + messageClickedId+':first').find(".flag-edited")
-							.find("img").attr("src", "../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");
+						if(current_folder == mailbox){
+							$('#td_message_followup_' + messageClickedId + ', ' + 
+							  'tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css("background", '#CCC');
+							$('#td_message_followup_' + messageClickedId + ', ' + 
+								'tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited")
+								.find("img").attr("src", "../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");
+						}else{
+							$('tr[role="'+messageClickedId+'_'+mailbox+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css("background", '#CCC');
+							$('tr[role="'+messageClickedId+'_'+mailbox+'"] #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
Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 5576)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 5584)
@@ -219,6 +219,6 @@
 				}
 			}
-		/*
-		tree_folders.draw(Element('content_folders'));
+
+		/*tree_folders.draw(Element('content_folders'));
 		if (!expresso_offline) {
 			n_root.changeState();
@@ -228,6 +228,6 @@
 			root_local.changeState();
 			tree_folders.getNodeById('local_Inbox')._select();
-		}
-		*/
+		}*/
+		
 		var trash_span = document.getElementById(mount_url_folder(["lINBOX",special_folders["Trash"]])  + 'tree_folders'); 
 		var draft_span = document.getElementById(mount_url_folder(["lINBOX",special_folders["Drafts"]]) + 'tree_folders'); 
@@ -346,5 +346,5 @@
 	myLabels.html("<div class='my-labels'>" +
 				"<img src='../prototype/modules/mail/img/tag.png'/>" +
-				"<a class='title-my-labels' tabindex='0' role='button' aria-expanded='false' title='"+get_lang("My Labels")+"'>"+get_lang("My Label")+"</a>" +
+				"<a class='title-my-labels' tabindex='0' role='button' aria-expanded='false' title='"+get_lang("My Labels")+"'>"+get_lang("My Labels")+"</a>" +
 				
 				"<span class='status-list-labels ui-icon ui-icon-triangle-1-s'></span>" +
@@ -1691,5 +1691,5 @@
 				};
 				$('#td_message_followup_' + messageClickedId + ', ' + 
-				'#td_message_followup_search_' + messageClickedId+':first').find(".flag-edited").css("background", headers_msgs.followupflagged.backgroundColor);
+				'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css("background", headers_msgs.followupflagged.backgroundColor);
 				//$(this).find(".flag-edited").css("background", headers_msgs.followupflagged.backgroundColor);
 				headers_msgs.followupflagged.id = DataLayer.put('followupflagged', headers_msgs.followupflagged);
@@ -1703,7 +1703,7 @@
 				DataLayer.remove('followupflagged', flagged[0].id);
 				$('#td_message_followup_' + messageClickedId + ', ' + 
-				  '#td_message_followup_search_' + messageClickedId + ':first').find(".flag-edited").css("background", '#CCC');
+				  'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css("background", '#CCC');
 				$('#td_message_followup_' + messageClickedId + ', ' + 
-					'#td_message_followup_search_' + messageClickedId+':first').find(".flag-edited")
+					'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited")
 					.find("img").attr("src", "../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");
 			} else {
Index: trunk/expressoMail1_2/js/doiMenuData.js
===================================================================
--- trunk/expressoMail1_2/js/doiMenuData.js	(revision 5575)
+++ trunk/expressoMail1_2/js/doiMenuData.js	(revision 5584)
@@ -53,14 +53,25 @@
 					}
 				}else{
-					var id = get_selected_messages_search().split(',');
-					var id_border = currentTab.replace(/[a-zA-Z_]+/, "");
-					for (i = 0; i < id.length; i++){
-						var tr = Element(id[i]+'_s'+id_border);
-						msg_folder = tr.getAttribute('name'); 
+					// var id = get_selected_messages_search().split(',');
+					// var id_border = currentTab.replace(/[a-zA-Z_]+/, "");
+					// for (i = 0; i < id.length; i++){
+						// var tr = Element(id[i]+'_s'+id_border);
+						// msg_folder = tr.getAttribute('name'); 
+						// messages.push({
+							// "msg_number": id[i],
+							// "msg_folder": msg_folder,
+						// });
+					// }	
+					
+					var roles = get_selected_messages_search_role().split(',');
+					for (i = 0; i < roles.length; i++){
+						var tr = $('[role="'+roles[i]+'"]');
+						msg_folder = $(tr).attr('name'); 
+						var id = $(tr).attr('id'); 
 						messages.push({
-							"msg_number": id[i],
+							"msg_number": id.replace(/_[a-zA-Z0-9]+/,""),
 							"msg_folder": msg_folder,
 						});
-					}	
+					}
 				}
 
@@ -167,11 +178,17 @@
 		msg_number = messageInfo.uid;
 	}
-	$('#td_message_labels_' + msg_number +', #td_message_labels_search_' + msg_number+':first')
-	.html('<img src="../prototype/modules/mail/img/tag.png">');
-	
 	var msg_folder = current_folder;
 	if(messageInfo.boxname != '' && messageInfo.boxname != 'undefined' && messageInfo.boxname != null){
 		msg_folder = messageInfo.boxname;
 	}
+	
+	 if(current_folder == msg_folder || !current_folder){
+		 $('#td_message_labels_' + msg_number +', tr[role="'+msg_number+'_'+msg_folder+'"] #td_message_labels_search_' + msg_number)
+		 .html('<img src="../prototype/modules/mail/img/tag.png">');
+	}else{
+		$('tr[role="'+msg_number+'_'+msg_folder+'"] #td_message_labels_search_' + msg_number)
+		.html('<img src="../prototype/modules/mail/img/tag.png">');
+	}
+	
 	var menuItems = {};
 	if (messageInfo.labels) {
@@ -196,23 +213,39 @@
 	}
 
-	$.contextMenu( 'destroy', '#td_message_labels_' + msg_number +', #td_message_labels_search_' + msg_number+':first');
-
-	$.contextMenu({
-		selector: '#td_message_labels_' + msg_number +', #td_message_labels_search_' + msg_number + ':first',
-		trigger: 'hover',
-		delay:100,
-		autoHide:true,
-		callback: function(key, options) {
-			//TODO - default actions
-
-		},
-		items: menuItems
-	});
-}
-
-
-
-
-
-
-
+	 if(current_folder == msg_folder || !current_folder){
+		$.contextMenu( 'destroy', '#td_message_labels_' + msg_number +', tr[role="'+msg_number+'_'+msg_folder+'"] #td_message_labels_search_' + msg_number);
+
+		$.contextMenu({
+			selector: '#td_message_labels_' + msg_number +', tr[role="'+msg_number+'_'+msg_folder+'"] #td_message_labels_search_' + msg_number,
+			trigger: 'hover',
+			delay:100,
+			autoHide:true,
+			callback: function(key, options) {
+				//TODO - default actions
+
+			},
+			items: menuItems
+		});
+	}else{
+		$.contextMenu( 'destroy', 'tr[role="'+msg_number+'_'+msg_folder+'"] #td_message_labels_search_' + msg_number);
+
+		$.contextMenu({
+			selector: 'tr[role="'+msg_number+'_'+msg_folder+'"] #td_message_labels_search_' + msg_number,
+			trigger: 'hover',
+			delay:100,
+			autoHide:true,
+			callback: function(key, options) {
+				//TODO - default actions
+
+			},
+			items: menuItems
+		});	
+	}
+}
+
+
+
+
+
+
+
