Index: branches/2.4/expressoMail1_2/js/common_functions.js
===================================================================
--- branches/2.4/expressoMail1_2/js/common_functions.js	(revision 7156)
+++ branches/2.4/expressoMail1_2/js/common_functions.js	(revision 7228)
@@ -249,6 +249,6 @@
 	div_attachment = document.getElementById("id_div_attachment");
 	var params = '';
-	if(msg_folder) 
- 	        msg_folder = utf8_decoder(Base64.decode(msg_folder)); 
+	if(msg_folder)
+		msg_folder = utf8_decoder(Base64.decode(msg_folder));
 	if (div_attachment == null){
 		var div_attachment = document.createElement("DIV");
@@ -629,14 +629,4 @@
 }
 
-function folderbox()
-{
-	connector.loadScript("TreeS");
-
-	if( typeof(window.ttree) == 'undefined')
-		setTimeout(function(){ folderbox(); }, 200 );
-	else
-		ttree.load();
-}
-
 function filterbox(){
 	connector.loadScript("filter");
@@ -686,12 +676,12 @@
 		closeOnEscape:true,
 		close:function(event, ui) {
-			select_all_search_messages(false, 'content_id_'+currentTab);
+			//select_all_search_messages(false, 'content_id_'+currentTab);
 			event.stopPropagation();
-		if(typeof(shortcut) != 'undefined') shortcut.disabled = false; 
+            if(typeof(shortcut) != 'undefined') shortcut.disabled = false;
 		},
-		open: function(event, ui)  
- 	    { 
- 	        if(typeof(shortcut) != 'undefined') shortcut.disabled = true;  
- 	    }, 
+        open: function(event, ui) 
+        {
+            if(typeof(shortcut) != 'undefined') shortcut.disabled = true; 
+        },
 		autoOpen:false,
 		dialogClass: 'dialog-configure-label'
@@ -744,12 +734,12 @@
 		closeOnEscape:true,
 		close:function(event, ui) {
-			select_all_search_messages(false, 'content_id_'+currentTab);
+			//select_all_search_messages(false, 'content_id_'+currentTab);
 			event.stopPropagation();
-	if(typeof(shortcut) != 'undefined') shortcut.disabled = false; 
+            if(typeof(shortcut) != 'undefined') shortcut.disabled = false; 
 		},
-	open: function(event, ui)  
- 	{ 
- 	    if(typeof(shortcut) != 'undefined') shortcut.disabled = true;  
- 	}, 
+        open: function(event, ui) 
+        {
+            if(typeof(shortcut) != 'undefined') shortcut.disabled = true; 
+        },
 		autoOpen:false
 	});	
@@ -836,5 +826,5 @@
 	var num_msg = id_msg.substr(0,(id_msg.length - 2));
 	var handler_source = function(data){
-		download_attachments(null, null, data, null,null,'fonte_da_mensagem.eml');
+		download_attachments(null, null, data[0], null,null,data[1]+'.eml');
 	}
 	cExecute("$this.exporteml.export_msg",handler_source,"folder="+url_decode(folder)+"&msgs_to_export="+num_msg);
@@ -1131,5 +1121,9 @@
 	var main_list = main.childNodes;
 	var len_main_list = main_list.length;
-
+	var folder = $('#content_folders .folder.selected').attr('title');
+	folder = folder ? folder : get_lang('INBOX');
+	folder = folder.length > 70 ? '"'+folder.substr(0,70) + "..." +'"': '"'+folder+'"' ;
+	var filterFlag = search_box_type != "ALL" ? '"'+get_lang(search_box_type) + "s" +'"': "";
+	var div = $('.select-all-messages');	
 	if (select)
 	{
@@ -1140,10 +1134,34 @@
 			if(!$("#"+main_list[i].id).hasClass("selected_shortcut_msg")){
 				//add_className(Element(main_list[i].id), 'selected_msg selected_shortcut_msg current_selected');
-				add_className(Element(main_list[i].id), 'selected_msg selected_shortcut_msg');
+				add_className(Element(main_list[i].id), 'selected_msg');
 			} else {
 				$("#"+main_list[i].id).addClass("selected_msg");
-				$("#"+main_list[i].id).addClass("selected_shortcut_msg");
-				$("#"+main_list[i].id).addClass("current_selected");		
-			}
+				//$("#"+main_list[i].id).addClass("selected_shortcut_msg");
+				//$("#"+main_list[i].id).addClass("current_selected");		
+			}			
+			selectedPagingMsgs[main_list[i].id] = true;
+		}		
+		if (totalSelected() == totalFolderMsgs && totalSelected() > 0){
+			allMsgsSelected = true;
+				if (total_pages > 1){
+					var link = "<a class='select-link' href='#'>Limpar seleção?</a>";
+					var info = "Todas as <b>"+totalFolderMsgs+"</b> mensagens "+filterFlag+" em "+folder+" foram selecionadas. "+link;
+					div.html("<span>"+info+"<span>");
+					div.show();
+					$('.select-link').bind('click',function(){
+						selectAllFolderMsgs();
+						//$('.select-link').unbind('click');
+					});
+				}			
+		}
+		else if (!allMsgsSelected && total_pages > 1){
+			var link = "<a class='select-link' href='#'>Selecionar todas as <b>"+totalFolderMsgs+"</b> mensagens "+filterFlag+" em "+folder+"?</a>";
+			var info = "Todas as <b>"+$('#table_box tr').length+"</b> mensagens desta página foram selecionadas. "+link;
+			div.html("<span>"+info+"<span>");
+			div.show();
+			$('.select-link').bind('click',function(){
+				selectAllFolderMsgs(true);
+				//$('.select-link').unbind('click');
+			});					
 		}
 	}
@@ -1156,7 +1174,24 @@
 			$("#"+main_list[i].id).removeClass("selected_msg");
 			$("#"+main_list[i].id).removeClass("current_selected");
-		}
-	}
-	
+			selectedPagingMsgs[main_list[i].id] = false;
+		}
+		if (allMsgsSelected){
+			allMsgsSelected = false;
+			updateSelectedMsgs();
+		}
+		else if (totalSelected() > 0 && total_pages > 1){
+			var link = "<a class='select-link' href='#'>Limpar seleção?</a>";
+			var info = "Foram selecionadas <b>"+totalSelected()+"</b> mensagens "+filterFlag+" em "+folder+". "+link;
+			div.html("<span>"+info+"<span>");
+			div.show();
+			$('.select-link').bind('click',function(){
+				selectAllFolderMsgs(false);
+				//$('.select-link').unbind('click');
+			});			
+		}
+		else div.hide();
+		
+	}
+	resizeWindow();
 }
 
@@ -1252,2 +1287,6 @@
     return folderName;
 }
+
+function useDesktopNotification(){
+    return !!parseInt(preferences.notifications);
+}
