Index: /trunk/expressoMail1_2/js/abas.js
===================================================================
--- /trunk/expressoMail1_2/js/abas.js	(revision 7879)
+++ /trunk/expressoMail1_2/js/abas.js	(revision 7889)
@@ -283,4 +283,29 @@
 				$('.upper, .lower').show();
         		$(".lower").css("top", ($("#content_folders").height()-18) + $("#content_folders").offset().top);
+				/* Habilitar anexar mensagem por drag-and-drop, se a aba atual for editável,  
+				ou seja, nem de leitura (2), nem de lista de mensagens (0):*/ 
+				var current_tab_type = openTab.type[currentTab]; 
+				if (current_tab_type != 0 && current_tab_type != 2){ 
+					var dropzone = $("#fileupload_msg" + currentTab + "_droopzone"); 
+					dropzone.show(); 
+					dropzone.prev().hide(); 
+					dropzone.droppable({ 
+						over: function (event, ui){ 
+							dropzone.addClass('hover in'); 
+							$(ui.helper).find(".draggin-folder,.draggin-mail").css("color", "green"); 
+						}, 
+						out: function (event, ui) { 
+							dropzone.removeClass('hover in'); 
+							$(ui.helper).find(".draggin-folder,.draggin-mail").css("color", ""); 
+						}, 
+						drop: function (event, ui) { 
+							var border_id = ui.draggable.find("input[type=hidden]").attr("name"); 
+							var id_msg = border_id.split("_")[0]; 
+							var folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder()); 
+							attach_message(folder, id_msg); /* Anexa a mensagem especificada (por folder e id_msg) 
+															   na mensagem sendo criada.*/ 
+						} 
+					}); 
+				} 
 				if($(".shared-folders").length){
 					$(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({
@@ -331,4 +356,12 @@
 				$('.upper, .lower').hide();
 				$(".shared-folders").parent().find(".folder").droppable("destroy");
+				/* Habilitar anexar mensagem por drag-and-drop, se a aba atual for editável,  
+				ou seja, nem de leitura (2), nem de lista de mensagens (0):*/ 
+				var current_tab_type = openTab.type[currentTab]; 
+				if (current_tab_type != 0 && current_tab_type != 2){ 
+					var dropzone = $("#fileupload_msg" + currentTab + "_droopzone"); 
+					dropzone.hide(); 
+					dropzone.prev().show(); 
+				} 
 			},
 			helper: function(event){
Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 7872)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 7889)
@@ -4747,4 +4747,99 @@
 			emQuickSearch(($(this).parents("tr:first").find("textarea").val() ? $(this).parents("tr:first").find("textarea").val() : input_search), "."+$(this).parents("tr:first").attr('class').split("-")[0], ID, undefined, true);
 	});
+}
+
+/* 
+	Anexa uma mensagem a mensagem sendo enviada. 
+	Parâmetros: 
+		folder_name: nome da pasta na qual a mensagem sendo anexada se encontra. 
+		message_number: id da mensagem sendo anexada. 
+*/ 
+function attach_message (folder_name, message_number) { 
+	var ID = currentTab; 
+	var fileUploadMSG = $('#fileupload_msg'+ID); 
+	fileUploadMSG.find(' .attachments-list').show(); 
+	var att = new Object(); 
+	att.folder = folder_name; 
+	att.uid = message_number; 
+	att.type = 'imapMSG'; 
+	/* Substituída a variável onceOpenedMessages por onceOpenedHeadersMessages, 
+	   porque essa última contem as mesmas informações da primeira, e está em escopo global.*/ 
+	att.name = Base64.encode(onceOpenedHeadersMessages[folder_name][message_number].subject + '.eml'); 
+	var idATT = JSON.stringify(att); 
+	addAttachment(ID, idATT); 
+	var attach = {}; 
+	attach.fileName = onceOpenedHeadersMessages[folder_name][message_number].subject + '.eml'; 
+	attach.fullFileName = onceOpenedHeadersMessages[folder_name][message_number].subject + '.eml'; 
+	if(attach.fileName.length > 20)  
+	{ 
+		attach.fileName = attach.fileName.substr(0, 17) + "... " + attach.fileName.substr(attach.fileName.length - 9, attach.fileName.length); 
+	} 
+ 
+	attach.error = false; 
+	attach.OK = true; 
+	attach.fileSize = formatBytes(onceOpenedHeadersMessages[folder_name][message_number].Size); 
+	var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", { 
+		file: attach 
+	})); 
+	$("#content_id_" + currentTab + " .save").button("enable"); 
+	upload.find('.att-box-loading').remove(); 
+	upload.append('<input type="hidden" name="fileId[]" value=\'' + idATT + '\'/>'); 
+ 
+	upload.find('.att-box-delete').click(function() 
+	{ 
+		$("#content_id_" + currentTab + " .save").button("enable"); 
+		var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 
+		fileUploadMSG.find(' .attachments-list').find('input[value="' + idAttach + '"]').remove(); 
+		delAttachment(ID, idAttach); 
+		$(this).parent().qtip("destroy"); 
+		$(this).parent().remove(); 
+		if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length) 
+		{ 
+			fileUploadMSG.find(' .attachments-list').hide(); 
+		} 
+	}); 
+ 
+	fileUploadMSG.find('.attachments-list').append(upload); 
+ 
+	upload.find('.att-box-loading').remove(); 
+ 
+	fileUploadMSG.find('.attachments-list .att-box:last').qtip( 
+	{ 
+		content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", { 
+			attach: attach 
+		}), 
+		position: { 
+			corner: { 
+				tooltip: 'bottomMiddle', 
+				target: 'topMiddle' 
+			}, 
+			adjust: { 
+				resize: true, 
+				scroll: true 
+			} 
+		}, 
+		show: { 
+			when: 'mouseover', 
+			// Don't specify a show event 
+			ready: false // Show the tooltip when ready 
+		}, 
+		hide: 'mouseout', 
+		// Don't specify a hide event 
+		style: { 
+			border: { 
+				width: 1, 
+				radius: 5 
+			}, 
+			width: { 
+				min: 75, 
+				max: 1000 
+			}, 
+			padding: 5, 
+			textAlign: 'center', 
+			tip: true, 
+			// Give it a speech bubble tip with automatic corner detection 
+			name: 'blue' // Style it according to the preset 'cream' style 
+		} 
+	}); 
 }
 		
@@ -5143,74 +5238,7 @@
 				jQuery.each(selectedMessages[folder_name], function(message_number, message) { 
 					if (message) {
-						fileUploadMSG.find(' .attachments-list').show();	
-						var att = new Object();
-						att.folder = folder_name;
-						att.uid = message_number;
-						att.type = 'imapMSG';
-						att.name = Base64.encode(onceOpenedMessages[folder_name][message_number].subject + '.eml');
-						var idATT = JSON.stringify(att);
-						addAttachment( ID , idATT);                        
-						var attach = {};
-						attach.fileName = onceOpenedMessages[folder_name][message_number].subject + '.eml';
-						attach.fullFileName = onceOpenedMessages[folder_name][message_number].subject + '.eml';
-						if(attach.fileName.length > 20)
-							attach.fileName = attach.fileName.substr(0, 17) + "... " + attach.fileName.substr(attach.fileName.length-9, attach.fileName.length);
-
-						attach.error = false;
-                        attach.OK = true;
-						attach.fileSize = formatBytes(onceOpenedMessages[folder_name][message_number].size);
-						var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach}));
-						$("#content_id_"+currentTab+" .save").button("enable");
-                        upload.find('.att-box-loading').remove();
-						upload.append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>');
-						
-						upload.find('.att-box-delete').click(function(){
-                            $("#content_id_"+currentTab+" .save").button("enable");
-                            var elAttach = $(this).parent().find('input[name="fileId[]"]');
-						    delAttachment(ID,$(elAttach).val());
-                            $(elAttach).remove();
-							$(this).parent().qtip("destroy");
-							$(this).parent().remove();
-							if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){
-								fileUploadMSG.find(' .attachments-list').hide();
-							}
-						});	
-							
-						fileUploadMSG.find('.attachments-list').append(upload);
-
-						upload.find('.att-box-loading').remove();
-
-						fileUploadMSG.find('.attachments-list .att-box:last').qtip({
-		                	content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", {attach : attach}),
-							position: {
-								corner: {
-									tooltip: 'bottomMiddle',
-									target: 'topMiddle'
-								},
-								adjust: {
-					               resize: true,
-					               scroll: true
-					            }
-							},
-							show: {
-								when: 'mouseover', // Don't specify a show event
-								ready: false // Show the tooltip when ready
-							},
-							hide: 'mouseout', // Don't specify a hide event
-							style: {
-								border: {
-									width: 1,
-									radius: 5
-								},
-								width: {
-									 min: 75,
-									 max : 1000
-								},
-								padding: 5, 
-								textAlign: 'center',
-								tip: true, // Give it a speech bubble tip with automatic corner detection
-								name: 'blue' // Style it according to the preset 'cream' style
-							}
-		                });
+						/* Anexa a mensagem especificada (por folder e id_msg) 
+						   na mensagem sendo criada.*/ 
+						attach_message(folder_name, message_number);
 					}
 				});
