Index: /trunk/prototype/modules/mail/js/followupflag.js
===================================================================
--- /trunk/prototype/modules/mail/js/followupflag.js	(revision 5584)
+++ /trunk/prototype/modules/mail/js/followupflag.js	(revision 5588)
@@ -148,13 +148,15 @@
 		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 id_border = currentTab.replace(/[a-zA-Z_]+/, "");
-				var tr = Element(selectedMessageIds[i]+'_s'+id_border);
-				folder_name = tr.getAttribute('name');
-			}
-			var messageNumber   = selectedMessageIds[i];
+				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);
 			
@@ -241,14 +243,15 @@
 		if (selectedMessageIds.length == 0) $(this).button("option", "disabled", true);
 		
-		for(i = 0; i < selectedMessageIds.length; i++){
-			var folder_name;
-			if (currentTab == 0) {
-				folder_name = current_folder;
-			}else{
-				var id_border = currentTab.replace(/[a-zA-Z_]+/, "");
-				var tr = Element(selectedMessageIds[i]+'_s'+id_border);
-				folder_name = tr.getAttribute('name');
-			}
-			var messageNumber = selectedMessageIds[i];
+			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){
Index: /trunk/expressoMail1_2/js/common_functions.js
===================================================================
--- /trunk/expressoMail1_2/js/common_functions.js	(revision 5582)
+++ /trunk/expressoMail1_2/js/common_functions.js	(revision 5588)
@@ -699,12 +699,16 @@
 	}
 	
-	
+	var roles = get_selected_messages_search_role().split(',');
 	for (var i=0; i<selectedMessageIds.length; i++) {
 		if (currentTab == 0) {
 			folder_name = current_folder;
+			var number = selectedMessageIds[i];
 		}else{
-			folder_name = $('#'+selectedMessageIds[i]+'_s'+id_border).attr('name');
-		}
-		messages.push(onceOpenedHeadersMessages[folder_name][selectedMessageIds[i]]);
+			var tr = $('[role="'+roles[i]+'"]');
+			folder_name = $(tr).attr('name'); 
+			var id = $(tr).attr('id'); 
+			var number = id.replace(/_[a-zA-Z0-9]+/,"");
+		}
+		messages.push(onceOpenedHeadersMessages[folder_name][number]);
 	}
 
Index: /trunk/expressoMail1_2/js/main.js
===================================================================
--- /trunk/expressoMail1_2/js/main.js	(revision 5584)
+++ /trunk/expressoMail1_2/js/main.js	(revision 5588)
@@ -1290,5 +1290,4 @@
 	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;
@@ -1298,5 +1297,4 @@
  	    });              
  	     
-	});
 	if (selected_messages != ""){
 		if(selected_messages.indexOf(',') == 0)
@@ -1312,13 +1310,11 @@
 	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 + ',' ;
-			};
- 	    });              
- 	     
-	});
+ 	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)
@@ -3349,22 +3345,18 @@
 
 function select_all_search_messages(select, aba){
-	   jQuery(function() {
-        if(select){
-			jQuery("#"+aba+" tr").each(function(i, o) {
-			
-				o.firstChild.firstChild.checked = true;
-				add_className(o, 'selected_msg');
-			});		
-		}else{
-			jQuery("#"+aba+" tr").each(function(i, o) {
-			
-				o.firstChild.firstChild.checked = false;
-				remove_className(o, 'selected_msg');
-			});
-	}
-	});
-
-	
-
+
+	if(select){
+		jQuery("#"+aba+" tr").each(function(i, o) {
+		
+			o.firstChild.firstChild.checked = true;
+			add_className(o, 'selected_msg');
+		});		
+	}else{
+		jQuery("#"+aba+" tr").each(function(i, o) {
+		
+			o.firstChild.firstChild.checked = false;
+			remove_className(o, 'selected_msg');
+		});
+	}
 }
 
Index: /trunk/expressoMail1_2/js/search.js
===================================================================
--- /trunk/expressoMail1_2/js/search.js	(revision 5587)
+++ /trunk/expressoMail1_2/js/search.js	(revision 5588)
@@ -493,5 +493,5 @@
 					chk_onclick = "changeBgColor(window.event,"+uid_msg+");";
 				else
-					chk_onclick = "changeBgColor(event,"+uid_msg+");";				//'search_' + numBox
+					chk_onclick = "changeBgColor(event,'"+uid_msg+"');";				//'search_' + numBox
 				var td1 = '<input type="checkbox" onclick="' + chk_onclick + '" id="' + border_id + '_check_box_message_'+uid_msg+'"></input>';
 
Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 5587)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 5588)
@@ -4421,4 +4421,10 @@
 		else
 			changeBgColorToON(all_messages, first_order, last_order);
+	}else if(event.target != document.getElementById(getTabPrefix()+'check_box_message_' + msg_number)){
+		if($(event.target).attr("checked") == "checked"){
+			$(event.target).parents("tr:first").addClass("selected_msg");
+		}else{
+			$(event.target).parents("tr:first").removeClass("selected_msg");
+		} 
 	}
 	else{
