Index: /sandbox/2.5.0-expresso1/expressoMail1_2/js/common_functions.js
===================================================================
--- /sandbox/2.5.0-expresso1/expressoMail1_2/js/common_functions.js	(revision 7349)
+++ /sandbox/2.5.0-expresso1/expressoMail1_2/js/common_functions.js	(revision 7376)
@@ -254,5 +254,6 @@
 	}
 	div_attachment.innerHTML="<iframe style='display:none;width:0;height:0' name='attachment' src='"+url+"'></iframe>";
-}
+	window.onbeforeunload = function(){return unloadMess();}
+} 
 
 function download_attachments(msg_folder, msg_number, idx_file, msg_part, encoding, new_file_name, show_iframe){
Index: /sandbox/2.5.0-expresso1/expressoMail1_2/js/main.js
===================================================================
--- /sandbox/2.5.0-expresso1/expressoMail1_2/js/main.js	(revision 7340)
+++ /sandbox/2.5.0-expresso1/expressoMail1_2/js/main.js	(revision 7376)
@@ -2412,5 +2412,5 @@
         {
                 var fileUploadMSG = $('#fileupload_msg'+new_border_ID);         
-                var attachments = document.getElementById("attachments_" + old_id_border).getElementsByTagName("a");	
+                var attachments = $("#attachments_" + old_id_border).find("a");	
                 var imagens = block_quoted_body.match(/<img[^>]*>/g);
 		var arrayAttachments = [];
@@ -2421,6 +2421,10 @@
                             if((attachments[i].tagName=="SPAN") || (attachments[i].tagName=="IMG") || ((attachments[i].href.indexOf("javascript:download_local_attachment")==-1)&&(attachments[i].href.indexOf("javascript:download_attachments")==-1)))
                                     continue;
-
-                                var arrayAtt = attachments[i].href.replace("javascript:download_attachments(", "").replace(")", "").split(',');                                 
+                                if(attachments[i].href.split("local") > 1){
+                                	var arrayAtt = attachments[i].href.replace("javascript:download_local_attachment(", "").replace(")", "").split(',');                                 
+                                }else{
+                                	var arrayAtt = attachments[i].href.replace("javascript:download_attachments(", "").replace(")", "").split(',');                                 
+                                }
+                                
                                 var att = new Object();
                                 var regex = new RegExp( "'", "g" );
@@ -2511,5 +2515,5 @@
 				    arrayAttachmentsA.push(attachments[i]);
 				}
-                    }
+        }
 		//-------------------
 		
@@ -2612,5 +2616,9 @@
                     continue;
                 fileUploadMSG.find(' .attachments-list').show();
-                var arrayAtt = attachments[i].href.replace("javascript:download_attachments(", "").replace(")", "").split(',');                                 
+                if(attachments[i].href.split("local").length > 1){
+                	var arrayAtt = attachments[i].href.replace("javascript:download_local_attachment(", "").replace(")", "").split(',');                                 	
+                }else{
+                	var arrayAtt = attachments[i].href.replace("javascript:download_attachments(", "").replace(")", "").split(',');                                 	
+                }
                 var att = new Object();
                 var regex = new RegExp( "'", "g" );
@@ -4048,8 +4056,17 @@
 
 	if(_button == 2 || _button == 3) {
-		var _params = _target.id.split(";;");
-		download_attachments(_params[0],_params[1],_params[2],_params[3],_params[4],file_type);
-	}
-}
+		if($(_target).parent().attr("href").split("http").length > 1){
+			var part_find = thumb.toString().split("#");
+			var part2_find = part_find[1].split("/temp");
+			var part_id_dwl = part2_find[0] + '/temp/download' + part2_find[1]; 
+			download_local_attachment(part_id_dwl);
+			return;
+		}else{
+			var _params = _target.id.split(";;");	
+			download_attachments(_params[0],_params[1],_params[2],_params[3],_params[4],file_type);
+		}
+	}
+}
+
 function save_image2(info){ 
 	var obj = jQuery.parseJSON(unescape(info)); 
Index: /sandbox/2.5.0-expresso1/expressoMail1_2/js/draw_api.js
===================================================================
--- /sandbox/2.5.0-expresso1/expressoMail1_2/js/draw_api.js	(revision 7347)
+++ /sandbox/2.5.0-expresso1/expressoMail1_2/js/draw_api.js	(revision 7376)
@@ -1879,5 +1879,5 @@
 
 		td_element2 = createTDElement(0,1,"td_msg");
-		if (headers_msgs.attachment == 1)
+		if (headers_msgs.attachment == 1 || headers_msgs.attachment.number_attachments> 0)
 			td_element2.innerHTML = "<img src ='templates/"+template+"/images/clip.gif' >";
 
