Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 7501)
+++ trunk/expressoMail1_2/js/main.js	(revision 7514)
@@ -3776,16 +3776,91 @@
 }
 
-function print_all(){
-    if(typeof (currentTab) == "string" && currentTab.indexOf("local") != -1){  
-        alert("Impossível manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais.");
-        return true;
-    }
-	if (openTab.type[currentTab] == 2)
-		return print_msg(current_folder,currentTab.substr(0,currentTab.indexOf("_r")),currentTab);
-
-	if (currentTab != 0 && currentTab.indexOf("search_")  >= 0){
-		return print_search_msg();
-	}
-		
+/*PERMITE A IMPRESSÃO DE UMA LISTA DE MENSAGENS E SEU CONTEÚDO*/
+function print_messages_bodies(){
+	var messages = {};
+	messages[get_current_folder()] = get_selected_messages().split(',');
+
+	var print_bodies = function (data){
+		data = data[get_current_folder()];
+		var print_width = screen.width - 200;
+		var x = ((screen.width - print_width) / 2);
+		var y = ((screen.height - 400) / 2) - 35;
+		var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y);
+		if(window_print == null) {
+			alert(get_lang("The Anti Pop-Up is enabled. Allow this site (%1) for print.",document.location.hostname));
+			return;
+		}
+		var header = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>'
+		+ '<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>';
+		window_print.document.write(header);
+		var printData ='<body style="overflow:auto">' + cabecalho + '</h4><hr>';
+		window_print.document.write(printData);
+		var newRow = function(label,data){
+			return "<tr><td width=7%><font size='2'><b>"+label+" </b></font></td><td><font size='2'>"+data+"</font></td></tr>";
+		}
+		/*INSERE AS MENSAGENS NO DOCUMENTO DE IMPRESSÃO*/
+		$.each(data,function(index,message){
+			var html = "<table><tbody>";
+			if(message.sender)
+				for(var i=0; i<message.sender.length; i++){	
+					html += newRow(get_lang('Sent by')+":",message.sender[i]);
+				}
+			if(message.from)
+				for(var i=0; i<message.from.length; i++){	
+					html += newRow(get_lang('From')+":",message.from[i]);
+				}
+			if(message.toaddress2) {
+				html += newRow(get_lang('To')+":",message.toaddress2);
+			}
+			if (message.cc) {
+				html += newRow(get_lang('Cc')+":",message.cc);
+			}
+			if (message.bcc) {
+				html += newRow(get_lang('Cco')+":",message.bcc);
+			}
+			if(message.smalldate)
+				html += newRow(get_lang('Date')+":",message.smalldate);
+				
+			html += newRow(get_lang('Subject')+":",message.subject);		
+			/*LISTA DE ANEXOS*/
+			if (message.attachments && message.attachments.length) {
+	 	        var img = '<img style="margin-bottom : -5px; cursor : pointer;" src="templates/'+template+'/images/new.png">';
+	 	        var atts = "";
+	 	        $.each(message.attachments,function(index,attach){
+	 	        	atts += " | " + attach.name + "("+ formatBytes(attach.fsize) +") " + img + " | ";
+	 	        });
+	 	        html += newRow(get_lang('Attachments: '),atts);       
+	 	    }
+			html += '</tbody></table>';
+			if (message.body){
+				html += "<hr>" + message.body;
+	 	    }
+	 	    html += "<hr>";
+			window_print.document.write(html);
+		});
+		window_print.document.close();
+		window_print.print();
+	}
+	$.ajax({			
+			url: "controller.php?" + $.param( {action: "$this.imap_functions.getMessages",
+				details: "all",
+                messages : messages,
+				}),
+			success: function(data){
+				data = connector.unserialize(data);
+				if(data){
+                  print_bodies(data);
+				}
+			},
+			beforeSend: function( jqXHR, settings ){
+				connector.showProgressBar();
+			},
+			complete: function( jqXHR, settings ){
+				connector.hideProgressBar();
+			}
+		});	
+}
+
+function print_messages_list(){
 	var folder= Element('border_id_0').innerHTML;
 	//var thead = Element('divScrollHead_'+numBox).firstChild.firstChild.innerHTML; 
@@ -3793,5 +3868,5 @@
 	msgs_number = get_selected_messages();
 	if(msgs_number == false){
-	var tbody = Element('divScrollMain_'+numBox).firstChild.firstChild.innerHTML;
+		var tbody = Element('divScrollMain_'+numBox).firstChild.firstChild.innerHTML;
 	}else{
 		msgs_number = msgs_number.split(",");
@@ -3837,4 +3912,33 @@
 }
 
+function print_all(){
+    if(typeof (currentTab) == "string" && currentTab.indexOf("local") != -1){  
+        alert("Impossível manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais.");
+        return true;
+    }
+	if (openTab.type[currentTab] == 2)
+		return print_msg(current_folder,currentTab.substr(0,currentTab.indexOf("_r")),currentTab);
+
+	if (currentTab != 0 && currentTab.indexOf("search_")  >= 0){
+		return print_search_msg();
+	}
+	if (get_selected_messages() == false){
+		return print_messages_list();
+	}
+    var msg = 'Algumas mensagens foram selecionadas para impressão. Deseja imprimir o conteúdo de cada uma delas? Caso contrário, apenas uma lista das mensagens selecionadas será impressa.';
+    $.Zebra_Dialog(msg, {
+	    'type':     'question',
+	    'buttons': ['Sim','Não'],
+	    'overlay_opacity': '0.5',
+	    'onClose':  function(caption) {
+	        if(caption == 'Sim'){
+	        	return print_messages_bodies();
+	        }
+	        else{
+	        	return print_messages_list();	
+	        }
+	    }
+	});
+}
 
 function print_msg(msg_folder, msg_number, border_ID){
