Index: /sandbox/novoExpressoMail/expressoMail1_2/templates/default/index.tpl
===================================================================
--- /sandbox/novoExpressoMail/expressoMail1_2/templates/default/index.tpl	(revision 6487)
+++ /sandbox/novoExpressoMail/expressoMail1_2/templates/default/index.tpl	(revision 6711)
@@ -98,20 +98,21 @@
 	</td>			
 	<td width="100%" valign="top" align="left">
-		<div id="exmail_main_body" class="messagescol">
-			<table id="border_table" width="auto" height="26" cellspacing="0" cellpadding="0" border="0">
-				<tbody id="border_tbody">
-					<tr id="border_tr">
-						<td nowrap class="menu" onClick="alternate_border(0);resizeWindow();"  id="border_id_0">
-							&nbsp;{lang_inbox}&nbsp;<font face="Verdana" size="1" color="#505050">[
-							<span id="new_m">0</span> / 
-							<span id="tot_m">0</span>]
-							</font>
-						</td>
-						<td nowrap id="border_blank" class="last_menu" width="100%">&nbsp;</td>								
+		<div id="ptabs">
+			<ul>
+				<li>
+					<a href="#ptabs_0">&nbsp;{lang_inbox}&nbsp;<font face="Verdana" size="1" color="#505050">
+						[<span id="new_m">0</span> / <span id="tot_m">0</span>]</font>
+					</a>
+				</li>
+			</ul>
+			<div id="ptabs_0">
+				<table class="fuu" id="message_attacher_grid">
+					<tr>
+							<td/>
 					</tr>
-				</tbody>
-			</table>
-			<div id="content_id_0" class="conteudo"></div>
-			<div id="footer_menu">
+				</table>
+				<div id="message_attacher_grid_pager"></div>
+			</div>
+			<div id="footer_menu">					
 				<table style="border-top:0px solid black" id="footer_box" cellpadding=0 cellspacing=0 border=0 width="100%" height="10px">
 					<tbody>
Index: /sandbox/novoExpressoMail/expressoMail1_2/templates/default/main.css
===================================================================
--- /sandbox/novoExpressoMail/expressoMail1_2/templates/default/main.css	(revision 6680)
+++ /sandbox/novoExpressoMail/expressoMail1_2/templates/default/main.css	(revision 6711)
@@ -1390,2 +1390,15 @@
 	border-color : red;
 }
+
+.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a{
+	font-size: 10px;	
+}
+
+.ui-tabs .ui-tabs-nav li a:hover, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a:hover{
+	text-decoration: none !important;
+}
+
+.ui-tabs .ui-tabs-panel{
+	width: 99.7%;
+	margin-top: 2px !important;
+}
Index: /sandbox/novoExpressoMail/expressoMail1_2/js/abas.js
===================================================================
--- /sandbox/novoExpressoMail/expressoMail1_2/js/abas.js	(revision 6684)
+++ /sandbox/novoExpressoMail/expressoMail1_2/js/abas.js	(revision 6711)
@@ -1,4 +1,3 @@
 var BordersArray = new Array();
-BordersArray[0] = new setBorderAttributes(0);
 var countBorders = 0; 
 var partMsgs = new Array(); 
@@ -7,651 +6,4 @@
 var zebraDiscardEventDialog = false;
 var saveBorderError = new Array(); 
+var ID = 1;
 
-function setBorderAttributes(ID)
-{
-	this.border_id = "border_id_"+ID;
-	this.sequence = ID; 
-}
-
-
-function alternate_border(ID)
-{
-	msg_selected = false;//Controle da seleÃ§Ã£o de mensagens
-	if(isNaN(ID))
-		if(preferences.use_shortcuts == "1")
-			select_msg((ID.split("_"))[0]);
-	if( document.getElementById("div_menu_c3") != null )
-	{
-		var node = document.getElementById("div_menu_c3").firstChild;
-		
-		while ( node )
-		{
-			node.style.display = "none";
-			node = node.nextSibling;
-		}
-		
-		if( document.getElementById("span_paging"+ID) != null )
-			document.getElementById("span_paging"+ID).style.display = "block";
-	}
-	
-	if ( typeof win == 'object' && win.close && win.close.constructor == Function ){
-            var search_win = document.getElementById( 'window_QuickCatalogSearch' );
-            if(search_win){
-                search_win.style.visibility = 'hidden';
-            }
-            win.close( );
-        }
-		
-	if (! Element('border_id_'+ID))
-		return false; // Not possible to alternate
-	show_hide_span_paging(ID);
-	spanD = Element("span_D");
-	if (spanD)
-		spanD.style.display = (openTab.type[ID] == 0 ? '' : 'none');
-
-	var footer_menu = Element("footer_menu");	
-	var aba = Element('border_id_'+ID);
-	if (footer_menu != null) {
-		footer_menu.style.display = (openTab.type[ID] != 4 ? '' : 'none');
-		var alternate_menu = document.getElementById('localOption');
-		
-		if(alternate_menu != null && alternate_menu != 'undefined'){ //Quando Carregado o expresso mail
-			if(openTab.imapBox[ID]!= null && openTab.imapBox[ID]!= 'undefined' ){ //Quando abrir uma Nova Mensagem
-				if((openTab.imapBox[ID].indexOf("local_") >= 0)){						
-						alternate_menu.title = get_lang("Unarchive");
-						alternate_menu.removeAttribute("onclick");
-						if(!is_ie)
-							alternate_menu.setAttribute("onclick",  'expresso_local_messages.unarchive_msgs(\''+openTab.imapBox[ID]+'\', null)');
-						else{
-							alternate_menu.onclick = function(){
-								expresso_local_messages.unarchive_msgs(openTab.imapBox[ID], null);
-							}
-						}
-						alternate_menu.innerHTML = get_lang("Unarchive");
-						
-					}else{
-						alternate_menu.title = get_lang("Archive");
-						alternate_menu.removeAttribute("onclick");
-						if(!is_ie)
-							alternate_menu.setAttribute("onclick", 'archive_msgs(\''+openTab.imapBox[ID]+'\', null)');		
-						else{
-							alternate_menu.onclick = function(){
-								archive_msgs(openTab.imapBox[ID], null);
-							}	
-						}
-						alternate_menu.innerHTML = get_lang("Archive");
-					}
-					
-			}
-		}
-		
-		if((aba.id.indexOf("_r") < 0) && (aba.id.indexOf("_0") < 0) && (aba.id.indexOf("id_search_") < 0) && (aba.id.indexOf("_s") < 0)){
-			spanD.style.display = 'none';
-			footer_menu.style.display = 'none';			
-		}
-	}
-
-
-	var len = BordersArray.length;
-	for (var i=0; i < len; i++)
-	{
-		m = document.getElementById(BordersArray[i].border_id);
-		if ((m)&&(m.className == 'menu-sel'))
-		{
-			m.className = 'menu';
-			c = document.getElementById("content_id_"+BordersArray[i].sequence);
-			c.style.display = 'none';
-			if(Element("font_border_id_"+BordersArray[i].sequence))
-				Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu';	
-
-		}
-	}
-
-	m = Element("border_id_"+ID);
-	if (m)
-		m.className = 'menu-sel';
-	if(Element("font_border_id_" + ID))
-		Element("font_border_id_" + ID).className = 'font-menu-sel';
-	var c = Element("content_id_"+ID)
-	if (c)
-		c.style.display = '';
-
-
-	// hide the DropDrowContact, if necessary
-	window_DropDownContacts = Element('tipDiv');
-	if ((window_DropDownContacts)&&(window_DropDownContacts.style.visibility != 'hidden')){
-		window_DropDownContacts.style.visibility = 'hidden';
-	}
-
-	numBox = getNumBoxFromTabId(ID);
-	if (typeof(ID)=='number') {
-                 numBox = ID;
-         }
-         else {
-             if (ID.match("search_"))
-             {
-                 if (ID.match("search_local_msg"))
-                 {
-                         var p = ID.search(/[0-9]/);
-                         numBox =  ID.substr(p);
-                 }
-                 else
-                 {
-                         numBox = ID.substr(7);
-                 }
-             }
-         }
-	currentTab=ID;
-	if( document.getElementById('to_'+ID) && document.getElementById('to_'+ID).type == "textarea"){ 
- 	    document.getElementById('to_'+ID).focus(); 
-	}
-	RichTextEditor.setEditable(ID);
-	resizeWindow();
-	return ID;
-}
-
-function create_border(borderTitle, id_value, search)
-{
-			
-	borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' );
-    borderTitle = html_entities(borderTitle);    
-	var resize = false;
-        resize = resize_borders();
-        if (!resize){
-            var str_continue = '';
-            var bolContinue = true;
-			str_continue = '\n' + get_lang('You must manually close one of your tabs before opening a new one');
-            if (preferences.auto_close_first_tab == 1){
-                var children = Element('border_tr').childNodes;
-                var bolDelete = true;
-                for (var i=0; i<children.length; i++) {
-                    if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank'))
-                    {
-                        bolDelete = true;
-                        var num_child = children[i].id.toString().substr(10);
-                        alternate_border(num_child);
-                        if (editTest(num_child)){
-                            bolDelete = false;
-                        }
-                        if (bolDelete || bolContinue){
-							str_fechar = '\n' + get_lang('Reached maximum tab limit. Want to close this tab');
-							var confirmacao = confirm(str_fechar);
-                            if(confirmacao){
-                            bolContinue = false;
-                            delete_border(num_child, 'false');
-                            break;
-							}else{
-								return 'maximo';
-                        }
-                    }
-                }
-            }
-            }else{			
-                alert(get_lang('Reached maximum tab limit') + str_continue );
-                return 'maximo';
-            }
-        }
-	
-	if (! id_value){ // Is new message?
-		var ID = parseInt(BordersArray[(BordersArray.length-1)].sequence) + 1;
-			if(isNaN(ID)){
-				var aux = BordersArray[(BordersArray.length-1)].sequence.split("_");
-				ID = parseInt(aux[1]) + 1;
-			}
-        }else
-	{
-		if (Element("border_id_"+id_value)) // It's opened already!
-			return alternate_border(id_value);
-		
-		var ID = id_value;
-		if(isNaN(ID) && ID.indexOf("search_local") >= 0){
-			if(current_folder.indexOf("local") >= 0)
-				openTab.imapBox[ID] = current_folder;
-			else
-				openTab.imapBox[ID] = 'local_search';
-		}else if(isNaN(ID) && ID.indexOf("search_") >= 0){
-			if(current_folder.indexOf("local") < 0)
-				openTab.imapBox[ID] = current_folder;
-			else
-				openTab.imapBox[ID] = 'search';
-		}else if( (currentTab != 0) && isNaN(currentTab) && (currentTab.indexOf("search") >= 0) && (ID.indexOf("msg") < 0) ) {
-			var id_border = currentTab.replace(/[a-zA-Z_]+/, "");
-			ID_TR = ID.toString().substr(0,ID.toString().indexOf("_r"));
-			var tr = Element(ID_TR);
-			openTab.imapBox[ID] = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name'));
-		}else
-			openTab.imapBox[ID] = current_folder;
-	}
-	td = document.createElement("TD");
-	td.id="border_id_" + ID;
-	if(resize) 
-	{
-		td.setAttribute("width", parseInt(resize)+"px");
-		td.style.width = parseInt(resize)+"px";
-	}
-	else
-		td.setAttribute("width", "200px");
-
-	td.setAttribute("align", "right");
-	td.onclick = function(){alternate_border(ID);resizeWindow()};
-	td.setAttribute("noWrap","true");
-    td.alt = ' ';
-    td.title = borderTitle;
-	borderTitle = borderTitle ?  borderTitle : id_value ? get_lang("No Subject") : " "	;
-	td.value = borderTitle;
-	if (borderTitle.length > 21)
-		borderTitle = borderTitle.substring(0,21) + "...";
-
-	if ( resize )
-		borderTitle = borderTitle.substring(0, resize*0.08);
-	
-	var cc = search;
-	if(!cc){
-		if(isNaN(ID)){
-			var is_local = ID.match('.*_local_.*');
-			if(!is_local)
-				cc = document.getElementById("em_message_search").value;
-			else{
-				cc = document.getElementsByName(currentTab)[0].value;
-			}
-		}else{
-			cc ="";
-		}
-	}
-	td.innerHTML = "<div><div id='font_border_id_" + ID+"' class='font-menu'>" +
-                                borderTitle +
-                            "</div>\n\
-                            <div style='float:right;'>\n\
-                                <img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'/>\n\ " +
-                            "</div>\n\ " + 
-							"<input type=\"hidden\" name=\""+ ID+"\" value=\""+cc+"\"></div>";		
-	bb = document.getElementById("border_blank");
-	parent_bb = bb.parentNode; //Pego o tbody
-	parent_bb.insertBefore(td, bb);
-
-	if((typeof(id_value) == 'string') && id_value.match(/_r/)){
-		$(td).draggable({
-			start : function(){
-				if($(".shared-folders").length){
-					$(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({
-						over : function(a, b){						
-							//SETA BORDA EM VOLTA DA PASTA
-							over = $(this);
-							$(this).addClass("folder-over");
-							if(($(this)[0] != $(this).parent().find(".head_folder")[0]))
-								if($(this).prev()[0])
-									if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){
-										setTimeout(function(){
-											if(over.hasClass("folder-over"))
-												over.prev().trigger("click");
-										}, 500);
-										
-									}
-						},
-						out : function(){
-							//RETIRA BORDA EM VOLTA DA PASTA
-							$(this).removeClass("folder-over");
-						},
-						//accept: ".draggin_mail",
-						drop : function(event, ui){
-							$(this).css("border", "");
-							if($(this).parent().attr('id') == undefined){
-								var folder_to = 'INBOX';
-								var to_folder_title = get_lang("Inbox");
-							}else{
-								var folder_to = $(this).parent().attr('id');
-								var to_folder_title = $(this).attr('title');
-							}		
-							var folder_to_move = ui.draggable.parent().attr('id');
-							var border_id = ui.draggable.find("input[type=hidden]").attr("name");
-							if(folder_to_move == "border_tr"){
-								var id_msg = border_id.split("_")[0];
-								folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder());
-								move_msgs2(folder, id_msg, border_id, folder_to, to_folder_title,true);
-								return refresh();
-							}
-						}
-					});
-				}
-			},
-			stop :function(){
-				$(".shared-folders").parent().find(".folder").droppable("destroy");
-			},
-			helper: function(event){
-				if(	borderTitle.length > 18 )
-					return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle.substring(0,18) + "...", type: "messages"})+"</td>");
-				else
-					return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle, type: "messages"})+"</td>");
-			},
-			delay: 150,
-			cursorAt: {top: 5, left: 56},
-			refreshPositions: true ,
-			containment: "#divAppbox"
-		});
-	}
-		//_dragArea.makeDragged(td, id_value,td.value);
-
-	BordersArray[BordersArray.length] = new setBorderAttributes(ID);
-
-	var div = document.createElement("DIV");
-	div.id = "content_id_" + ID;
-	div.className = "conteudo";
-	div.style.display='';
-
-	div.style.overflow = "hidden";
-
-	Element("exmail_main_body").insertBefore(div,Element("footer_menu"));       
-	if (!is_ie)
-		resizeWindow();
-	alternate_border(ID);
-    uidsSave[ID] = [];
-    saveBorderError[ID] = false;
-	return ID;
-}
-
-function resize_borders()
-{
-	var numBorders = count_borders();
-
-	if (numBorders > 8)
-		return false;
-
-	return redim_borders(numBorders+1);
-}
-
-function count_borders()
-{
-	var numBorders = 0;
-	var children = Element('border_tr').childNodes;
-	for (var i=0; i<children.length; i++) {
-	    if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank'))
-		numBorders++;
-	}
-
-	return numBorders;
-}
-
-function redim_borders(numBorders)
-{
-	var children = Element('border_tr').childNodes;
-	var clientWidth = (window.document.body.clientWidth - findPosX(Element("exmail_main_body"))) - Element("border_id_0").clientWidth - 30;
-	var newWidthTD = (clientWidth/numBorders)-6;
-	newWidthTD = newWidthTD > 200 ? 200 : (newWidthTD < 50 ? 50 : newWidthTD);
-	children = Element('border_tr').childNodes;
-	for (var i=0; i<children.length; i++) {
-		if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){
-			$(children[i]).css("width", newWidthTD);
-			$(children[i]).find('div:first').css("width", newWidthTD);
-			set_border_caption(children[i].id, children[i].title, newWidthTD);
-		}
-	}
-	return newWidthTD;
-}
-
-
-
-
-function set_border_caption(border_id, title, border_width)
-{
-        var border = document.getElementById(border_id);
-        if (border_width == null)
-        {
-            border_width = border.clientWidth;
-        }
-	var caption = "";
-    if (border != null){
-		Element("font_"+border.id).style.width = (border_width - 35)+'px';
-		Element("font_"+border.id).innerHTML = title;
-	}
-	return(title);
-}
-
-
-function draftTests(ID, msg_sent){
-    
-       
-        if( openTab.toPreserve[ID] = false)
-        {
-            close_delete(ID, msg_sent);
-            delete(openTab.type[ID]);
-        }    
-        else  
-        {
-             var msg = 'Existem alterações não salvas na mensagem.';
-             var buttons = ['Descartar alterações', 'Salvar e fechar' ,'Cancelar'];
-             var width = 371;
-             if($('#fileupload_msg'+ID).find('.in-progress').length)
-             {
-                 msg = 'Existem anexos sendo enviados para o servidor.';
-                 buttons = ['Descartar alterações e anexos', 'Salvar estado atual fechar', 'Continuar editando']; 
-                 width = 560;
-             }
-             zebraDiscardEventDialog = true;
-             window.setTimeout(function() {
-                $.Zebra_Dialog(msg, {
-                            'type':     'question',
-                            'overlay_opacity': '0.5',
-                            'buttons':  buttons,
-                            'width' : width,
-                            'onClose':  function(clicked) {
-									if(clicked == 'Cancelar'){
-										if (RichTextEditor.plain[id] != true) 
-											setTimeout("RichTextEditor.focus("+ID+")",100);                  
-										else  
-											$('#body_'+ID).focus(); 
-									}
-                                    if(clicked == 'Descartar alterações' || clicked == 'Descartar alterações e anexos' ) {
-                                        if (openTab.imapBox[ID] && !openTab.toPreserve[ID])
-                                            openTab.toPreserve[ID] = false;
-
-                                        delete(openTab.type[ID]);
-                                        close_delete(ID, msg_sent);
-                                    }
-                                    else if(clicked == 'Salvar e fechar' || clicked == 'Salvar estado atual fechar')
-                                    {
-                                        save_msg(ID);
-                                        openTab.toPreserve[ID] = false;
-                                        close_delete(ID, msg_sent);
-                                        delete(openTab.type[ID]);
-                                    }    
-                                    else{
-
-                                        Element("border_id_"+ID).onclick = function () {alternate_border(ID);}; 
-                                        var setFocus = function(ID){
-                                                        if ($.trim($("#to_"+ID).val()) == "")
-                                                                $("#to_"+ID).focus();
-                                                        else if ($("#tr_cc_"+ID).css('display') != 'none' && $.trim($("#cc_"+ID).val()) == "")
-                                                                $("#cc_"+ID).focus();
-                                                        else if ($("#tr_cco_"+ID).css('display') != 'none' && $.trim($("#cco_"+ID).val()) == "")
-                                                                $("#cco_"+ID).focus();		
-                                                        else if ($.trim($("#subject_"+ID).val()) == "")
-                                                                $("#subject_"+ID).focus();
-                                                        else{
-                                                                if (RichTextEditor.plain[id] != true) 
-                                                                        setTimeout("RichTextEditor.focus("+ID+")",100);                  
-                                                                else  
-                                                                        $('#body_'+ID).focus(); 
-                                                        }
-                                                }
-                                                setFocus(ID);  
-                                    }
-                                    window.setTimeout(function() {
-                                            zebraDiscardEventDialog = false;
-                                    }, 500);
-                            }})}, 300);    
-        }
-	
-}
-
-function editTest(ID){
-    var body = document.getElementById('body_'+ ID);
-	var content = $('#content_id_'+ ID);
-    if (body)
-    {
-        var save_link = content.find(".save");
-        if (openTab.toPreserve[ID] == undefined)
-                openTab.toPreserve[ID] = false;
-        if (((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on')) && (save_link.onclick != ''))
-        {
-            return true;
-        }
-    }
-    return false;
-}
-
-function delete_border(ID, msg_sent)
-{
-	
-	if($("#border_id_"+ID).attr("title") == get_lang("New Message")){
-		var to = $("#content_id_"+ID).find(".to").parent(".email-area").find("div").length || $("#content_id_"+ID).find(".email-area").find(".to").val();
-		var cc = $("#content_id_"+ID).find(".cc").parent(".email-area").find("div").length || $("#content_id_"+ID).find(".email-area").find(".cc").val();
-		var cco = $("#content_id_"+ID).find(".cco").parent(".email-area").find("div").length || $("#content_id_"+ID).find(".email-area").find(".cco").val();
-		var subject = $("#content_id_"+ID).find(".subject").val();
-		var auxAttachments = false;
-		var attachments = $("#content_id_"+ID).find("ul.attachments-list").find("li").each(function(){
-			($(this).find("p").length > 0) ? auxAttachments = true : auxAttachments;
-			if(auxAttachments)
-				return false;
-		});
-		var textArea = RichTextEditor.getData("body_"+ID);
-		
-		if(!to && !cc && !cco && !auxAttachments && subject == "" && textArea == "")
-			close_delete(ID, msg_sent);
-	}
-        var bolExecuteClose = true;
-	var borderElem = Element("border_id_" + ID);
-	if (borderElem){
-            borderElem.onclick = null; // It's avoid a FF3 bug
-        }else{
-            return false;
-        }
-	if (msg_sent == 'false')
-	{
-            if (editTest(ID)){
-                bolExecuteClose = false;
-                if(zebraDiscardEventDialog === false)
-                    return(draftTests(ID, msg_sent));
-            }
-	}
-        if (bolExecuteClose)
-        {
-            close_delete(ID, msg_sent);
-		}
-		delete(openTab.type[ID]);
-        return true;
-}
-
-function close_delete(ID, msg_sent)
-{
-	openTab.toPreserve[ID] = false;
-        // Limpa o autosave
-            if (preferences.auto_save_draft == 1 && autoSaveControl.timer[ID] !== null )
-            {
-                autoSaveControl.status[ID] = null;
-                clearInterval(autoSaveControl.timer[ID]);
-            }
-        ////////////////////////////////
-        
-	hold_session = false;
-	if (exist_className(Element('border_id_'+ID),'menu-sel'))
-	{
-		if (BordersArray[BordersArray.length-2].sequence == ID)
-			this.alternate_border(0);
-		else
-			this.alternate_border(BordersArray[BordersArray.length-2].sequence);
-	}
-
-	// Remove TD, title
-	border = Element('border_id_' + ID);
-	border.parentNode.removeChild(border);
-	var j=0;
-	var new_BordersArray = new Array();
-	for (i=0;i<BordersArray.length;i++)
-		if (document.getElementById(BordersArray[i].border_id) != null){
-			new_BordersArray[j] = BordersArray[i];
-			j++;
-		}
-	if(j == 1)
-		Element("footer_menu").style.display = '';
-	BordersArray = new_BordersArray;
-
-	// Remove Div Content
-	content = Element('content_id_' + ID);
-	content.parentNode.removeChild(content);
-	if(is_webkit)
-		resizeWindow();
-	RichTextEditor.destroy( 'body_'+ID );
-        delete msgAttachments[ID];
-        //Caso for uma mensagem anexada tem que deletar ela da lixeira apos fechar a aba
-            var isPartMsg = false;
-			if(!parseInt(id2))
-				return;
-            var id2 = ID.replace('_r','');
-            for(var ii = 0; ii < partMsgs.length; ii++)
-               if(partMsgs[ii] == id2){           
-                  isPartMsg = true;
-                  partMsgs[ii] = null;
-               }     
-
-            if(isPartMsg === true){
-                var handler_delete_msg = function(){};
-                cExecute ("$this.imap_functions.delete_msgs&folder=INBOX"+cyrus_delimiter+trashfolder+"&msgs_number="+id2,handler_delete_msg);
-            }
-        ///////////////////////////////////////////////////////////////////////////////////
-        
-	return true;
-}
-
-function getTabPrefix() { // define o prefixo para os checkboxes das mensagens
-	if (typeof(currentTab)!='number')
-		return currentTab+"_";
-	else
-		return "";
-}
-
-function getMessageIdFromRowId(row_id) { // extrai o id da mensagem do id da linha
-	var p = row_id.search("_s");
-	if (p>0)
-		return row_id.substr(0,p);
-	else
-		return row_id;
-}
-
-function getNumBoxFromTabId(tab_id) { // extrai o numBox do id da tab
-	if (typeof(tab_id)=='number') {
-		return tab_id;
-	}
-	else {
-		var p = tab_id.search(/[0-9]/);
-		return tab_id.substr(p);
-	}
-}
-
-function addAttachment(ID, att)
-{
-    if(typeof(msgAttachments[ID]) == 'undefined')
-            msgAttachments[ID] = [];
-
-        msgAttachments[ID].push(att);
-}
-
-function delAttachment(ID, att)
-{
-    
-    if(msgAttachments[ID] == undefined) return;
-    var len = msgAttachments[ID].length;
-    for(var i = 0; i < len; i++)
-    {
-        if(msgAttachments[ID][i] == att)
-        {
-            delete msgAttachments[ID][i];
-            break;
-        }
-    }  
-}
-
-function listAttachment(ID)
-{
-   return (typeof(msgAttachments[ID]) == 'undefined') ? '' : JSON.stringify(msgAttachments[ID]); 
-}
-
Index: /sandbox/novoExpressoMail/expressoMail1_2/js/main.js
===================================================================
--- /sandbox/novoExpressoMail/expressoMail1_2/js/main.js	(revision 6673)
+++ /sandbox/novoExpressoMail/expressoMail1_2/js/main.js	(revision 6711)
@@ -2,5 +2,5 @@
 var time_refresh = 300000;
 // tempo do auto save (em milisegundos)
-// 20000 = 20 segundos
+// 20000 = 20 segundosfun
 var autosave_time = 40000;
 var results_search_messages = ""; 
@@ -8,8 +8,9 @@
 // Variavel para controle de atualização das mensagens listadas na modal de alerta de filtro por remetente
 var checkAlarmsFilter = false;
-
+var ptabs;
 var dynamicPersonalContacts = new Array();
 var dynamicContacts = new Array();
 var topContact = 0;
+var tab_content = "";
 DataLayer.get("folder", true);
 
@@ -116,4 +117,14 @@
 			cExecute ("$this.imap_functions.automatic_trash_cleanness&before_date="+preferences.delete_trash_messages_after_n_days+"&cyrus_delimiter="+cyrus_delimiter, handler_automatic_trash_cleanness);
 		
+		ptabs = $("#ptabs").tabs({
+			tabTemplate: "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
+			add: function( event, ui ) {
+				//var tab_content = $tab_content_input.val() || "Tab " + tab_counter + " content.";
+				ID++;
+				ptabs.tabs('select', '#' + ui.panel.id);
+				$( ui.panel ).html(tab_content);
+			}
+		});
+		
 		//if(preferences.outoffice == "1")
 		//	
@@ -129,7 +140,4 @@
 			loadApplet();
 		}
-		// Fim da inserção da applet	
-		DataLayer.get("folder", true);
-		cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu);	
 		
 		if($.cookie('collapse_folders') == "true"){
@@ -139,11 +147,11 @@
 				$("#folderscol").hide();
 			$(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-e").children().attr('title', "Expandir");
-			refresh();
-			resizeWindow();
+			//refresh();
+			//resizeWindow();
 		}	
 		else{
 			$(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-w").children().attr('title', "Ocultar");
-			refresh();
-			resizeWindow();
+			//refresh();
+			//resizeWindow();
 		}
 		
@@ -159,6 +167,6 @@
 				$(".collapse_folders").parent().attr('title', "Expandir");
 				$.cookie('collapse_folders', "true");
-				refresh();
-				resizeWindow();
+				//refresh();
+				//resizeWindow();
 			}else{
 				if(!is_ie)
@@ -170,8 +178,8 @@
 				$(".collapse_folders").parent().attr('title', "Ocultar");
 				$.cookie('collapse_folders', "false");
-				refresh();
-				resizeWindow();
-			}
-			resizeWindow();
+				//refresh();
+				//resizeWindow();
+			}
+			//resizeWindow();
 			
 		}).hover(
@@ -2080,5 +2088,5 @@
 	txtarea.css("height",height);
 	$("#border_id_" + new_border_ID).attr("title", title);
-	set_border_caption("border_id_" + new_border_ID, title);
+	//set_border_caption("border_id_" + new_border_ID, title);
 	resizeWindow();
 	return new_border_ID; //Preciso retornar o ID da nova mensagem.
@@ -2092,4 +2100,9 @@
 	});
 }
+
+$( "#ptabs span.ui-icon-close" ).live( "click", function() {
+	var index = $( "li", ptabs ).index( $( this ).parent() );
+	ptabs.tabs( "remove", index );
+});
 
 //Remove o email do usuario ao responder a todos
@@ -2319,22 +2332,22 @@
 }
 
-function send_message_return(data, ID){
+function send_message_return(data, aID){
 	
 	if (typeof(data) == 'object' && data.load){
 		cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu);
 	}
-	watch_changes_in_msg(ID);
-
-	var content = $("#content_id_"+ID);
+	watch_changes_in_msg(aID);
+
+	var content = $("#content_id_"+aID);
 	var sign = false;
 	var crypt = false;
 	var reComplexEmail = /<([^<]*)>[\s]*$/;
 	if ((preferences.use_assinar_criptografar != '0') && (preferences.use_signature_digital_cripto != '0')){
-		var checkSign = document.getElementById('return_digital_'+ID)
+		var checkSign = document.getElementById('return_digital_'+aID)
 		if (checkSign.checked){
 			sign = true;
 		}
 
-		var checkCript = document.getElementById('return_cripto_'+ID);
+		var checkCript = document.getElementById('return_cripto_'+aID);
 		if (checkCript.checked){
 			crypt = true;
@@ -2407,6 +2420,9 @@
 		var dynamicContactList = new Array();
 
+		
+		delete_border(ID,'true');
 		*/
-		delete_border(ID,'true');
+		var index = $( "li", ptabs ).index( $("#ptabs_"+aID) );
+		ptabs.tabs("remove", index);
 		var arrayTo = content.find(".to-tr").find(".box").clone();
 		save_dynamic_contacts(arrayTo);
@@ -2589,6 +2605,6 @@
 	if (preferences.auto_save_draft == 1)
 	   autoSaveControl.status[ID] = true;
-	var content = $("#content_id_"+ID);
-	var save_link = $("#content_id_"+ID).find(".save");
+	var content = $("#ptabs_"+ID);
+	var save_link = $("#ptabs_"+ID).find(".save");
 	var onClick = save_link.onclick;
 	save_link.onclick = '';
@@ -2619,20 +2635,20 @@
 	input_type.name = "type"; 
 	input_type.value = RichTextEditor.plain[ID] ? 'plain' : 'html'; 
-	
+	/*
         var uids = document.createElement("INPUT");
 	uids.style.display='none';
 	uids.name = "uids_save";
 	uids.value = uidsSave[ID].toString();
-        
+    */    
         var save_folder = document.createElement("INPUT");
 	save_folder.style.display='none';
 	save_folder.name = "save_folder";
 	save_folder.value = (openTab.imapBox[ID] && openTab.type[ID] < 6) ? openTab.imapBox[ID]: "INBOX" + cyrus_delimiter + draftsfolder;
-        
+    /*    
         var msg_attachments = document.createElement("INPUT");
 	msg_attachments.style.display='none';
 	msg_attachments.name = "attachments";
 	msg_attachments.value = listAttachment(ID);
-
+	*/
 	if (is_ie){
 		var i = 0;
@@ -2667,7 +2683,8 @@
 	form.appendChild(msgId);
     form.appendChild(save_folder);
+    /*
     form.appendChild(uids);
 	form.appendChild(msg_attachments);
-
+	*/
         var mail_type = document.createElement('input');
 	mail_type.setAttribute('type', 'hidden');
Index: /sandbox/novoExpressoMail/expressoMail1_2/js/draw_api.js
===================================================================
--- /sandbox/novoExpressoMail/expressoMail1_2/js/draw_api.js	(revision 6698)
+++ /sandbox/novoExpressoMail/expressoMail1_2/js/draw_api.js	(revision 6711)
@@ -1073,5 +1073,5 @@
 	numBox = 0; //As pastas sempre estarão na aba 0
 	
-	openTab.content_id[numBox] = document.getElementById("content_id_"+numBox);
+	openTab.content_id[numBox] = document.getElementById("ptabs_"+numBox);
 	openTab.content_id[numBox].innerHTML = "";
 	openTab.imapBox[numBox] = msg_folder;
@@ -1361,6 +1361,5 @@
 	var tdFolders  =  Element("folderscol");
 	tdFolders.style.display = preferences.hide_folders == '1'  ? "none" : "";
-	if ( !currentTab )
-		alternate_border(numBox);
+
 	draw_footer_box(headers_msgs.num_msgs);
 	Element('main_table').style.display = '';
@@ -1368,5 +1367,5 @@
 		setTimeout("resizeWindow()",1);
 	else
-		resizeWindow();
+		//resizeWindow();
 	if(debug) {
 		var _eTime = new Date();
@@ -1403,4 +1402,72 @@
 		Element('msg_number').value = '';
 	}
+	$("#ptabs_0")//.empty().html("<table style='height: 618px;'></table>")
+		.find("table:first").remove();	
+		$("#ptabs_0")//.empty().html("<table style='height: 618px;'></table>")
+		.html(DataLayer.render(BASE_PATH + 'api/templates/messagegrid.ejs', {}))
+		.find("#message_attacher_grid")
+		.jqGrid({
+			url:BASE_PATH + 'REST.php?q=folder/INBOX/message',
+			datatype: "json",
+			mtype: 'GET',
+			colNames:['#',' ', 'De', 'Assunto', 'Data', 'Tamanho'],
+			colModel:[
+				{name:'msg_number',index:'msg_number', width:"10%", hidden:true, sortable:false},
+				{name:'flags',index:'msg_number',edittype: 'image', width:"10%", sortable:false, formatter:pflags2Class, title :false},
+				{name:'from.name',index:'msg_number', width:"25%", sortable:false, formatter:pNormaliseFrom},
+				{name:'subject',index:'subject', width:"60%", sortable:false,formatter:pNormaliseSubject},
+				{name:'timestamp',index:'timestamp', width:"10%", align:"center", sortable:false, formatter:pdate2Time},
+				{name:'size',index:'size', width:"10%", align:"center", sortable:false, formatter:pbytes2Size}
+			],
+			jsonReader : {
+				  root:"rows",
+				  page: "page",
+				  total: "total",
+				  records: "records",
+				  repeatitems: false,
+				  id: "0"
+			},
+			rowNum:50,
+			rowList:[10,25,50],
+			pager: '#message_attacher_grid_pager',
+			//sortname: 'id',
+			//viewrecords: true,
+			//sortorder: "desc",
+			multiselect: true,
+			autowidth: true,
+			height : '600px',
+			//shrinkToFit: false,
+			//width: 1300,
+			//toppager : true,
+			loadComplete: function(data) {
+				var lastLoadedMessages = data.rows;
+				
+				// aplica o contador
+				jQuery('.timable').each(function (i) {
+					jQuery(this).countdown({
+						since: new Date(parseInt(this.title)), 
+						significant: 1,
+						layout: 'h&aacute; {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}', 
+						description: ' atr&aacute;s'
+					});					
+				});
+				/*
+				// reconstrói a seleção das mensagens mesmo depois da mudança de pasta
+				if (selectedMessages[selectedFolder.id]) {
+					for (var message in selectedMessages[selectedFolder.id]){
+						for (var j=0; j<data.rows.length; j++){	
+							if (selectedMessages[selectedFolder.id][message] && message == data.rows[j].msg_number) {
+								jQuery("#message_attacher_grid").setSelection(jQuery("#message_attacher_grid").getDataIDs()[j], false);
+							}
+						}
+					}
+				}*/
+				$('#cb_message_attacher_grid').css('display', 'none');
+				
+			}
+		});
+	//$("#ptabs").find(".ui-tabs-nav li:first").addClass("ui-state-disabled");
+	//$("#ptabs").find(".ui-tabs-nav").sortable({ axis: "x",cancel: ".ui-state-disabled" });		
+	$("#selected_messages_counter").remove();
 	var scripts = new Array("InfoContact",
 							"TreeShow");
@@ -1417,9 +1484,134 @@
 		ruler_element.className = "table_message_ruler";
 		ruler_element.style.top = getColumnPosition(document.getElementById("content_id_0"),"BODY")[1];
-		document.getElementById("exmail_main_body").appendChild(ruler_element);
-    }
-				
-}
-
+		//document.getElementById("exmail_main_body").appendChild(ruler_element);
+    }	
+    resizeWindow();
+}
+punorphanize = function(root, element) {
+	var ok = false;
+	for (var i=0; i<root.length; i++) {
+		if (root[i].id == element.parentFolder) {
+			element.children = new Array(); 
+			root[i].children.push(element);
+			return true;
+		} else if (ok = unorphanize(root[i].children, element)) {
+			break;
+		}
+	}
+
+	return ok;
+}
+
+/* --- helpers --- */
+pbytes2Size = function(bytes) {
+	var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
+	if (bytes == 0) return 'n/a';
+	var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
+	var size = (i<2) ? Math.round((bytes / Math.pow(1024, i))) : Math.round((bytes / Math.pow(1024, i)) * 100)/100;
+	return  size + ' ' + sizes[i];
+}
+
+pflags2Class = function(cellvalue, options, rowObject) {
+	var classes = '';	
+	cellvalue = cellvalue.split(',');
+	cell = {
+			Unseen: parseInt(cellvalue[0])  ? 'Unseen' : 'Seen', 
+			Answered: parseInt(cellvalue[1]) ? 'Answered' : (parseInt(cellvalue[2]) ? 'Forwarded' : ''), 
+			Flagged: parseInt(cellvalue[3]) ? 'Flagged' : '',
+			Recent: parseInt(cellvalue[4])  ? 'Recent' : '', 			
+			Draft: parseInt(cellvalue[5]) ? 'Draft' : ''		
+		};
+	for(var flag in cell){
+		classes += '<span class="flags '+ (cell[flag]).toLowerCase() + '"' + (cell[flag] != "" ? 'title="'+ get_lang(cell[flag])+'"' : '')+'> </span>';	
+	}
+	if(rowObject.labels){	
+		var titles = [];
+		var count = 0;
+		 for(i in rowObject.labels){
+			titles[count] = " "+rowObject.labels[i].name;
+			count++;
+		}
+		titles = titles.join();
+		classes += '<span class="flags labeled" title="'+titles+'"> </span>';
+	}else{
+		classes += '<span class="flags"> </span>';
+	}
+	
+	if(rowObject.followupflagged){		
+		if(rowObject.followupflagged.followupflag.id < 7){
+			var nameFollowupflag = get_lang(rowObject.followupflagged.followupflag.name);
+		}else{
+			var nameFollowupflag = rowObject.followupflagged.followupflag.name;
+		}
+		if(rowObject.followupflagged.isDone == 1){
+			classes += '<span class="flags followupflagged" title="'+nameFollowupflag+'" style="background:'+rowObject.followupflagged.backgroundColor+';"><img style=" margin-left:-3px;" src="../prototype/modules/mail/img/flagChecked.png"></span>';
+		}else{			
+			classes += '<span class="flags followupflagged" title="'+nameFollowupflag+'" style="background:'+rowObject.followupflagged.backgroundColor+';"><img src="../prototype/modules/mail/img/flagEditor.png"></span>';
+		}
+		
+	}
+
+	return classes;
+}
+
+function numberMonths (months){
+	switch(months){
+		case 'Jan':
+			return 1;
+		case 'Feb':
+			return 2;
+		case 'Mar':
+			return 3;
+		case 'Apr':
+			return 4;
+		case 'May':
+			return 5;
+		case 'June':
+			return 6;
+		case 'July':
+			return 7;
+		case 'Aug':
+			return 8;
+		case 'Sept':
+			return 9;
+		case 'Oct':
+			return 10;
+		case 'Nov':
+			return 11;
+		case 'Dec':
+			return 12;
+	}	
+}
+
+pNormaliseFrom = function(cellvalue, options, rowObject) {
+	rowObject['flags'] = rowObject['flags'].split(",");
+	if(rowObject['flags'][rowObject['flags'].length-1] ==  1){
+		return get_lang(special_folders["Drafts"]);
+	}
+	return cellvalue;	
+}
+
+pNormaliseSubject = function(cellvalue, options, rowObject) {
+	return html_entities(cellvalue);
+}
+
+pdate2Time = function (timestamp) {
+	date = new Date();
+	dat = new Date(timestamp);
+	if ((date.getTime() - timestamp) < (24*60*60*1000)) {
+		return '<span class="timable" title="'+dat.getTime()+'"></span>';
+	} else {
+		date = new Date(timestamp);
+		if(is_ie){
+			var b = date.toString().split(' ');
+			var c = b[2] + "/" + numberMonths(b[1]) + "/" + b[5];
+			return '<span class="datable">' + c + '</span>';
+		}else{
+			var b = date.toISOString().split("T")[0].split("-");
+			var c = b[2] + "/" + b[1] + "/" + b[0];
+			return '<span class="datable">' + c + '</span>';
+		}
+	}
+}
 function showEmptyBoxMsg(tbody_element) {
 	document.getElementById("table_message_header_box_"+numBox).emptyBody = true;
@@ -4187,9 +4379,15 @@
 		});	
 	}
-	var ID = create_border("",border_ID);
-	
-	if (ID == 0)
+	//var ID = create_border("",border_ID);
+	tab_content = DataLayer.render("../prototype/modules/mail/templates/new_message.ejs", {id: ID+1});
+
+	ptabs.tabs("add", "#ptabs_"+(ID+1), "Nova Mensagem");
+
+
+		//ID = 5;
+	var thisID = ID;
+	if (thisID == 0)
 		return 0;
-	else if(ID == 'maximo')
+	else if(thisID == 'maximo')
 		return 'maximo';
 		
@@ -4199,6 +4397,6 @@
 		$("#footer_menu").css('display','none');
 	}
-	var content = $("#content_id_"+ID).html(DataLayer.render("../prototype/modules/mail/templates/new_message.ejs", {id: ID}));    
-	RichTextEditor.loadEditor2(ID);
+	var content = $("#ptabs_"+thisID).html(DataLayer.render("../prototype/modules/mail/templates/new_message.ejs", {id: thisID}));    
+	RichTextEditor.loadEditor2(thisID);
 	
 	//if(!expresso_offline)
@@ -4228,32 +4426,15 @@
 		if(!field.find("textarea").hasClass("track")){
 			field.find("textarea").css({"max-height" : "115px", "overflow-y" : "auto"}).addClass("track");	
-			input_binds(field.find(".email-area"), ID);
+			input_binds(field.find(".email-area"), thisID);
 		}
 	} 
 	
-	input_binds(content.find('[name="input_aux_to"]').css("max-width" , parseInt(content.find(".email-area").css("width"))-5).focus().parent().css({"max-height" : "115px", "overflow-y" : "auto"}), ID);	
+	input_binds(content.find('[name="input_aux_to"]').css("max-width" , parseInt(content.find(".email-area").css("width"))-5).focus().parent().css({"max-height" : "115px", "overflow-y" : "auto"}), thisID);	
 	
 	//Botão TextoRico/TextoSimples
 	content.find(".new-msg-head-right-buttons").find(".button").button().filter(".rich-button").click(function(){
-		/*Se o texto do botão for "Texto simples" exibirá a mensagem antes de alterar para texto simples*/
-		if($(".rich-button").find("span").text() == get_lang("Simple Text")){
-			$.Zebra_Dialog(get_lang("Convert this message into plain text can make parts of it are removed. Continue?"), {
-	            'type':     'warning',
-	            'overlay_opacity': '0.5',
-	            'buttons':  ['OK','Cancelar'],
-	            'width' : 380,
-	            'onClose':  function(clicked) {
-	                if(clicked == 'OK'){
-	            		RichTextEditor.setPlain(check_input(content.find('[name="textplain_rt_checkbox"]')), ID);
-		            	$(".rich-button").find("span").text(get_lang("Rich Text"));
-	                } 
-	            }
-			})
-		}
-		/*Se o texto do botão for "Texto rico" simplesmente altera para texto rico*/
-		else{
-			RichTextEditor.setPlain(check_input(content.find('[name="textplain_rt_checkbox"]')), ID);
-			$(".rich-button").find("span").text(get_lang("Simple Text"));
-		}
+		//RichTextEditor.loadEditor2(ID);
+		RichTextEditor.setPlain(check_input(content.find('[name="textplain_rt_checkbox"]')), thisID);
+		change_text($(this).find(".ui-button-text"), get_lang("Rich Text"), get_lang("Simple Text"));
 	})
 	
@@ -4275,5 +4456,5 @@
 		}
 	}).click(function(){
-		send_message(ID,preferences.save_in_folder,null);
+		send_message(thisID,preferences.save_in_folder,null);
 	})
 	//BOTAO SALVAR E ENVIAR
@@ -4283,5 +4464,5 @@
 		}
 	}).click(function(){
-		wfolders.makeWindow(ID,"send_and_file");
+		wfolders.makeWindow(thisID,"send_and_file");
 	})
 	//BOTAO SALVAR
@@ -4291,5 +4472,5 @@
 		}
 	}).click(function(){
-		save_msg(ID);
+		save_msg(thisID);
 	})
 	//BOTAO CONF. LEITURA
@@ -4330,6 +4511,6 @@
 	});
 	
-	content.find(".attachment td").filter(".value").prepend(DataLayer.render("../prototype/modules/mail/templates/attachment.ejs", {ID:ID}));
-	var fileUploadMSG = $('#fileupload_msg'+ID);
+	content.find(".attachment td").filter(".value").prepend(DataLayer.render("../prototype/modules/mail/templates/attachment.ejs", {ID:thisID}));
+	var fileUploadMSG = $('#fileupload_msg'+thisID);
 	var maxAttachmentSize = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false;
 	
@@ -4361,5 +4542,5 @@
 			if(!maxAttachmentSize || data.files[0].size < maxAttachmentSize || is_ie) {
 				setTimeout(function() {
-                    $('#attDisposition'+ID).val('attachment');
+                    $('#attDisposition'+thisID).val('attachment');
 					data.submit();
 				}, 3000);
@@ -4384,5 +4565,5 @@
 					var idAttach = $(this).parent().find('input[name="fileId[]"]').val();
 					fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]').remove();
-                                        delAttachment(ID, idAttach)
+                                        delAttachment(thisID, idAttach)
 					$(this).parent().remove();
 				});
@@ -4406,5 +4587,5 @@
 					{
 						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);
+						addAttachment(thisID,newAttach['mailAttachment'][0][0].id);
 					}
 					else                             
@@ -4452,5 +4633,5 @@
 							att.name = Base64.encode(onceOpenedMessages[folder_name][message_number].subject + '.eml');
 							var idATT = JSON.stringify(att);
-							addAttachment( ID , idATT);                        
+							addAttachment( thisID , idATT);                        
 							var attach = {};
 							attach.fileName = onceOpenedMessages[folder_name][message_number].subject + '.eml';
@@ -4472,5 +4653,5 @@
 										var idAttach = $(this).parents("li:first").find('input[name="fileId[]"]').val();
 										fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]');
-										delAttachment(ID,idAttach); 
+										delAttachment(thisID,idAttach); 
 										$(this).parent().remove();
 							});	
@@ -4489,5 +4670,5 @@
 		});
 	});
-	return ID;
+	return thisID;
 }
 
