Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 6047)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 6071)
@@ -3671,16 +3671,40 @@
 	content.find(".attachment td").filter(".value").prepend(DataLayer.render("../prototype/modules/mail/templates/attachment.ejs", {ID:ID}));
 	var fileUploadMSG = $('#fileupload_msg'+ID);
-	var maxAttachmentSise = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false;
+	var maxAttachmentSize = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false;
 
 	fileUploadMSG.find(".button-files-upload").fileupload({
-		sequentialUploads: true,
+		type: 'post',
+		dataType : 'json',
+		url: "../prototype/post.php",
+		forceIframeTransport: true,
+		formData: function(form) {
+			return [
+				{
+					name : "mailAttachment[0][source]",
+					value : "files0"
+				},
+				{
+					name : "mailAttachment[0][disposition]",
+					value : $(form[0]['attDisposition'+$(form[0]['abaID']).val()]).val()
+				},
+				{
+					name: "MAX_FILE_SIZE",
+					value : maxAttachmentSize
+				}
+			];
+		},
 		add: function (e, data) {
 			
-			if(!maxAttachmentSise || data.files[0].size < maxAttachmentSise || is_ie) {
+			if(!maxAttachmentSize || data.files[0].size < maxAttachmentSize || is_ie) {
 				setTimeout(function() {
-                                        $('#attDisposition'+ID).val('attachment');
-					delete data.fileInput; 
+                    $('#attDisposition'+ID).val('attachment');
+					if(!data.fileInput){
+						$(fileUploadMSG).find("input")[0].files = data.files;
+						data['fileInput'] = $(fileUploadMSG).find("input");
+					}
+					if(!data.form)
+						data['form'] = fileUploadMSG.parents("form:first");
 					data.submit();
-				}, 5000);
+				}, 3000);
 			}		
 			var attach = {};
@@ -3690,6 +3714,7 @@
 				attach.fileName = data.files[0].name.substr(0, 32) + " ... " + data.files[0].name.substr(data.files[0].name.length-9, data.files[0].name.length);
 			attach.fileSize = formatBytes(data.files[0].size);
-			if(maxAttachmentSise && data.files[0].size > maxAttachmentSise)
-				attach.error = 'Tamanho de arquivo nao permitido!!'
+			data.files[0].size = 300;
+			if(maxAttachmentSize && data.files[0].size > maxAttachmentSize)
+				attach.error = 'Tamanho de arquivo nao permitido!!!'
 
 			var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach}));				
@@ -3708,5 +3733,5 @@
 			fileUploadMSG.find('.attachments-list').append(upload);
 
-			if(!maxAttachmentSise || data.files[0].size < maxAttachmentSise)
+			if(!maxAttachmentSize || data.files[0].size < maxAttachmentSize)
 			    fileUploadMSG.find('.attachments-list').find('[type=file]').addClass('hidden');	
 			else
@@ -3715,24 +3740,21 @@
 		done: function(e, data){
 			if(!!data.result && data.result != "[]" ){
-				var newAttach = jQuery.parseJSON(data.result);
-				
-				//Compatibilidade com Firefox3.6 	
-				if(newAttach === null ) newAttach = jQuery.parseJSON(data.result.text());
-				
-				var newAttach = jQuery.parseJSON(data.result);                               
-                                if(newAttach.rollback !== false)
-                                {
-                                    fileUploadMSG.find('.in-progress:first').parents('p').append('<input type="hidden" name="fileId[]" value="'+newAttach['mailAttachment'][0][0].id+'"/>').find('.status-upload').addClass('ui-icon ui-icon-check');
-                                    addAttachment(ID,newAttach['mailAttachment'][0][0].id);
-                                }
-                                else                             
-                                  fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error');   
+				var newAttach = data.result;                             
+				if(!newAttach.mailAttachment.error){
+					if(newAttach.rollback !== false)
+					{
+						fileUploadMSG.find('.in-progress:first').parents('p').append('<input type="hidden" name="fileId[]" value="'+newAttach['mailAttachment'][0][0].id+'"/>').find('.status-upload').addClass('ui-icon ui-icon-check');
+						addAttachment(ID,newAttach['mailAttachment'][0][0].id);
+					}
+					else                             
+						fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error');   
+				}else{
+					fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append(newAttach.mailAttachment.error).addClass('message-attach-error');   
+				}
                                 
 			}else {
 				fileUploadMSG.find(' .progress.on-complete:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error');
 			}
-                        fileUploadMSG.find(' .in-progress:first').remove();
-				
-                    
+            fileUploadMSG.find(' .in-progress:first').remove();
 		}
 	}).find('[name="files[]"]').css({"height" : "20px", "width": "100px", "border-width": "0 0 0px 0px", "-moz-transform" : "none","-o-transform" : 'none'});
