Index: /sandbox/newExpressoMail/prototype/modules/mail/js/foldertree.js
===================================================================
--- /sandbox/newExpressoMail/prototype/modules/mail/js/foldertree.js	(revision 6930)
+++ /sandbox/newExpressoMail/prototype/modules/mail/js/foldertree.js	(revision 7167)
@@ -509,2 +509,3 @@
 	$("#new_m").html($('.selected').find(".folder_unseen").html() ? $('.selected').find(".folder_unseen").html() : "0").css("color", "red");
 }
+
Index: /sandbox/newExpressoMail/prototype/modules/mail/templates/email.ejs
===================================================================
--- /sandbox/newExpressoMail/prototype/modules/mail/templates/email.ejs	(revision 7066)
+++ /sandbox/newExpressoMail/prototype/modules/mail/templates/email.ejs	(revision 7167)
@@ -1,13 +1,13 @@
 <div class="message">
-	<div class="message-options ui-widget-header ui-corner-all" style="width:100%; clear: both; display: inline-block; height: 30px;">
-		<div class="info" style="float: left; margin: 3px;">
-			<%= data.info.from.email %>
+	<div class="message-options ui-widget-header ui-corner-all" style="width:100%; clear: both; display: inline-block; height: 30px; border-top-left-radius: 0px; border-top-right-radius: 0px;">
+		<div class="info" style="float: left; margin: 3px; padding-top: 5px;">
+			<span><%= data.info.from.full %></span>,<%= data.info.fulldate %> 
 		</div>
-		<div style="float: right; margin: 3px; margin-rigth: 5px; width: auto; display: inline;">
+		<!--<div style="float: right; margin: 3px; width: auto; display: inline;">
 			<span class="messages-controll" style="display: inline; margin-right: 1px;">
 				<button class="button messages-preferences" title="Preferências">&nbsp;</button>
 			</span>
-		</div>
-		<div style="float: right; margin: 3px; margin-rigth: 5px; width: auto; display: inline;">
+		</div> -->
+		<div style="float: right; margin: 3px; width: auto; display: inline;">
 			<span class="messages-controll" style="display: inline; margin-right: 1px;">
 				<button class="button message-prev" title="Mensagem Anterior">&nbsp;</button>
@@ -15,36 +15,71 @@
 			</span>
 		</div>
-		<div style="float: right; margin: 3px; margin-rigth: 5px; width: auto; display: inline;">
-			<span class="message-reply" style="display: inline; margin-right: 1px;">
-				<button class="button message-reply" title="Responder Mensagem">Responder</button>
-				<button class="button message-next" title="Mais opções para responder">&nbsp;</button>
-			</span>
-		</div>
-		<div style="float: right; margin: 3px; margin-rigth: 5px; width: auto; display: inline;">
-			<span class="messages-foward" style="display: inline; margin-right: 1px;">
-				<button class="button message-foward" title="Encaminhar Mensagem">Encaminhar</button>
-			</span>
-		</div>
-		<div style="float: right; margin: 3px; margin-rigth: 5px; width: auto; display: inline;">
-			<span style="display: inline;">
-				<button class="button message-tags" title="Marcadores">&nbsp;</button>
-				<button class="button message-more" title="Mais Ações">Mais</button>
+		<div style="float: right; margin: 3px; width: auto; display: inline; margin-right: 0px;">
+			<span class="messages-remove" style="display: inline; margin-right: 1px;">
 				<button class="button message-remove" title="Excluir">&nbsp;</button>
 			</span>
 		</div>
-		<div class="buttons" style="float: right; margin: 3px; margin-rigth: 5px; width: auto; display: inline;">
+		<% if($.trim(data.info.Draft) == ""){ %>
+		<div style="float: right; margin: 3px; width: auto; display: inline; margin-right: 0px;">
+			<span class="messages-forward" style="display: inline; margin-right: 1px;">
+				<button class="button message-forward" title="Encaminhar Mensagem">&nbsp;</button>
+			</span>
+		</div>
+		<div style="float: right; margin: 3px; width: auto; display: inline;">
+			<span class="message-reply" style="display: inline; margin-right: 1px;">
+				<button class="button message-reply" title="Responder Mensagem">&nbsp;</button>
+				<a href="#" class="button message-reply-options" title="Mais opções para responder">&nbsp;</a>
+				<div class="message-reply-menu-content" style="display:none;"> 
+					<ul>
+						<li><a href="#" class="menu-pass-through">Sem Histórico</a></li>
+						<li><a href="#" class="menu-command configurations">Todos com Histórico</a></li>
+						<li><a href="#" class="menu-command configurations">Todos sem Histórico</a></li>
+					</ul>
+				</div>
+			</span>
+		</div>
+		<% }else{ %>
+		<div style="float: right; margin: 3px; width: auto; display: inline; margin-right: 0px;">
+			<span class="message-edit" style="display: inline; margin-right: 1px;">
+				<button class="button message-edit" title="Editar Rascunho">&nbsp;</button>
+			</span>
+		</div>
+		<% } %>
+		<div style="float: right; margin: 3px; width: auto; display: inline; margin-right: 0px;">
+			<span style="display: inline;">
+				<button class="button message-tags" title="Marcadores">&nbsp;</button>
+				<div class="message-tags-menu-content" style="display:none;"> 
+					<ul>
+					</ul>
+				</div>
+
+				<a class="button message-more" href="#" title="Mais Ações">Mais</a>
+				<div class="message-more-menu-content" style="display:none;"> 
+					<ul>
+						<li><a href="#" class="menu-command configurations">Mover</a></li>
+						<li><a href="#" class="menu-command configurations">Exportar</a></li>
+						<li><a href="#" class="menu-pass-through">Bloquear Remetente</a></li>
+						<li><a href="#" class="menu-pass-through">Reportar Erro</a></li>
+					</ul>
+				</div>
+			</span>
+		</div>
+		<div class="buttons" style="float: right; margin: 3px; width: auto; display: inline;">
 			<span  class="message-flags" style="display: inline; margin-right: 1px;">
 
-				<input type="checkbox" id="check10<%= data.ID %>" class="message-important-flag"/>
-				<label title="Marcar como importante" for="check10<%= data.ID %>" style="height: 22px;"></label>
+				<input type="checkbox" id="check10<%= data.ID %>" class="message-important-flag"
+				<%= data.info.Flagged ? 'checked="checked"' : '' %>
+				/>
+				<label title="Marcar como importante" for="check10<%= data.ID %>">&nbsp;</label>
 
 				<input type="checkbox" id="check2<%= data.ID %>" class="message-unread-flag"/>
-				<label title="Marcar como nao lida" for="check2<%= data.ID %>" style="height: 22px;"></label>
+				<label title="Marcar como nao lida" for="check2<%= data.ID %>">&nbsp;</label>
 
-				<input type="checkbox" id="check3<%= data.ID %>" class="message-spam-flag"/>
-				<label title="Marcar como Spam" for="check3<%= data.ID %>" style="height: 22px;"></label>
+				<input type="checkbox" id="check3<%= data.ID %>" class="message-spam-flag" 
+					<%= data.info.msg_folder.split(cyrus_delimiter)[data.info.msg_folder.split(cyrus_delimiter).length -1] == spamfolder ? 'checked="checked"' : ''%>/>
+				<label title="Marcar como Spam" for="check3<%= data.ID %>">&nbsp;</label>
 
 				<input type="checkbox" id="check4<%= data.ID %>" class="message-followup-flag"/>
-				<label title="Marcar com Sinalizador" for="check4<%= data.ID %>" style="height: 22px;"></label>
+				<label title="Marcar com Sinalizador" for="check4<%= data.ID %>">&nbsp;</label>
 
 			</span>
@@ -52,6 +87,56 @@
 	</div>
 
-	<div class="message-header">
-
+	<div class="message-header" style="background-color : #F3F7FD; width: 100%; font-weight: bold; font-size: 18px; border-left: 5px solid #BBD8FB;border-radius:5px;">
+		<span class="message-subject"><%=data.info.subject%></span>
+		<table class="message-details">
+			<tr>
+				<td>
+					Enviado Por:
+				</td>
+				<td>
+					<%= data.info.reply_toaddress %>
+				</td>
+			</tr>
+			<tr>
+				<td>
+					De:
+				</td>
+				<td>
+					<%= data.info.from.full %>
+				</td>
+			</tr>
+				<td>
+					Para:
+				</td>
+				<td>
+					<%= data.info.toaddress2 %>
+				</td>
+			<tr>
+			</tr>
+				<td>
+					Data:
+				</td>
+				<td>
+					<%= data.info.fulldate %>
+				</td>
+			<tr>
+			<% if(data.info.cc != ""){ %>
+			</tr>
+				<td>
+					CC:
+				</td>
+				<td>
+					<%= data.info.cc %>
+				</td>
+			<tr>
+			<%}%>
+			</tr>
+			<tr>
+			</tr>
+		</table>
+	</div>
+	<div style="border-radius: 5px; width: 100%; height: 12px;border-bottom: 1px solid #CCC; cursor: pointer;" align="center" title="Mostrar/Ocultar Detalhes" class="message-hide-show-details">
+		<span class="ui-icon ui-icon-carat-1-n"></span>
+		<span class="ui-icon ui-icon-carat-1-s" style="display:none;"></span>
 	</div>
 
Index: /sandbox/newExpressoMail/prototype/modules/mail/templates/new_message.ejs
===================================================================
--- /sandbox/newExpressoMail/prototype/modules/mail/templates/new_message.ejs	(revision 6930)
+++ /sandbox/newExpressoMail/prototype/modules/mail/templates/new_message.ejs	(revision 7167)
@@ -1,3 +1,3 @@
-<div class="new-msg-head-buttons table_message ui-widget-header" style="width:100%; clear: both; display: inline-block; height: 30px;">
+<div class="new-msg-head-buttons table_message ui-widget-header" style="width:99.8%; clear: both; display: inline-block; height: 30px;">
 	<div class="new-msg-head-left-buttons" style="float: left; margin: 3px;">		
 		<button class="send button small" title="<%= get_lang("Send Mail") %>"><%= get_lang("Send") %></button>
@@ -10,33 +10,37 @@
 		%>
 		<button class="save button small" title="<%= get_lang("Save Mail") %>"><%=get_lang("Save")%></button>
-		<%
-		if (parseInt(preferences.use_important_flag)){
-		%>
-		<button class="important button small msg-option" name="input_important_message" title="<%= get_lang("Important message") %>">&nbsp;</button>
-		<%
-		}
-		%>
-		
-		<button class="return-recept button small msg-option <%=(parseInt(preferences.return_recipient_deafault) != 0 ? "expressomail-button-icon-ative": "")%>" name="input_return_receipt" title="<%= get_lang("Return receipt") %>">&nbsp;</button>
-		
-		<%
-		if(parseInt(preferences.use_assinar_criptografar)){
-			if(parseInt(preferences.use_signature_digital_cripto)){
-		%>
-		<button class="return_cripto button small" title="<%=get_lang("Digitally sign message?")%>">&nbsp;</button>
-		<button class="return_digital button small" title="<%=get_lang("Encrypted email")%>">&nbsp;</button>
-		<%
+		<span class="flags-buttons">
+			<%
+			if (parseInt(preferences.use_important_flag)){
+			%>
+			<button class="important button small msg-option" name="input_important_message" title="<%= get_lang("Important message") %>">&nbsp;</button>
+			<%
 			}
-		}
-		%>
+			%>
+			
+			<button class="return-recept button small msg-option <%=(parseInt(preferences.return_recipient_deafault) != 0 ? "expressomail-button-icon-ative": "")%>" name="input_return_receipt" title="<%= get_lang("Return receipt") %>">&nbsp;</button>
+			
+			<%
+			if(parseInt(preferences.use_assinar_criptografar)){
+				if(parseInt(preferences.use_signature_digital_cripto)){
+			%>
+			<button class="return_cripto button small" title="<%=get_lang("Digitally sign message?")%>">&nbsp;</button>
+			<button class="return_digital button small" title="<%=get_lang("Encrypted email")%>">&nbsp;</button>
+			<%
+				}
+			}
+			%>
+		</span>
 	</div>
 	<div class="new-msg-head-right-buttons" style="float: right; margin: 3px; margin-rigth: 5px;">
-		<button class="button small cc-button"><%= get_lang("Add CC") %></button>
-		<%if(allow_hidden_copy){ %>
-		<button class="button small cco-button"><%= get_lang("Add BCC") %></button>
-		<%
-		}	
-		%>
-		<button class="button small reply-to-button"><%= get_lang("Reply to") %></button>
+		<span class="field-buttons">
+			<button class="button small cc-button">CC</button>
+			<%if(allow_hidden_copy){ %>
+			<button class="button small cco-button">CCO</button>
+			<%
+			}	
+			%>
+			<button class="button small reply-to-button"><%= get_lang("Reply") %></button>
+		</span>
 		<button class="button small rich-button"><%= (preferences.plain_text_editor == 1 ? get_lang("Rich Text") : get_lang("Simple Text")) %></button>
 	</div>
Index: /sandbox/newExpressoMail/expressoMail1_2/index.php
===================================================================
--- /sandbox/newExpressoMail/expressoMail1_2/index.php	(revision 7064)
+++ /sandbox/newExpressoMail/expressoMail1_2/index.php	(revision 7167)
@@ -48,7 +48,5 @@
 		<script src="../library/ckeditor/adapters/jquery.js" language="javascript"></script> 
 		<script src="../prototype/plugins/lazy/jquery.lazy.js" language="javascript"></script> 
-		<link rel="stylesheet" type="text/css" href="../prototype/plugins/fgmenu/fg.menu.css" media="screen">
 		<link rel="Stylesheet" type="text/css" href="../prototype/plugins/jquery/jquery-ui.css" />					
-		
 		<link rel="stylesheet" type="text/css" href="../prototype/plugins/contextmenu/jquery.contextMenu.css"></link>
 		<link rel="stylesheet" type="text/css" href="../prototype/plugins/zebradialog/css/zebra_dialog.css"></link>		
@@ -68,17 +66,17 @@
 		<script type="text/javascript" src="../prototype/plugins/fileupload/jquery.fileupload.js"></script>
 		<script type="text/javascript" src="../prototype/plugins/fileupload/jquery.iframe-transport.js"></script>
-		<script type="text/javascript" src="../prototype/plugins/scrollable-tabs/jquery.scrollabletab.js"></script>
-		<script type="text/javascript" src="../prototype/plugins/qtip/jquery.qtip-1.0.0-rc3.min.js"></script>
-		<script type="text/javascript" src="../prototype/plugins/fgmenu/fg.menu.js"></script>
+    	<script type="text/javascript" src="../prototype/plugins/qtip/jquery.qtip-1.0.0-rc3.min.js"></script>
+    	<link rel="stylesheet" type="text/css" href="../prototype/plugins/fgmenu/fg.menu.css" media="screen">
+		<script type="text/javascript" src="../prototype/plugins/fgmenu/fg.menuPlugin.js"></script>
 		<script type="text/javascript" src="../prototype/plugins/contextmenu/jquery.contextMenu.js"></script>
 		<!-- <script type="text/javascript" src="../prototype/plugins/contextmenu/jquery.ui.position.js"></script> -->
 		
+		<script type="text/javascript" src="../prototype/modules/calendar/js/timezone.js"></script>
 		<script type="text/javascript" src="../prototype/modules/calendar/js/timezone.js"></script>
         <script type="text/javascript" src="../prototype/plugins/dateFormat/dateFormat.js"></script>
 		<script type="text/javascript" src="../prototype/modules/calendar/js/calendar.date.js"></script>
 		<script type="text/javascript" src="../prototype/modules/calendar/js/calendar.codecs.js"></script>
-		<link rel="stylesheet" type="text/css" href="../prototype/plugins/freeow/style/freeow/freeow.css" >
+		<link rel="stylesheet" type="text/css" href="../prototype/plugins/freeow/style/freeow/freeow.css"/>
 		<script type="text/javascript" src="../prototype/plugins/freeow/jquery.freeow.min.js"></script>
-		<script type="text/javascript" src="../prototype/plugins/freeow/jquery.freeow.js"></script>
 
 
Index: /sandbox/newExpressoMail/expressoMail1_2/templates/default/index.tpl
===================================================================
--- /sandbox/newExpressoMail/expressoMail1_2/templates/default/index.tpl	(revision 6997)
+++ /sandbox/newExpressoMail/expressoMail1_2/templates/default/index.tpl	(revision 7167)
@@ -95,18 +95,19 @@
 	</td>
 	<td class="collapse_folders_td">
-		<span class="collapse_folders"/>
+		<span class="collapse_folders ui-icon ui-icon-triangle-1-w" title="Ocultar"></span>
+		<span class="collapse_folders ui-icon ui-icon-triangle-1-e" title="Expandir" style="display:none;"></span>
 	</td>			
 	<td width="100%" valign="top" align="left">
 		<div id="exmail_main_body" class="messagescol">
 			<div id="ptabs">
-                <ul>
+                <ul style="border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;">
                     <li class="ui-tab-disabled" style="opacity: 100;">
-                        <a href="#ui-tabs-0">&nbsp;{lang_inbox}&nbsp;<font face="Verdana" size="1" color="#505050">
+                        <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="ui-tabs-0">
-                    <table class="fuu" id="message_attacher_grid">
+                <div id="ptabs_0" role="folder">
+                    <table id="message_attacher_grid">
                         <tr>
                             <td/>
Index: /sandbox/newExpressoMail/expressoMail1_2/templates/default/main.css
===================================================================
--- /sandbox/newExpressoMail/expressoMail1_2/templates/default/main.css	(revision 6997)
+++ /sandbox/newExpressoMail/expressoMail1_2/templates/default/main.css	(revision 7167)
@@ -43,12 +43,6 @@
 table.expressomail-message-body {width:100%; height:100%;}
 table.table_message, div.table_message {
-background: #96b3d3; /* Old browsers */
-background: -moz-linear-gradient(top, #96b3d3 0%, #b4c9e4 30%, #d9e6ef 65%, #e2e9f1 70%, #e9f0f8 78%, #e8f1fa 83%, #dbe5ef 96%, #d9e3ed 100%); /* FF3.6+ */
-background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#96b3d3), color-stop(30%,#b4c9e4), color-stop(65%,#d9e6ef), color-stop(70%,#e2e9f1), color-stop(78%,#e9f0f8), color-stop(83%,#e8f1fa), color-stop(96%,#dbe5ef), color-stop(100%,#d9e3ed)); /* Chrome,Safari4+ */
-background: -webkit-linear-gradient(top, #96b3d3 0%,#b4c9e4 30%,#d9e6ef 65%,#e2e9f1 70%,#e9f0f8 78%,#e8f1fa 83%,#dbe5ef 96%,#d9e3ed 100%); /* Chrome10+,Safari5.1+ */
-background: -o-linear-gradient(top, #96b3d3 0%,#b4c9e4 30%,#d9e6ef 65%,#e2e9f1 70%,#e9f0f8 78%,#e8f1fa 83%,#dbe5ef 96%,#d9e3ed 100%); /* Opera 11.10+ */
-background: -ms-linear-gradient(top, #96b3d3 0%,#b4c9e4 30%,#d9e6ef 65%,#e2e9f1 70%,#e9f0f8 78%,#e8f1fa 83%,#dbe5ef 96%,#d9e3ed 100%); /* IE10+ */
-background: linear-gradient(top, #96b3d3 0%,#b4c9e4 30%,#d9e6ef 65%,#e2e9f1 70%,#e9f0f8 78%,#e8f1fa 83%,#dbe5ef 96%,#d9e3ed 100%); /* W3C */
-filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#96b3d3', endColorstr='#d9e3ed',GradientType=0 ); /* IE6-9 */
+	border-top-left-radius: 0px; 
+	border-top-right-radius: 0px;
 }
 table.expressomail-message-body tr{vertical-align:top;}
@@ -803,5 +797,5 @@
 .em_div_sidebox_menu {
 	position: relative;
-	left: 17px;
+	padding-left: 17px;
 	cursor: pointer;
 }
@@ -1471,3 +1465,10 @@
 } 
 
-.ui-state-highlight { width: 60px; height: 23px; border-radius: 5px;}
+.ui-state-highlight-prognus { width: 90px; height: 19px; border-radius: 5px; border : 3px dashed #F93 !important; border-bottom: 3px dashed #F93 !important;}
+
+.message-detail-hover { border-bottom : 1px solid #1B75BB !important;}
+
+.ui-tabs .ui-tabs-nav li .ui-icon-circle-close  {
+	float: right;
+	margin: 5px 5px 0 -5px;
+}
Index: /sandbox/newExpressoMail/expressoMail1_2/js/abas.js
===================================================================
--- /sandbox/newExpressoMail/expressoMail1_2/js/abas.js	(revision 7064)
+++ /sandbox/newExpressoMail/expressoMail1_2/js/abas.js	(revision 7167)
@@ -8,15 +8,30 @@
 var countID = 2;
 var tab_content = "";
+var tab_role = "";
 var lastIndexSelected = 0;
 
 var ptabs = $("#ptabs").tabs({ 
-	tabTemplate: "<li role='tab' style='cursor: pointer;'><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close' title='Fechar Aba'>Fechar Aba</span></li>", 
+	tabTemplate: "<li role='tab' style='cursor: pointer;'><a href='#{href}'>#{label}</a> <span class='ui-icon tab-close ui-icon-close' title='Fechar Aba'>Fechar Aba</span></li>", 
+	panelTemplate: "<div></div>",
 	add: function( event, ui ) { 
 	        countID++; 
-	        $(ptabs).tabs('select', '#' + ui.panel.id); 
-	        $.cookie('open_tabs', ($.cookie('open_tabs') ? $.cookie('open_tabs')+"," : "") +ui.panel.id.substring(6));
-	        $( ui.panel ).addClass("conteudo").append(tab_content); 
+	        $(ptabs).tabs('select', '#' + $(ptabs).find("div:last").attr("id")); 
+         	$(ptabs).find("span.tab-close:last").hover(function(){$(this).toggleClass("ui-icon-circle-close ui-icon-close");}, function(){$(this).toggleClass("ui-icon-circle-close ui-icon-close");})
+	        $(ptabs).find("div:last").addClass("conteudo").attr("role", tab_role).append(tab_content); 
+	        if(tab_role == "new")
+	        	uidsSave[indexTab("#"+ui.panel.id)] = [];
 	},
 	show: function(event, ui){
+		switch($( ui.panel ).attr("role")){
+			case "new":
+			case "search":
+				$("#footer_menu").hide();
+				break;
+			case "message":
+			case "draft":
+			case "folder":
+				$("#footer_menu").show();
+				break;
+		}
 		resizeWindow();
 	},
@@ -29,5 +44,4 @@
 });
 
-//$(ptabs).find(".ui-tabs-nav").wrap("<div class='scroll-tabs'></div>");
 /* 
 	method : createTab
@@ -35,4 +49,5 @@
 	params : {
 		label : Label of the tab
+		* role : Tab type
 		* content : Content of the tab
 		* href : Tab id 
@@ -42,16 +57,19 @@
 		#1 : if the user just set the label, a tab with blank content and a dynamic id is created
 		#2 : if a tab with a set href already exists, don't duplicate, this function only select the tab 
-
+		#3 : if the role is 
 	* = Optional
 */
 
-function createTab(label, content,href, callback){
+function createTab(label, role, content,href, callback){
 	if( !$("#ptabs_"+href).length){
 		tab_content = content ? content : "";
+		tab_role = role ? role : "new";
 		$(ptabs).tabs("add", "#ptabs_"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label));
 		if(typeof(callback) == 'function') 
 			callback($("#ptabs_"+(href ? href : countID)));
+		else
+			return $("#ptabs_"+(href ? href : countID));
 	}else{
-		$(ptabs).tabs( "select", indexTab(href) );
+		$(ptabs).tabs( "select", indexTab("#ptabs_"+href) );
 	}
 }
@@ -83,5 +101,5 @@
 /* 
 	method : indexTab
-	descrition : remove a tab
+	descrition : return a tab index
 	params : {
 		* href : Tab id 
@@ -97,2 +115,40 @@
 		$( "li", ptabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected;
 }
+
+/*
+ method : idTab
+ descrition : remove a tab id
+ params : {
+ * index : Tab index
+ }
+ comments : {
+ #1 : if the user doesn't set no parameter, this function just return the id of the open tab
+
+ * = Optional
+ */
+
+function idTab(index){
+    return $( ".ui-tabs-panel", ptabs ).eq((index ? index : indexTab())).attr("id");
+}
+
+function getTabData(index){
+	return {
+		id : parseInt(idTab(index).substring(6).split("_r_")[0]),
+		folder : Base64.decode(idTab(index).substring(6).split("_r_")[1]),
+		role : getTabRole(index),
+		header : getTabHeader(index),
+		content : getTabContent(index)
+	};
+}
+
+function getTabHeader(index){
+    return $( ptabs ).find('[href="#'+$( ".ui-tabs-panel", ptabs ).eq((index ? index : indexTab())).attr("id")+'"]').parent();
+}
+
+function getTabRole(index){
+	return getTabContent(index).attr("role");
+}
+
+function getTabContent(index){
+	return $( ".ui-tabs-panel", ptabs ).eq((index ? index : indexTab()));
+}
Index: /sandbox/newExpressoMail/expressoMail1_2/js/common_functions.js
===================================================================
--- /sandbox/newExpressoMail/expressoMail1_2/js/common_functions.js	(revision 7043)
+++ /sandbox/newExpressoMail/expressoMail1_2/js/common_functions.js	(revision 7167)
@@ -67,17 +67,17 @@
 	}
 
-	if(typeof(BordersArray) != 'undefined') {
-		for(var i = 1; BordersArray.length > 1 && i < BordersArray.length;i++) {
-			var div_scroll = Element("div_message_scroll_"+BordersArray[i].sequence);
-			var div = Element("ptabs_"+BordersArray[i].sequence);
-
-			if(div){
-				div.style.height = (clientHeight - (findPosY(div) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+2)) + "px";
-				 div.style.width = (clientWidth - (findPosX(div)+10)) + "px";
-			}
-			if(div_scroll){
-				div_scroll.style.height = (clientHeight - (findPosY(div_scroll) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+5)) + "px";
-				div_scroll.style.width = (clientWidth - (findPosX(div_scroll)+15)) + "px";
-			}
+	var BordersArray = $(".ui-tabs-panel", ptabs);
+	//$(".ui-tabs-nav").css("width", $(ptabs).width()-6);
+	for(var i = 1; BordersArray.length > 1 && i < BordersArray.length;i++) {
+		var div_scroll = Element("div_message_scroll_"+BordersArray[i]);
+		var div = BordersArray[i];
+
+		if(div){
+			div.style.height = (clientHeight - (findPosY(div) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+2)) + "px";
+			 div.style.width = (clientWidth - (findPosX(div)+10)) + "px";
+		}
+		if(div_scroll){
+			div_scroll.style.height = (clientHeight - (findPosY(div_scroll) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+5)) + "px";
+			div_scroll.style.width = (clientWidth - (findPosX(div_scroll)+15)) + "px";
 		}
 	}
@@ -234,4 +234,7 @@
 function kill_current_box(){
 	var box = document.getElementById("table_box");
+	if($("#div_msg_info").length){
+		$("#div_msg_info").remove();
+	}
 	if (box != null)
 		box.parentNode.removeChild(box);
@@ -817,5 +820,5 @@
 function search_emails(value, data){
 	var resize = false;
-        resize = resize_borders();
+/*        resize = resize_borders();
         if (!resize){
             var str_continue = '';
@@ -852,4 +855,5 @@
             }
         }
+*/
 	connector.loadScript("TreeS");
 	connector.loadScript("search");
Index: /sandbox/newExpressoMail/expressoMail1_2/js/main.js
===================================================================
--- /sandbox/newExpressoMail/expressoMail1_2/js/main.js	(revision 7064)
+++ /sandbox/newExpressoMail/expressoMail1_2/js/main.js	(revision 7167)
@@ -86,7 +86,7 @@
 		current_folder="INBOX";
 
-		$( "#ptabs span.ui-icon-close" ).live( "click", function() { 
+		$( "#ptabs ul span.ui-icon.tab-close" ).live( "click", function() { 
 			removeTab($( this ).prev().attr("href"));
-
+/*
 			var teste = "";
 			var ola = $( this );
@@ -97,4 +97,5 @@
 			});
 			$.cookie('open_tabs', teste.substring(0, teste.length-1));
+*/
 		});
 
@@ -103,11 +104,11 @@
 			helper : function(e, drag){
 				var helper = $(drag).clone();
-				helper.addClass("ui-corner-all").css("width", "auto").find("span.ui-icon-close").hide().end().find("a").html("Mover "+helper.find("a").html());
+				helper.addClass("ui-corner-all").css("width", "auto").find("span.ui-icon").hide().end().find("a").html("Mover "+helper.find("a").html());
 				return helper;
 			},
-			placeholder: 'ui-state-highlight',
+			placeholder: 'ui-state-highlight-prognus',
 			forcePlaceholderSize: true
 		}).disableSelection();
-
+/*
 		if($.cookie('open_tabs')){	
 			$.Zebra_Dialog("Gostaria de recuperar suas mensagens que estavam abertas?", {
@@ -156,5 +157,5 @@
 			});
 		}
-
+*/
 		if( (window.google && google.gears) && !google.gears.factory.getPermission())
 		    preferences.use_local_messages=0;
@@ -205,47 +206,11 @@
 		DataLayer.get("folder", true);
 		cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu);	
-		
-		if($.cookie('collapse_folders') == "true"){
-			if(!is_ie)
-				$("#folderscol").addClass( "hidden");
-			else
-				$("#folderscol").hide();
-			$(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-e").children().attr('title', "Expandir");
-			refresh();
-			//resizeWindow();
-		}	
-		else{
-			$(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-w").children().attr('title', "Ocultar");
-			refresh();
-			//resizeWindow();
-		}
-		
+
 		$(".collapse_folders_td").attr('title', "Ocultar/Expandir").click(function(){
-			if($("#folderscol").css("display") != "none"){
-				if(!is_ie)
-					$("#folderscol").addClass( "hidden");
-				else
-					$("#folderscol").hide();
-					
-				$(".collapse_folders").removeClass("ui-icon-triangle-1-w");
-				$(".collapse_folders").addClass("ui-icon-triangle-1-e");
-				$(".collapse_folders").parent().attr('title', "Expandir");
-				$.cookie('collapse_folders', "true");
+			$(this).find("span").toggle();
+			$("#folderscol").toggle("blind", {direction: "horizontal"}, "normal", function(){
 				refresh();
-				resizeWindow();
-			}else{
-				if(!is_ie)
-					$("#folderscol").removeClass( "hidden");
-				else
-					$("#folderscol").show();
-				$(".collapse_folders").removeClass("ui-icon-triangle-1-e");
-				$(".collapse_folders").addClass("ui-icon-triangle-1-w");
-				$(".collapse_folders").parent().attr('title', "Ocultar");
-				$.cookie('collapse_folders', "false");
-				refresh();
-				//resizeWindow();
-			}
-			//resizeWindow();
-			
+				resizeWindow();	
+			});
 		}).hover(
 			function(){
@@ -569,67 +534,11 @@
 		else {
 			var sbj = msg_info.subject.length < 21 ? msg_info.subject : msg_info.subject.substr(0,21) + "...";
+			//console.log(msg_info);
 			var content = $(DataLayer.render("../prototype/modules/mail/templates/email.ejs", {info : msg_info, ID : id_msg_read}));
 
-			createTab(sbj, content.html(), id_msg_read, function(content){
-                content.find(".message-flags").find(".message-important-flag").button({
-                	icons: {
-                		primary: "ui-icon-notice"
-                	},
-                    text: false
-                }).end().find(".message-unread-flag").button({
-                	icons: {
-                		primary: "ui-icon-mail-closed"
-                	},
-                    text: false
-                }).end().find(".message-spam-flag").button({
-                	icons: {
-                		primary: "ui-icon-alert"
-                	},
-                    text: false	
-                }).end().find(".message-followup-flag").button({
-                	icons: {
-                		primary: "ui-icon-flag"
-                	},
-                    text: false
-                });
-                content.find(".message-flags").buttonset();
-
-                content.find(".messages-controll").find(".message-prev").button({
-                	icons: {
-                		primary: "ui-icon-carat-1-w"
-                	},
-                    text: false
-                }).next().button({
-                	icons: {
-                		primary: "ui-icon-carat-1-e"
-                	},
-                    text: false
-                });
-                content.find(".messages-controll").buttonset();
-                content.find(".message-tags").button({
-                    icons: {
-                        primary: "ui-icon-tag",
-                        secondary: "ui-icon-triangle-1-s"
-                    },
-                    text: false
-                }).next().button({
-                    icons: {
-                        secondary: "ui-icon-triangle-1-s"
-                    },
-                    text: true
-                }).next().button({
-                    icons: {
-                        primary: "ui-icon-trash"
-                    },
-                    text: false
-                });
-                content.find(".messages-preferences").button({
-                    icons: {
-                        primary: "ui-icon-gear",
-                        secondary: "ui-icon-triangle-1-s"
-                    },
-                    text: false
-                }).css("width", "45px");
+			createTab(sbj, 'message', content.html(), id_msg_read, function(content){
+				buildMessageButtons(content);
             });
+            return;
 
 			//$(".message-flags").buttonset();
@@ -709,4 +618,209 @@
 	}
 	setTimeout('resizeWindow()',300);
+}
+
+function buildMessageButtons(content){
+	var data = getTabData();
+	//FLAGS BUTTON SET 
+    content.find(".message-flags").find(".message-important-flag").button({
+    	icons: {
+    		primary: "ui-icon-notice"
+    	},
+        text: false
+    }).click(function(){
+    	var checked = $(this).attr("checked") == "checked" ? true : false;
+    	set_message_flag(data.id, checked ? "flagged" : "unflagged", undefined, data.folder);
+    	write_msg(get_lang('Message marked as ') + get_lang( checked ? "Important" : "Normal"));
+    	refresh();
+    }).end().find(".message-unread-flag").button({
+    	icons: {
+    		primary: "ui-icon-mail-closed"
+    	},
+        text: false
+    }).click(function(){
+    	var checked = $(this).attr("checked") == "checked" ? true : false;
+    	set_message_flag(data.id, checked ? "unseen" : "seen", undefined, data.folder);
+    	write_msg(get_lang('Message marked as ') + get_lang( checked ? "Unseen" : "Seen"));
+    	refresh();
+    }).end().find(".message-spam-flag").button({
+    	icons: {
+    		primary: "ui-icon-alert"
+    	},
+        text: false	
+    }).click(function(){
+    	var checked = $(this).attr("checked") == "checked" ? true : false;
+    	checked ? spam(data.folder, data.id,'null') : nospam(data.id,'null', data.folder);
+    	removeTab();
+    	refresh();
+    }).end().find(".message-followup-flag").button({
+    	icons: {
+    		primary: "ui-icon-flag"
+    	},
+        text: false
+    });
+    content.find(".message-flags").buttonset();
+
+    //MESSAGES ACTION NEXT PREV BUTTON SET
+    content.find(".messages-controll").find(".message-prev").button({
+    	icons: {
+    		primary: "ui-icon-carat-1-w"
+    	},
+        text: false
+    }).click(function(){
+
+    }).next().button({
+    	icons: {
+    		primary: "ui-icon-carat-1-e"
+    	},
+        text: false
+    });
+    content.find(".messages-controll").buttonset();
+
+    //
+    content.find(".message-forward").button({
+    	icons:{
+    		primary: "ui-icon-arrowreturnthick-1-e"
+    	},
+    	text : false
+    });
+
+	var teste = content.find(".message-reply-menu-content").clone();
+	content.find(".message-reply-menu-content").remove();
+
+    content.find(".button.message-reply").button({
+    	icons:{
+    		primary: "ui-icon-arrowreturnthick-1-w"
+    	},
+    	text : false
+    }).next().button({
+    	icons:{
+    		primary: "ui-icon-triangle-1-s"
+    	},
+    	text : false
+    }).parent().buttonset();
+
+	content.find("span.message-reply").append(teste);
+
+	content.find(".message-reply").next().menuPlugin({
+		content : content.find(".message-reply-menu-content").html(),
+		positionOpts: {
+			posX: 'left', 
+			posY: 'bottom',
+			offsetX: -140,
+			offsetY: 0,
+			directionH: 'right',
+			directionV: 'down', 
+			detectH: true, // do horizontal collision detection  
+			detectV: true, // do vertical collision detection
+			linkToFront: false
+		},
+		flyOut: true,
+		showSpeed: 100,
+		crumbDefaultText: '>'
+	});
+
+
+    content.find(".button.message-edit").button({
+    	icons:{
+    		primary: "ui-icon-pencil"
+    	},
+    	text : false
+    });
+    //BUTTON MORE AND TAGS
+    content.find(".message-tags").button({
+        icons: {
+            primary: "ui-icon-tag",
+            secondary: "ui-icon-triangle-1-s"
+        },
+        text: false
+    }).next().next().button({
+        icons: {
+            secondary: "ui-icon-triangle-1-s"
+        },
+        text: true
+ 	});
+
+	content.find(".message-more").menuPlugin({
+		content : content.find(".message-more-menu-content").html(),
+		flyOut: true,
+		positionOpts: {
+			posX: 'left', 
+			posY: 'bottom',
+			offsetX: -140,
+			offsetY: 0,
+			directionH: 'right',
+			directionV: 'down', 
+			detectH: true, // do horizontal collision detection  
+			detectV: true, // do vertical collision detection
+			linkToFront: false
+		},
+		showSpeed: 100,
+		crumbDefaultText: '>'
+	});
+ 		
+	content.find(".message-tags-menu-content ul li").remove();
+	$.each(getLabels(), function(key,value){
+		content.find(".message-tags-menu-content ul")
+		.append("<li id='"+key+"'><a href='#'>"+value.name+"</a></li>").find("li:last").click(function(){
+			if(typeof(value.callback) != "function"){
+				var isLabel = key.match(/label(.*)/);
+				if (isLabel && isLabel.length > 1) {
+					labeledMessages(isLabel[1]);
+				}
+			}
+		});
+	});
+
+	content.find(".message-tags").menuPlugin({
+		content : content.find(".message-tags-menu-content").html(),
+		flyOut: true,
+		positionOpts: {
+			posX: 'left', 
+			posY: 'bottom',
+			offsetX: -140,
+			offsetY: 0,
+			directionH: 'right',
+			directionV: 'down', 
+			detectH: true, // do horizontal collision detection  
+			detectV: true, // do vertical collision detection
+			linkToFront: false
+		},
+		showSpeed: 100,
+		crumbDefaultText: '>'
+	});
+    //REMOVE MESSAGE BUTTON
+    content.find(".message-remove").button({
+        icons: {
+            primary: "ui-icon-trash"
+        },
+        text: false
+    }).click(function(){
+    	proxy_mensagens.delete_msgs(data.folder,data.id,'null');
+    	removeTab();
+    	refresh();
+    });
+
+    //PREFERENCES BUTTON
+    content.find(".messages-preferences").button({
+        icons: {
+            primary: "ui-icon-gear",
+            secondary: "ui-icon-triangle-1-s"
+        },
+        text: false
+    }).css("width", "45px");
+
+    //MESSAGE DETAILS 
+    content.find(".message-hide-show-details").click(function(){
+    	$(this).find("span").toggle();
+    	content.find(".message-details").toggle("blind");
+    }).hover(
+		function(){
+			$(this).addClass("message-detail-hover");
+		},
+		function(){
+			$(this).removeClass("message-detail-hover");
+		}
+	);
+
 }
 
@@ -978,6 +1092,6 @@
 					return move_search_msgs('content_id_'+currentTab,userTrashFolder,special_folders['Trash']); 
 					
-				if(currentTab.toString().indexOf("_r") != -1) 
-					msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); 
+//				if(currentTab.toString().indexOf("_r") != -1) 
+//					msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); 
  		         
  		        if (!archive && (parseInt(preferences.save_deleted_msg)) && (folder != userTrashFolder)){ 
@@ -1371,9 +1485,9 @@
 				delete_border(data.border_ID,'false');
 		}
-		if(folder == get_current_folder()){
+//		if(folder === get_current_folder()){
 			var n_total_msg = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length;
 			draw_paging(n_total_msg);
 			Element('tot_m').innerHTML = n_total_msg;
-		}
+//		}
 		refresh();
 	}
@@ -1399,5 +1513,5 @@
 
 	// se a aba estiver aberta e selecionada, apenas a msg da aba ï¿œ movida
-	if(currentTab.toString().indexOf("_r") != -1 && currentTab == border_ID)
+	/*if(currentTab.toString().indexOf("_r") != -1 && currentTab == border_ID)
         {
                 //se a aba for aberta atraves de uma pesquisa
@@ -1406,5 +1520,5 @@
                 else
                     msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf('_r'));
-	}
+	}*/
 	refresh();
 	if (parseInt(msgs_number) > 0 || msgs_number.length > 0){
@@ -1430,5 +1544,5 @@
 				    	delete selectedPagingMsgs[value];
 				    });
-				    totalFolderMsgs -= msgs_number.split(",").length;
+				    totalFolderMsgs -= msgs_number+"".split(",").length;
 
 				    //TESTE
@@ -1595,5 +1709,5 @@
 
 	 if( !id_msgs ){
-	      write_msg( "Todas as mensagens jï¿œ foram arquivadas anteriormente." );
+	      write_msg( "Todas as mensagens jÃ¡ foram arquivadas anteriormente." );
 	      return;
 	  }
@@ -2273,5 +2387,5 @@
 	$("#border_id_" + new_border_ID).attr("title", title);
 //	set_border_caption("border_id_" + new_border_ID, title);
-//	resizeWindow();
+	resizeWindow();
 	return new_border_ID; //Preciso retornar o ID da nova mensagem.
 }
@@ -3270,8 +3384,5 @@
 // Get checked messages
 function set_messages_flag(flag, msgs_to_set){	
-	if(currentTab != 0 && currentTab.indexOf("search_local")  >= 0){
-		return set_messages_flag_search_local(flag);
-	}
-	if (currentTab != 0 && currentTab.indexOf("search_")  >= 0){
+	if(indexTab() != 0){
 		return set_messages_flag_search(flag);
 	}
@@ -3365,7 +3476,8 @@
 	if (msgs_to_set == 'get_selected_messages')
 		var msgs_to_set = this.get_selected_messages();
-	else
+	else{
 		folder = Element("input_folder_"+msgs_to_set+"_r").value;
-	
+    }
+
 	if (msgs_to_set)
 		$.ajax({
@@ -3397,5 +3509,5 @@
 
 // By message number
-function set_message_flag(msg_number, flag, func_after_flag_change){
+function set_message_flag(msg_number, flag, func_after_flag_change, folder){
 	var msg_number_folder = Element("new_input_folder_"+msg_number+"_r"); //Mensagens respondidas/encaminhadas
 	if(!msg_number_folder)
@@ -3440,5 +3552,5 @@
 	$.ajax({
 		  url: 'controller.php?' + $.param( {action: '$this.imap_functions.set_messages_flag',
-						      folder: ( msg_number_folder ?  msg_number_folder.value : get_current_folder() ),
+						      folder: folder ? folder : ( msg_number_folder ?  msg_number_folder.value : get_current_folder() ),
 						      msgs_to_set: msg_number,
 						      flag: flag,
@@ -3914,9 +4026,9 @@
 	}
 
-	if(currentTab.toString().indexOf("_r") != -1)
+	/*if(currentTab.toString().indexOf("_r") != -1)
 		msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));
 	else if(msgs_number == 'selected')
 		msgs_number = get_selected_messages();
-
+	*/
 	//TODO: REFATORAR O Cï¿œDIGO PARA EVITAR recodificaï¿œï¿œo
 	if(currentTab == 0)
@@ -3952,18 +4064,19 @@
 	}
 
-	if(currentTab.toString().indexOf("_r") != -1)
-		msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));
-	else if(currentTab != 0 && currentTab.indexOf("search_")  >= 0){
-		var content_search = document.getElementById('content_id_'+currentTab);mount_url_folder(["INBOX",special_folders['Trash']]), 'Trash',
-		move_search_msgs('content_id_'+currentTab,  mount_url_folder(["INBOX",special_folders["Spam"]]), special_folders['Spam']);
-		refresh();
-		return;
-	}else if(msgs_number == 'selected')
-		msgs_number = get_selected_messages();
-
-	//TODO: REFATORAR O Cï¿œDIGO PARA EVITAR recodificaï¿œï¿œo
-	if(currentTab == 0)
-		msgs_number = get_selected_messages();
-
+	if(!msgs_number){
+		if(currentTab.toString().indexOf("_r") != -1)
+			msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));
+		else if(currentTab != 0 && currentTab.indexOf("search_")  >= 0){
+			var content_search = document.getElementById('content_id_'+currentTab);mount_url_folder(["INBOX",special_folders['Trash']]), 'Trash',
+			move_search_msgs('content_id_'+currentTab,  mount_url_folder(["INBOX",special_folders["Spam"]]), special_folders['Spam']);
+			refresh();
+			return;
+		}else if(msgs_number == 'selected')
+			msgs_number = get_selected_messages();
+
+		//TODO: REFATORAR O Cï¿œDIGO PARA EVITAR recodificaï¿œï¿œo
+		if(currentTab == 0)
+			msgs_number = get_selected_messages();
+	}
 	if(parseInt(msgs_number) > 0 || msgs_number.length > 0)
 		cExecute ("$this.imap_functions.spam&folder="+folder+"&spam=true"+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&sort_box_reverse="+sort_box_reverse+"&reuse_border="+border_ID+"&new_folder="+new_folder+"&new_folder_name="+new_folder_name+"&get_previous_msg="+0+"&cyrus_delimiter="+cyrus_delimiter, handler_move_msgs);
@@ -4568,5 +4681,5 @@
             var border_id = form.abaID;  
             //Defininindo pasta a ser salva mensagem
-			var user_selected = $('#content_id_'+border_id).find('.from-select option:selected').text();
+			var user_selected = $('#ptabs_'+border_id).find('.from-select option:selected').text();
 			var str_begin_name = user_selected.indexOf('<') + 1;
 			var str_end_name = user_selected.indexOf('@');
@@ -4598,4 +4711,5 @@
 			form.type =  RichTextEditor.plain[border_id] ? 'plain' : 'html';	    
             form.attachments = listAttachment(border_id);
+            uidsSave[border_id] = [];
             form.uidsSave = uidsSave[border_id].toString();
             return( form );
@@ -4684,2 +4798,29 @@
 
 
+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/newExpressoMail/expressoMail1_2/js/messages_controller.js
===================================================================
--- /sandbox/newExpressoMail/expressoMail1_2/js/messages_controller.js	(revision 6930)
+++ /sandbox/newExpressoMail/expressoMail1_2/js/messages_controller.js	(revision 7167)
@@ -89,5 +89,5 @@
 			msgs_number = get_selected_messages();
 		
-		if(currentTab != 0 && currentTab.indexOf("search_")  >= 0){
+		/*if(currentTab != 0 && currentTab.indexOf("search_")  >= 0){
 			var content_search = document.getElementById('content_id_'+currentTab);
 			action_msg_selected_from_search(content_search.id, 'delete');
@@ -96,5 +96,5 @@
 			//update_local_box(); 
 			return;
-		}
+		}*/
 			
 		if (!this.is_local_folder(folder)){
@@ -151,5 +151,5 @@
 	}
 	
-	messages_proxy.prototype.proxy_set_message_flag = function (msg_number,flag,func_after_flag_change){
+	messages_proxy.prototype.proxy_set_message_flag = function (msg_number,flag,func_after_flag_change, folder){
 		var msg_number_folder = Element("new_input_folder_"+msg_number+"_r"); //Mensagens respondidas/encaminhadas
 		if(!msg_number_folder)
Index: /sandbox/newExpressoMail/expressoMail1_2/js/draw_api.js
===================================================================
--- /sandbox/newExpressoMail/expressoMail1_2/js/draw_api.js	(revision 7064)
+++ /sandbox/newExpressoMail/expressoMail1_2/js/draw_api.js	(revision 7167)
@@ -49,302 +49,4 @@
 // aqui no expressoMail.
 
-function draw_tree_folders(folders){
-	// Check if the tree folders alredy exist.
-	if (Element('dftree_tree_folders')){
-		if (!expresso_offline) {
-			var update_tree_folders = function(data){
-				draw_quota(data);
-				var unseen_in_mailbox = 0;
-				var unseen_in_shared_folders = 0;
-				for (var i=0; i<data.length; i++){
-					if ( data[i].folder_unseen > 0 )
-					{
-						unseen_in_mailbox = parseInt( unseen_in_mailbox + data[ i ].folder_unseen );
-						if ( data[i].folder_id.indexOf( 'INBOX' ) !== 0 )
-							unseen_in_shared_folders = parseInt( unseen_in_shared_folders + data[ i ].folder_unseen );
-					}
-
-					var folder_unseen = Element('dftree_'+data[i].folder_id+'_unseen');
-
-					if ((folder_unseen) && (data[i].folder_unseen > 0))
-					{
-						folder_unseen.innerHTML = data[i].folder_unseen;
-					}
-					else if (data[i].folder_unseen > 0)
-					{
-						tree_folders.getNodeById(data[i].folder_id).alter({caption:lang_folder(data[i].folder_name) + '<font style=color:red>&nbsp(</font><span id="dftree_'+data[i].folder_id+'_unseen" style=color:red>'+data[i].folder_unseen+'</span><font style=color:red>)</font>'});
-						tree_folders.getNodeById(data[i].folder_id)._refresh();
-					}
-					else if (data[i].folder_unseen <= 0)
-					{
-						if(tree_folders.getNodeById(data[i].folder_id)){
-						tree_folders.getNodeById(data[i].folder_id).alter({caption:lang_folder(data[i].folder_name)});
-						tree_folders.getNodeById(data[i].folder_id)._refresh();
-					}
-					}
-
-					if(data[i].folder_id == current_folder){
-						var old_new_m = isNaN(parseInt(Element('new_m').innerHTML)) ? parseInt(Element('new_m').firstChild.innerHTML) : parseInt(Element('new_m').innerHTML);
-						Element('new_m').innerHTML = data[i].folder_unseen ? '<font color="RED">'+data[i].folder_unseen+'</font>' : 0;
-						draw_paging(Element('tot_m').innerHTML);
-					}
-				}
-
-				var display_unseen_in_mailbox = tree_folders.getNodeById( 'root' );
-				display_unseen_in_mailbox.alter({caption:get_lang("My Folders")});
-				display_unseen_in_mailbox._refresh();
-
-				var display_unseen_in_shared_folders = tree_folders.getNodeById( 'user' );
-				if ( display_unseen_in_shared_folders )
-				{
-					if ( unseen_in_shared_folders )
-						display_unseen_in_shared_folders.alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">' + unseen_in_shared_folders +'</span><font style=color:red>]</font> ' + get_lang("Shared folders")});
-					else
-						display_unseen_in_shared_folders.alter({caption:get_lang("Shared folders")});
-					display_unseen_in_shared_folders._refresh();
-				}
-			}
-			cExecute ("$this.imap_functions.get_folders_list&folder="+current_folder, update_tree_folders);
-		}
-
-		return;
-	}
-	else{
-		if (!expresso_offline) {
-			tree_folders = new dFTree({name: 'tree_folders'});
-
-			var n_root = new dNode({id:'root', caption: get_lang("My Folders")});
-			tree_folders.add(n_root,'anything'); //Places the root; second argument can be anything.
-
-			var unseen_in_mailbox = 0;
-			var unseen_in_shared_folders = 0;
-			for (var i=0; i<folders.length; i++){
-				if (folders[i].folder_unseen > 0)
-				{
-					unseen_in_mailbox = parseInt( unseen_in_mailbox + folders[ i ].folder_unseen );
-					if ( folders[i].folder_id.indexOf( 'INBOX' ) !== 0 )
-						unseen_in_shared_folders = parseInt( unseen_in_shared_folders + folders[ i ].folder_unseen );
-
-					var nn = new dNode({id:folders[i].folder_id, caption:lang_folder(folders[i].folder_name) + '<font style=color:red>&nbsp(</font><span id="dftree_'+folders[i].folder_id+'_unseen" style=color:red>'+folders[i].folder_unseen+'</span><font style=color:red>)</font>', onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')", plusSign:folders[i].folder_hasChildren});
-
-					if( folders[i].folder_name.toLowerCase() == 'inbox' )
-						Element('new_m').innerHTML = '<font style="color:red">' + folders[i].folder_unseen + '</font>';
-				}
-				else
-					var nn = new dNode({id:folders[i].folder_id, caption:lang_folder(folders[i].folder_name), onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')", plusSign:folders[i].folder_hasChildren});
-
-				if (folders[i].folder_parent == '')
-					folders[i].folder_parent = 'root';
-				else if (folders[i].folder_parent == 'user'){
-
-					if (!tree_folders.getNodeById('user')){
-                                                tmpFolderId = folders[i].folder_id.split(cyrus_delimiter).pop();
-						var n_root_shared_folders = new dNode({id:'user', caption:get_lang("Shared folders"), plusSign:true});
-						tree_folders.add(n_root_shared_folders,'root');
-					}
-				}
-				tree_folders.add(nn,folders[i].folder_parent);
-			}
-		}
-
-
-
-		var handlerChannel = function(data){
-			if (data == null || typeof(data) == 'string')
-				return;
-			/*
-			*  RSS NEWS
-			*/
-			var root_rss = new dNode({
-				id: "news_root",
-				caption: get_lang('News')
-			});
-			tree_folders.add(root_rss, "root");
-			for(i=0; i < data.length; i++)
-			{
-				var nodeNews = new dNode({
-					id: "NEWS/"+data[i].name,
-					caption: data[i].name,
-					onClick: "open_rss('"+data[i].rss_url+"')",
-					plusSign: 0
-				});
-				tree_folders.add(nodeNews,"news_root");
-			}
-			var noden=document.getElementById('lnews_roottree_folders');
-			noden.style.backgroundImage="url(templates/"+template+"/images/menu/rss.png)";
-			
-			
-			
-		}
-//		cExecute('$this.rss.getChannels',handlerChannel);
-
-
-		/**
-		 * Pastas locais
-		 */
-		if (preferences.use_local_messages==1 || expresso_offline) {
-			    //verifica se gears esta installado ou o offline
-			if( (!window.google || !google.gears) &&
-			     !expresso_local_messages.installGears() ){
-                                preferences.use_local_messages = 0;
-			}
-			else if( !expresso_local_messages.is_offline_installed() )
-				preferences.use_local_messages = 0;
-			else{
-				if (expresso_offline)
-					tree_folders = new dFTree({
-						name: 'tree_folders'
-					});
-				var root_local = new dNode({
-					id: "local_root",
-					caption: get_lang('local folders')
-				});
-				tree_folders.add(root_local, "root"); //coloca root local
-				var local_folders = expresso_local_messages.list_local_folders();
-				for (var i in local_folders) { //Coloca as pastas locais.
-					var node_root = "local_root";
-					var new_caption = local_folders[i][0];
-					if (local_folders[i][0].indexOf("/") != "-1") {
-						final_pos = local_folders[i][0].lastIndexOf("/");
-						node_root = "local_" + local_folders[i][0].substr(0, final_pos);
-						new_caption = local_folders[i][0].substr(final_pos + 1);
-					}
-					if (local_folders[i][1] > 0)
-						var nodeLocal = new dNode({
-							id: "local_" + local_folders[i][0],
-							caption: lang_folder(new_caption) + '<font style=color:red>&nbsp(</font><span id="local_unseen" style=color:red>' + local_folders[i][1] + '</span><font style=color:red>)</font>',
-							onClick: "change_folder('local_" + local_folders[i][0] + "','" + new_caption + "')",
-							plusSign: local_folders[i][2]
-						});
-					else
-						var nodeLocal = new dNode({
-							id: "local_" + local_folders[i][0],
-							caption: lang_folder(new_caption),
-							onClick: "change_folder('local_" + local_folders[i][0] + "','" + new_caption + "')",
-							plusSign: local_folders[i][2]
-						});
-						tree_folders.add(nodeLocal, node_root);
-					}
-				}
-			}
-
-		/*tree_folders.draw(Element('content_folders'));
-		if (!expresso_offline) {
-			n_root.changeState();
-			tree_folders.getNodeById('INBOX')._select();
-		}
-		else {
-			root_local.changeState();
-			tree_folders.getNodeById('local_Inbox')._select();
-		}*/
-		
-		var trash_span = document.getElementById(mount_url_folder(["lINBOX",special_folders["Trash"]])  + 'tree_folders'); 
-		var draft_span = document.getElementById(mount_url_folder(["lINBOX",special_folders["Drafts"]]) + 'tree_folders'); 
-		var sent_span  = document.getElementById(mount_url_folder(["lINBOX",special_folders["Sent"]]) + 'tree_folders'); 
-		var spam_span  = document.getElementById(mount_url_folder(["lINBOX",special_folders["Spam"]]) + 'tree_folders');
-		//local folders
-		var sent_local_conf = this.preferences.save_in_folder.replace(mount_url_folder(["INBOX",""]),"local_");
-		var sent_local_conf_span=document.getElementById('l'+sent_local_conf+'tree_folders');
-		var trash_local_span=document.getElementById('llocal_'+special_folders['Trash']+'tree_folders');
-		var draft_local_span=document.getElementById('llocal_'+special_folders['Drafts']+'tree_folders');
-		var sent_span_default=document.getElementById('llocal_'+special_folders['Sent']+'tree_folders');
-
-
-		if (trash_span)
-			trash_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_trash.png)";
-
-		if (draft_span)
-			draft_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_draft.png)"
-
-		if (sent_span)
-			sent_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";
-		if (spam_span)
-			spam_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_spam.png)";
-
-		if (sent_span_default)
-			sent_span_default.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";
-		//Local folders
-
-		if (sent_local_conf_span)
-			sent_local_conf_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";
-		if (trash_local_span)
-			trash_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_trash.png)";
-		if (draft_local_span)
-			draft_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_draft.png)"
-		if (sent_span_default)
-			sent_span_default.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";
-
-
-		draw_paging(Element('tot_m').innerHTML);
-		if(document.getElementById(mount_url_folder(["nINBOX",special_folders["Trash"]])+"tree_folders"))
-		{
-			var trash = document.createElement("SPAN");
-			trash.id = 'empty_trash';
-			trash.className = 'clean_folder';
-			trash.style.cursor = 'pointer';
-			trash.onclick = function () {empty_trash_imap();};
-			trash.innerHTML = "["+get_lang("Clean")+"]";
-			trash.title=get_lang("Empty trash");
-			trash.onmouseover = function() {trash.style.color="red";};
-			trash.onmouseout= function() {trash.style.color="#666666";};
-			document.getElementById(mount_url_folder(["nINBOX",special_folders["Trash"]])+"tree_folders").appendChild(trash);
-		}
-		if(document.getElementById(mount_url_folder(["nINBOX",special_folders["Spam"]])+"tree_folders"))
-		{
-						var spam = document.createElement("SPAN");
-						spam.id = 'empty_spam';
-						spam.className = 'clean_folder';
-						spam.style.cursor = 'pointer';
-						spam.style.padding = '0 0 0 6px';
-						spam.onclick = function () {empty_spam_imap();};
-						spam.innerHTML = "["+get_lang("Clean")+"]";
-						spam.title=get_lang("Empty Spam Folder");
-						spam.onmouseover = function() {spam.style.color="red";};
-						spam.onmouseout= function() {spam.style.color="#666666";};
-						document.getElementById(mount_url_folder(["nINBOX",special_folders["Spam"]])+"tree_folders").appendChild(spam);
-			   }
-
-		if(!expresso_offline)
-			var display_unseen_in_mailbox = tree_folders.getNodeById( 'root' );
-		else
-			var display_unseen_in_mailbox = tree_folders.getNodeById( 'local_root' );
-		display_unseen_in_mailbox.alter({caption:get_lang("My Folders")});
-		display_unseen_in_mailbox._refresh();
-
-		var display_unseen_in_shared_folders = tree_folders.getNodeById( 'user' );
-		if ( display_unseen_in_shared_folders )
-		{
-			if ( unseen_in_shared_folders )
-				display_unseen_in_shared_folders.alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">' + unseen_in_shared_folders +'</span><font style=color:red>]</font> ' + get_lang("Shared folders")});
-			else
-				display_unseen_in_shared_folders.alter({caption:get_lang("Shared folders")});
-			display_unseen_in_shared_folders._refresh();
-		}
-	}
-
-	if (!expresso_offline) {
-		var folder_create = "";
-		var nm1 = "";
-		if(tree_folders._folderPr.length > 0){
-			var nm_folder = "";
-			for(var i=0; i < tree_folders._folderPr.length; i++){
-				nm_folder = tree_folders._folderPr[i].split(cyrus_delimiter);
-				if(nm_folder[0] == "INBOX"){
-					if(nm1 == ""){
-						nm1 = nm_folder[1];
-						folder_create = "INBOX" + cyrus_delimiter + nm_folder[1] + ";";
-					}else{
-						if( nm1 != nm_folder[1]){
-							folder_create += "INBOX" + cyrus_delimiter + nm_folder[1] + ";";
-							nm1 = nm_folder[1];
-						}
-					}
-				}
-			}
-		}
-	}
-	
-	outOfficeVerify();
-}
 
 function draw_tree_labels(){
@@ -489,5 +191,5 @@
 		
 		if(data) {
-			draw_tree_folders(data);
+			//draw_tree_folders(data);
 			draw_quota(data);
 			var f_unseen = Element('dftree_'+current_folder+'_unseen');
@@ -924,5 +626,5 @@
 function syncColumns() {
 	var thisCell;
-	var tbl = (document.getElementById("ui-tabs-"+numBox)==null ? 1 : 0);
+	var tbl = (document.getElementById("ptabs_"+numBox)==null ? 1 : 0);
 	if (objCell)
 		thisCell = objCell;
@@ -1230,5 +932,5 @@
 	numBox = 0; //As pastas sempre estarï¿œo na aba 0
 	
-	openTab.content_id[numBox] = document.getElementById("ui-tabs-"+numBox);
+	openTab.content_id[numBox] = document.getElementById("ptabs_"+numBox);
 	//openTab.content_id[numBox].innerHTML = "";
 	openTab.imapBox[numBox] = msg_folder;
@@ -1411,5 +1113,5 @@
 	}
 
-	_divScroll.style.overflowY = "scroll";
+	_divScroll.style.overflowY = "auto";
 	_divScroll.style.overflowX = "hidden";
 	_divScroll.style.width	="100%";
@@ -1663,5 +1365,6 @@
 			if(preferences.use_shortcuts == '1')
 				$(this).parents("tr:first").addClass("current_selected_shortcut_msg selected_shortcut_msg");
-			changeBgColor(e,headers_msgs.msg_number);
+			//changeBgColor(e,headers_msgs.msg_number);
+            $(this).parents("tr:first").toggleClass("selected_msg");
 			$(this).blur();
 		});
@@ -2186,1586 +1889,4 @@
 
 var msg_selected;
-function draw_message(info_msg, ID){
-	// remove a flag $FilteredMessage da mensagem ao ser lida
-	if(info_msg.Unseen == "U"){
-		$.each(fromRules, function(index, value) {
-			if(value == info_msg.msg_folder){
-				cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+info_msg.msg_folder+"&msg_number="+info_msg.msg_number, function(){}); 
-				return false;
-			}
-		});
-	}
-	var content = document.getElementById('content_id_' + ID);
-
-	var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
-	 //////////////////////////////////////////////////////////////////////////////////////////////////////
-	//Make the next/previous buttom.
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	var next_previous_msg_td = document.createElement("TD");
-	next_previous_msg_td.setAttribute("noWrap","true");
-	next_previous_msg_td.align = "right";
-	next_previous_msg_td.style.fontSize = "10px";
-	next_previous_msg_td.width = "40px";
-	var img_next_msg = document.createElement("IMG");
-	img_next_msg.id = 'msg_opt_next_' + ID;
-	img_next_msg.src = './templates/'+template+'/images/down.button.png';
-        if(preferences.use_shortcuts == '1')
-            img_next_msg.title = get_lang('Next Shortcut:Control + Down');
-        else
-            img_next_msg.title = get_lang('Next');
-	img_next_msg.style.cursor = 'pointer';
-
-        var folder_id = ID.match(/\d+/)[0];
-        var folder;
-
-        //Correï¿œï¿œo para fazer funcionar e-mails assinados no formato encapsulado.
-       // folder_id = info_msg.original_ID ? info_msg.original_ID: info_msg.msg_number;
-        //if ((folder = document.getElementById(info_msg.msg_number)) == null)
-	if ((folder = Element(info_msg.original_ID)) == null)
-		folder = Element(info_msg.msg_number);
-		
-
-	if (folder){ // mensagem local criptografada nao tem ID da pasta local
-		if (folder.nextSibling){
-			var nextMsgBox = folder.nextSibling.name?folder.nextSibling.name:info_msg.msg_folder;
-
-			if (nextMsgBox == "INBOX" + cyrus_delimiter + "decifradas")// teste para ver se a mensagem vem da pasta oculta decifradas
-					nextMsgBox = get_current_folder();
-
-			img_next_msg.onclick = function()
-			{
-				currentTab = ID;
-				openTab.type[ID] = 2;
-				proxy_mensagens.get_msg(folder.nextSibling.id,nextMsgBox,true,show_msg);
-				//select_msg('null', 'down', true);
-				if (!msg_selected){
-					select_msg('null', 'down', true);
-					msg_selected = true;
-				}
-			};
-		}
-		/*Ultima mensagem de cada pï¿œgina, exceto a ultima*/
-        else if( (current_page < total_pages) ){
-		   
-		   img_next_msg.onclick = function()
-			{
-
-			   current_page++;
-			   var tot_msgs = parseInt(Element("tot_m").innerHTML);
-			   var range_begin = preferences.max_email_per_page*( current_page - 1 ) + 1;
-			   var range_end; 
-			   if ( range_begin + parseInt(preferences.max_email_per_page - 1) > tot_msgs ) 
-			        range_end = tot_msgs;
-			   else     
-			        range_end = range_begin + parseInt(preferences.max_email_per_page  - 1);  
-			   var creatBoxProximo = function (data){
-					    draw_box(data, get_current_folder());
-					    firstRow();
-			        };      			  
-		       proxy_mensagens.messages_list(get_current_folder(),range_begin,range_end,sort_box_type,search_box_type,sort_box_reverse,'','', creatBoxProximo);
-			
-			};	   
-		}
-		else
-		{
-			img_next_msg.src = "./templates/"+template+"/images/down.gray.button.png";
-			img_next_msg.style.cursor = 'default';
-
-		}
-	}
-	else
-	{
-		img_next_msg.src = "./templates/"+template+"/images/down.gray.button.png";
-		img_next_msg.style.cursor = 'default';
-		// testa se a mensagem e local 
- 	    if (!proxy_mensagens.is_local_folder(get_current_folder()) && !(info_msg.msg_folder == "INBOX" + cyrus_delimiter + "decifradas")) // testa se a mensagem e local
-		{
-			img_next_msg.onclick = function()
-				{
-					delete_border(ID);
-				};
-		}
-	}
-	var img_space = document.createElement("SPAN");
-	img_space.innerHTML = "&nbsp;";
-	var img_previous_msg = document.createElement("IMG");
-	img_previous_msg.id = 'msg_opt_previous_' + ID;
-	img_previous_msg.src = './templates/'+template+'/images/up.button.png';
-        if(preferences.use_shortcuts == '1')
-            img_previous_msg.title = get_lang('Previous Shortcut:Control + Up');
-        else
-            img_previous_msg.title = get_lang('Previous');
-	img_previous_msg.style.cursor = 'pointer';
-
-
-	if (folder){ // mensagem local criptografada nao tem ID da pasta local
-		if (folder.previousSibling)
-		{
-			var previousMsgBox = folder.previousSibling.name?folder.previousSibling.name:info_msg.msg_folder;
-
-			if (previousMsgBox == "INBOX" + cyrus_delimiter + "decifradas") // teste para ver se a mensagem vem da pasta oculta decifradas
-					previousMsgBox = get_current_folder();
-
-			img_previous_msg.onclick = function()
-			{
-				currentTab = ID;
-				openTab.type[ID] = 2;
-				proxy_mensagens.get_msg(folder.previousSibling.id,previousMsgBox,true,show_msg);
-				//select_msg('null', 'up', false);
-				if (!msg_selected){
-					select_msg('null', 'up', true);
-					msg_selected = true;
-				}
-			};
-		}
-		//primeira mensagem de cada pï¿œgina, exceto a primeira
-		else if(current_page > 1){
-		      
-		      img_previous_msg.onclick = function()
-		      {
-			     
-			     current_page--;
-			     var range_begin = (current_page - 1)*preferences.max_email_per_page + 1; 
-			     var range_end = current_page*preferences.max_email_per_page;         			     
-			     var creatBoxAnterior = function (data){
-				    	  draw_box(data, get_current_folder());
-					      lastRow();
-					 };      			  
-		         proxy_mensagens.messages_list(get_current_folder(),range_begin,range_end,sort_box_type,search_box_type,sort_box_reverse,'','', creatBoxAnterior);	         
-	          };
-	    }
-		else
-		{
-			img_previous_msg.src = "./templates/"+template+"/images/up.gray.button.png";
-			img_previous_msg.style.cursor = 'default';
-		}
-	}
-	else
-	{
-		img_previous_msg.src = "./templates/"+template+"/images/up.gray.button.png";
-		img_previous_msg.style.cursor = 'default';
-		// testa se a mensagem e local 
- 	    if (!proxy_mensagens.is_local_folder(get_current_folder()) && !(info_msg.msg_folder == "INBOX" + cyrus_delimiter + "decifradas")) // testa se a mensagem e local
-		{
-			img_previous_msg.onclick = function()
-			{
-				delete_border(ID);
-			};
-		}
-	}
-	next_previous_msg_td.appendChild(img_previous_msg);
-	next_previous_msg_td.appendChild(img_space);
-	next_previous_msg_td.appendChild(img_next_msg);
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	//Make the header message.
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	var table_message = document.createElement("TABLE");
-	var tbody_message = document.createElement("TBODY");
-	table_message.border = "0";
-	//table_message.width = "100%";
-	//k!
-	table_message.setAttribute("class", "expressomail-message-body");
-	table_message.setAttribute("className", "expressomail-message-body");
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	//Make the options message.
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	var tr0 = document.createElement("TR");
-	tr0.className = "tr_message_header";
-	var td0 = document.createElement("TD");
-	var table_message_options = document.createElement("TABLE");
-	table_message_options.width = "100%";
-	table_message_options.border = '0';
-	table_message_options.className = 'table_message';
-	var tbody_message_options = document.createElement("TBODY");
-	var tr = document.createElement("TR");
-	var td = document.createElement("TD");
-	td.setAttribute("noWrap","true");
-	td.style.fontSize = "10px";
-	var _name = '';
-	var _maxChar = menuHidden ? 40 : 15;
-
-	if (info_msg.from.name)
-	{
-		var spanName = document.createElement("SPAN");
-			spanName.innerHTML = info_msg.from.name;
-		_name = spanName.innerHTML.length > _maxChar ? spanName.innerHTML.substring(0,_maxChar) + "..." : spanName.innerHTML;
-	}
-	else
-		_name = info_msg.from.email.length > _maxChar ? info_msg.from.email.substring(0,_maxChar) + "..." : info_msg.from.email;
-
-	td.innerHTML = _name.bold() + ', ' + info_msg.smalldate;
-	//k!
-	if (info_msg.attachments && info_msg.attachments.length > 0)
-		td.innerHTML += "&nbsp<img style='cursor:pointer' onclick='javascript:Element(\"option_hide_more_"+ID+"\").onclick()' src ='templates/"+template+"/images/clip.gif' title='"+info_msg.attachments[0].name+"'>";
-
-	if (typeof(info_msg.signature) == 'string')
-	{
-		if (info_msg.signature != "void")
-			td.innerHTML += '&nbsp;<img style="cursor:pointer" onclick="alert(\''+ get_lang("This message is signed, and you can trust.") + info_msg.signature +'\');" src="templates/'+template+'/images/signed.gif">';
-		else
-			td.innerHTML += "&nbsp;<img style='cursor:pointer' onclick='alert(\""+get_lang("This message is signed, but it is invalid. You should not trust on it.")+"\");' title='"+get_lang("Voided message")+"' src='templates/"+template+"/images/invalid.gif'>";
-	}
-
-	if (info_msg.DispositionNotificationTo)
-	{
-		td.innerHTML += '&nbsp;<img id="disposition_notification_'+ID+'" style="cursor:pointer" alt="'+ get_lang('Message with read notification') + '" title="'+ get_lang('Message with read notification') + '" src="templates/'+template+'/images/notification.gif">';
-	}
-
-	if (info_msg.Flagged == 'F')
-	{
-		td.innerHTML += '&nbsp;<img id="disposition_important_'+ID+'" style="cursor:pointer" alt="'+ get_lang('Important message') + '" title="'+ get_lang('Important message') + '" src="templates/'+template+'/images/important.png">';
-	}
-	// NORMAL MSG
-	if(info_msg.Draft != 'X')
-	{
-	var options = document.createElement("TD");
-	options.width = "30%";
-	options.setAttribute("noWrap","true");
-	options.style.fontSize = "10px";
-		
-		//BEGIN: DESENHA MOSTRA DETALHES, OCULTAR DETALHES
-	var option_hide_more = document.createElement("SPAN");
-	option_hide_more.className = 'message_options';
-        option_hide_more.onmouseover=function () {this.className='message_options_active';};
-        option_hide_more.onmouseout=function () {this.className='message_options'};
-	options.align = 'right';
-	option_hide_more.value = 'more_options';
-	option_hide_more.id = 'option_hide_more_'+ID;
-	option_hide_more.onclick = function(){
-		if (this.value == 'more_options'){
-			this.innerHTML = "<b><u>"+get_lang('Hide details')+"</u></b>";
-			this.value = 'hide_options';
-			Element('table_message_others_options_'+ID).style.display = '';
-		}
-		else{
-			this.innerHTML = get_lang('Show details');
-			this.value = 'more_options';
-			Element('table_message_others_options_'+ID).style.display = 'none';
-		}
-		resizeWindow();
-	};
-		//END: DESENHA MOSTRA DETALHES, OCULTAR DETALHES
-		
-		//OPCAO PARA MARCAR COMO
-		var option_mark_as = document.createElement("SPAN");
-		option_mark_as.innerHTML = "<b>"+get_lang('Mark as')+"</b>";
-		option_mark_as.className = 'message_options';
-		option_mark_as.onmouseover=function () {this.className='message_options_active';};
-		option_mark_as.onmouseout=function () {this.className='message_options'};
-		option_mark_as.onclick = function(){
-			verifyOption('tr_other_mark_options_', ID);
-			var thi = document.getElementById('msg_opt_mark_options_'+ID);
-			if (thi.value != 'hide'){
-				thi.value = 'hide';
-				option_mark_as_options.src= '../expressoMail1_2/templates/default/images/pressed.png';
-				Element('tr_other_mark_options_'+ID).style.display = '';
-
-			}
-			else{
-				thi.value = 'show';
-				option_mark_as_options.src= '../expressoMail1_2/templates/default/images/down.png';
-				Element('tr_other_mark_options_'+ID).style.display = 'none';
-			}
-		};
-		//DESENHA OPCOES DO MARCAR COMO
-	var option_mark_as_unseen = document.createElement("SPAN");
-		option_mark_as_unseen.className = "reply_options";
-	option_mark_as_unseen.onclick = function () {changeLinkState(this,'seen');
-		proxy_mensagens.proxy_set_message_flag(folder_id,'unseen');
-		write_msg(get_lang('Message marked as ')+get_lang("Unseen"));
-	};
-		option_mark_as_unseen.onmouseover=function () {this.className='reply_options_active'};
-		option_mark_as_unseen.onmouseout=function () {this.className='reply_options'};
-	option_mark_as_unseen.innerHTML = get_lang("Unseen");
-
-	var option_mark_important = document.createElement("SPAN");
-		option_mark_important.className = 'reply_options';		
-		option_mark_important.onmouseover=function () {this.className='reply_options_active';};
-		option_mark_important.onmouseout=function () {this.className='reply_options'};
-
-	if (info_msg.Flagged == "F"){
-		option_mark_important.onclick = function() {
-			var _this = this;
-			proxy_mensagens.proxy_set_message_flag(folder_id,'unflagged', function(success){
-				if (success) {
-					changeLinkState(_this, 'important');
-					write_msg(get_lang('Message marked as ') + get_lang("Normal"));
-				}
-			} );
-
-		};
-		option_mark_important.innerHTML = get_lang("Normal");
-	}
-	else{
-		option_mark_important.onclick = function() {changeLinkState(this,'normal');
-			proxy_mensagens.proxy_set_message_flag(folder_id,'flagged');
-			write_msg(get_lang('Message marked as ')+get_lang("Important"));
-		};
-		option_mark_important.innerHTML = get_lang("Important");
-	}
-		//option_mark.appendChild(option_mark_as_unseen);
-		//option_mark.appendChild(option_mark_important);
-
-		
-	option_hide_more.innerHTML = get_lang('Show details');
-		option_hide_more.title = (preferences.use_shortcuts == '1') ? get_lang('Shortcut: %1', 'O') : get_lang('Show details');
-	
-		var space3 = document.createElement("SPAN");
-		space3.innerHTML = '&nbsp;|&nbsp;';
-		
-		var option_mark_as_options = document.createElement('IMG');
-		option_mark_as_options.id = 'msg_opt_mark_options_'+ID;
-		option_mark_as_options.src = '../expressoMail1_2/templates/default/images/down.png';
-		option_mark_as_options.value = 'show';
-
-		option_mark_as_options.onmouseover = function(){
-			option_mark_as_options.src= '../expressoMail1_2/templates/default/images/over.png';
-			option_mark_as.className = 'message_options_active';
-		};
-		option_mark_as_options.onmouseout = function(){
-			option_mark_as.className = 'message_options';
-			if (this.value == 'show')
-			{
-				option_mark_as_options.src= '../expressoMail1_2/templates/default/images/down.png';
-			}
-			else
-			{
-				option_mark_as_options.src= '../expressoMail1_2/templates/default/images/pressed.png';
-			}
-		};
-		option_mark_as_options.onclick = function(){
-			verifyOption('tr_other_mark_options_', ID);
-			if (this.value != 'hide'){
-				this.value = 'hide';
-				option_mark_as_options.src= '../expressoMail1_2/templates/default/images/pressed.png';
-				Element('tr_other_mark_options_'+ID).style.display = '';
-
-			}
-			else{
-				this.value = 'show';
-				option_mark_as_options.src= '../expressoMail1_2/templates/default/images/down.png';
-				Element('tr_other_mark_options_'+ID).style.display = 'none';
-			}
-		};
-		
-	options.appendChild(option_hide_more);
-		options.appendChild(space3);
-		options.appendChild(option_mark_as_options);				
-		options.appendChild(option_mark_as);
-		//FIM OPCAO PARA MARCAR COMO
-
-	var space0 = document.createElement("SPAN");
-	space0.innerHTML = '&nbsp;|&nbsp;';
-	var space1 = document.createElement("SPAN");
-	space1.innerHTML = '&nbsp;|&nbsp;';
-	var space2 = document.createElement("SPAN");
-	space2.innerHTML = '&nbsp;|&nbsp;';
-
-		//OPCAO PARA MAIS ACOES
-		var option_more = document.createElement("SPAN");
-		option_more.id = 'msg_opt_more_actions_'+ID;
-		option_more.className = 'message_options';
-		//option_more.onclick = function(){new_message('forward', ID);};
-		option_more.onmouseover=function () {this.className='message_options_active';};
-        option_more.onmouseout=function () {this.className='message_options'};
-		option_more.onclick = function(){
-			verifyOption('tr_other_more_options_', ID);
-			if (option_more_options.value != 'hide'){
-				option_more_options.value = 'hide';
-				option_more_options.src= '../expressoMail1_2/templates/default/images/pressed.png';
-				Element('tr_other_more_options_'+ID).style.display = '';
-
-			}
-			else{
-				option_more_options.value = 'show';
-				option_more_options.src= '../expressoMail1_2/templates/default/images/down.png';
-				Element('tr_other_more_options_'+ID).style.display = 'none';
-			}
-		};
-		option_more.innerHTML = get_lang('More Actions');
-		
-		//CRIA IMG DE MAIS ACOES
-		var option_more_options = document.createElement('IMG');
-		option_more_options.id = 'msg_opt_more_options_'+ID;
-		option_more_options.src = '../expressoMail1_2/templates/default/images/down.png';
-		option_more_options.value = 'show';
-
-		option_more_options.onmouseover = function(){
-			option_more.className = 'message_options_active';
-			option_more_options.src= '../expressoMail1_2/templates/default/images/over.png';
-		};
-		option_more_options.onmouseout = function(){
-			option_more.className = 'message_options';
-			if (this.value == 'show')
-			{
-				option_more_options.src= '../expressoMail1_2/templates/default/images/down.png';
-			}
-			else
-			{
-				option_more_options.src= '../expressoMail1_2/templates/default/images/pressed.png';
-			}
-		};
-		option_more_options.onclick = function(){
-			verifyOption('tr_other_more_options_',ID);
-			
-			if (this.value != 'hide'){
-				this.value = 'hide';
-				option_more_options.src= '../expressoMail1_2/templates/default/images/pressed.png';
-				Element('tr_other_more_options_'+ID).style.display = '';
-
-			}
-			else{
-				this.value = 'show';
-				option_more_options.src= '../expressoMail1_2/templates/default/images/down.png';
-				Element('tr_other_more_options_'+ID).style.display = 'none';
-			}
-		};
-	options.appendChild(space1);
-		options.appendChild(option_more_options);
-		options.appendChild(option_more);
-		//FIM OPCAO PARA MAIS ACOES
-		
-		//OPCAO PARA RESPONDER
-	var option_reply = document.createElement("SPAN");
-	option_reply.id = 'msg_opt_reply_'+ID;
-	option_reply.className = 'message_options';
-	option_reply.onclick = function(){new_message('reply_with_history', ID);};
-	option_reply.innerHTML = get_lang('Reply');
-	option_reply.onmouseover=function () {this.className='message_options_active';};
-	option_reply.onmouseout=function () {this.className='message_options'};
-		option_reply.title = (preferences.use_shortcuts == '1') ? get_lang('Shortcut: %1', 'R') : get_lang('Reply');
-
-	options.appendChild(space2);
-
-	var option_reply_options = document.createElement('IMG');
-	option_reply_options.id = 'msg_opt_reply_options_'+ID;
-	option_reply_options.src = '../expressoMail1_2/templates/default/images/down.png';
-	option_reply_options.value = 'show';
-
-	option_reply_options.onmouseover = function(){
-		option_reply_options.src= '../expressoMail1_2/templates/default/images/over.png';
-	};
-	option_reply_options.onmouseout = function(){
-		if (this.value == 'show')
-		{
-			option_reply_options.src= '../expressoMail1_2/templates/default/images/down.png';
-		}
-		else
-		{
-			option_reply_options.src= '../expressoMail1_2/templates/default/images/pressed.png';
-		}
-	};
-	option_reply_options.onclick = function(){
-			verifyOption('tr_other_options_', ID);
-		if (this.value != 'hide'){
-			this.value = 'hide';
-			option_reply_options.src= '../expressoMail1_2/templates/default/images/pressed.png';
-			Element('tr_other_options_'+ID).style.display = '';
-
-		}
-		else{
-			this.value = 'show';
-			option_reply_options.src= '../expressoMail1_2/templates/default/images/down.png';
-			Element('tr_other_options_'+ID).style.display = 'none';
-		}
-	};
-	options.appendChild(option_reply_options);
-	options.appendChild(option_reply);
-		//FIM OPCAO PARA RESPONDER
-		
-		//OPCAO PARA ENCAMINHAR
-		var option_forward = document.createElement("SPAN");
-		option_forward.id = 'msg_opt_forward_'+ID;
-		option_forward.className = 'message_options';
-		option_forward.innerHTML = get_lang('Forward');
-		option_forward.onclick = function(){new_message('forward', ID);};
-		option_forward.onmouseover=function () {this.className='message_options_active';};
-        option_forward.onmouseout=function () {this.className='message_options'};
-		option_forward.title = (preferences.use_shortcuts == '1') ? get_lang('Shortcut: %1', 'E') : get_lang('Forward');
-		
-		var space9 = document.createElement("SPAN");
-		space9.innerHTML = '&nbsp;|&nbsp;';
-		
-		options.appendChild(space9);
-		options.appendChild(option_forward);
-		//FIM DA OPCAO PARA ENCAMINHAR
-		
-		//OPCAO PARA DELETAR
-		var option_delete = document.createElement("SPAN");
-		option_delete.id = 'msg_opt_delete_'+ID;
-		option_delete.className = 'message_options';
-		option_delete.onclick = function(){proxy_mensagens.delete_msgs('null','selected','null');};
-		option_delete.innerHTML = get_lang('Delete');
-		option_delete.onmouseover=function () {this.className='message_options_active';};
-		option_delete.onmouseout=function () {this.className='message_options'};
-		option_delete.title = (preferences.use_shortcuts == '1') ? get_lang('Shortcut: %1', 'Delete') : get_lang('Delete');
-
-		var space6 = document.createElement("SPAN");
-		space6.innerHTML = '&nbsp;|&nbsp;';
-		
-		options.appendChild(space6);
-		options.appendChild(option_delete);
-		//FIM OPCAO PARA DELETAR
-
-	tr.appendChild(td);
-		//tr.appendChild(option_mark);
-	tr.appendChild(options);
-	tr.appendChild(next_previous_msg_td);
-	tbody_message_options.appendChild(tr);
-
-	////////// OTHER OPTIONS ////////////////////
-	var tr_other_options = document.createElement("TR");
-		var tr_other_mark_options = document.createElement("TR");
-		var tr_other_more_options = document.createElement("TR");
-		
-		tr_other_mark_options.id = 'tr_other_mark_options_' + ID;
-		tr_other_mark_options.style.display = 'none';
-		tr_other_mark_options.style.backgroundColor = '#205C8E';
-	tr_other_options.id = 'tr_other_options_' + ID;
-	tr_other_options.style.display = 'none';
-		tr_other_options.style.backgroundColor = '#205C8E';
-		tr_other_more_options.id = 'tr_other_more_options_' + ID;
-		tr_other_more_options.style.display = 'none';
-		tr_other_more_options.style.backgroundColor = '#205C8E';		
-
-	var td_other_options = document.createElement("TD");
-		var td_other_mark_options = document.createElement("TD");
-		var td_other_more_options = document.createElement("TD");
-		
-	td_other_options.colSpan = '3';
-		td_other_mark_options.colSpan = '3';
-		td_other_more_options.colSpan = '3';
-
-	var div_other_options = document.createElement("DIV");
-		var div_other_mark_options = document.createElement("DIV");
-		var div_other_more_options = document.createElement("DIV");
-
-		//var option_mark_as_unseen = '<span class="message_options" onclick="proxy_mensagens.proxy_set_messages_flag(\'unseen\','+info_msg.msg_number+');write_msg(\''+get_lang('Message marked as ')+get_lang("Unseen")+'.\');">'+get_lang("Unseen")+'</span>, ';
-		//var option_mark_as_important			= '<span class="message_options" onclick="proxy_mensagens.proxy_set_messages_flag(\'flagged\','+info_msg.msg_number+');write_msg(\''+get_lang('Message marked as ')+get_lang("Important")+'.\');">'+get_lang("Important")+'</span>, ';
-		//var option_mark_as_normal				= '<span class="message_options" onclick="proxy_mensagens.proxy_set_messages_flag(\'unflagged\','+info_msg.msg_number+');write_msg(\''+get_lang('Message marked as ')+get_lang("Normal")+'.\');">'+get_lang("Normal")+'</span> | ';
-		var block_user = '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick ="block_user_email(\''+info_msg.from.email+'\');">'+get_lang("Block Sender")+'</span> | ';	
-		//var option_forward = '<span onclick="new_message(\'forward\',\''+ ID+'\');" onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options">'+get_lang("Forward")+'</span> | ';
-		var option_move	= '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=wfolders.makeWindow("'+ID+'","move_to");>'+get_lang("Move")+'</span> | ';
-		var option_print = '<span onclick="print_all()" onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options">'+get_lang("Print")+'</span> | ';
-		var option_export = '<span onclick="proxy_mensagens.export_all_messages()" onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options">'+get_lang("Export")+'</span> | ';
-
-		option_reply_to_all__title = (preferences.use_shortcuts == '1') ? get_lang('Shortcut: %1', 'T') : '';
-		var option_reply_to_all = '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick="new_message(\'reply_to_all_with_history\',\''+ID+'\');" title="'+option_reply_to_all__title+'">'+get_lang("Reply to all")+'</span> | ';
-	var option_reply_without_history = '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=new_message("reply_without_history","'+ID+'");>'+get_lang("Reply without history")+'</span> | ';
-		var option_reply_to_all_without_history	= '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=new_message("reply_to_all_without_history","'+ID+'");>'+get_lang("Reply to all without history")+'</span>  | ';
-
-		var report_error        = '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=reports_window("'+currentTab+'");>'+get_lang("Report error")+'</span> | '; 
-
-		div_other_more_options.innerHTML += option_move + option_print + option_export + block_user +  report_error;
-		
-		div_other_options.innerHTML += option_reply_without_history + option_reply_to_all_without_history + option_reply_to_all;
-	if (use_spam_filter) {
-			if(info_msg.msg_folder == 'INBOX'+cyrus_delimiter+'Spam' || (info_msg.msg_folder.match(/^user/) && info_msg.msg_folder.match(/Spam$/))){
-				div_other_mark_options.innerHTML += '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick="nospam('+info_msg.msg_number+',\'null\', \''+info_msg.msg_folder+'\');">'+get_lang("Not Spam")+'</span> | ';
-	}
-			else{
-				div_other_mark_options.innerHTML += '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick="spam(\''+info_msg.msg_folder+'\', '+info_msg.msg_number+',\'null\');">'+get_lang("Is Spam")+'</span> | ';
-			}
-		}
-		var space5 = document.createElement("SPAN");
-		space5.innerHTML = '&nbsp;|&nbsp;';
-	
-		div_other_mark_options.appendChild(option_mark_as_unseen);
-		var space4 = document.createElement("SPAN");
-		space4.innerHTML = '&nbsp;|&nbsp;';
-		div_other_mark_options.appendChild(space4);
-		div_other_mark_options.appendChild(option_mark_important); 
-		var space7 = document.createElement("SPAN");
-		space7.innerHTML = '&nbsp;|&nbsp;';
-		div_other_mark_options.appendChild(space7);
-	
-	td_other_options.align = 'right';
-	td_other_options.style.paddingTop = '3px';
-	td_other_options.appendChild(div_other_options);
-
-		td_other_mark_options.align = 'right';
-		td_other_mark_options.style.paddingTop = '3px';
-		td_other_mark_options.appendChild(div_other_mark_options);
-		
-		td_other_more_options.align = 'right';
-		td_other_more_options.style.paddingTop = '3px';
-		td_other_more_options.appendChild(div_other_more_options);
-
-
-	tr_other_options.appendChild(td_other_options);
-	tbody_message_options.appendChild(tr_other_options);
-		
-		tr_other_more_options.appendChild(td_other_more_options);
-		tbody_message_options.appendChild(tr_other_more_options);
-		
-		tr_other_mark_options.appendChild(td_other_mark_options);
-		tbody_message_options.appendChild(tr_other_mark_options);
-	////////// END OTHER OPTIONS ////////////////
-
-		////////// BEGIN SIGNATURE //////////////////
-	if (info_msg.signature && info_msg.signature.length > 0)
-	{
-            var tr_signature = document.createElement("TR");
-            var td_signature = document.createElement("TD");
-            td_signature.className = 'tr_message_header';
-            tr_signature.id = 'tr_signature_'+ID;
-            td_signature.colSpan = "5";
-            tr_signature.style.display = 'none';
-            for (i in info_msg.signature)
-                {
-                    if(typeof(info_msg.signature[i]) == 'object')
-                        {
-                            var aux = '';
-                            for (ii in info_msg.signature[i])
-                                {
-                                    if(info_msg.signature[i][ii].indexOf("###") > -1)
-                                        {
-                                         aux += get_lang(info_msg.signature[i][ii].substring(0,info_msg.signature[i][ii].indexOf("###"))) + info_msg.signature[i][ii].substring(info_msg.signature[i][ii].indexOf("###")+3);
-                                        }
-                                    else
-                                        {
-                                         aux += info_msg.signature[i][ii];
-                                        }
-                                }
-                            td_signature.innerHTML += "<a onclick=\"javascript:alert('" + aux + "')\"><b><font color=\"#0000FF\">" + get_lang("More") + "...</font></b></a>";
-                            continue;
-                        }
-                    if(info_msg.signature[i].indexOf("#@#") > -1)
-                        {
-                         td_signature.innerHTML += '<span style=color:red><strong>'+get_lang(info_msg.signature[i].substring(0,info_msg.signature[i].indexOf("#@#")))+'</strong> '+info_msg.signature[i].substring(info_msg.signature[i].indexOf("#@#")+3)+'</span> <br /> ';
-                        }
-                            if(info_msg.signature[i].indexOf("###") > -1)
-                                {
-                                    td_signature.innerHTML += '<span><strong>'+get_lang(info_msg.signature[i].substring(0,info_msg.signature[i].indexOf("###")))+'</strong> '+info_msg.signature[i].substring(info_msg.signature[i].indexOf("###")+3)+'</span> <br /> ';
-                                }
-                }
-            var signature_status_pos = info_msg.signature[0].indexOf('Message untouched');
-            td_signature.id = "td_signature_"+ID;
-            if(signature_status_pos < 0 )
-                {
-                    td.innerHTML += '&nbsp;<img style="cursor:pointer" src="templates/'+template+'/images/signed_error.gif" title="'+get_lang("Details")+'">';
-                    tr_signature.style.display = '';
-                }
-            else
-                {
-                    td.innerHTML += '&nbsp;<img style="cursor:pointer" src="templates/'+template+'/images/signed_table.gif" title="'+get_lang("Details")+'">';
-                }
-            td.onclick = function(){
-            var _height = Element("div_message_scroll_"+ID).style.height;
-            _height = parseInt(_height.replace("px",""));
-            var _offset = 130;
-            if (this.value == 'more_cert'){
-                this.value = 'hide_cert';
-                Element("div_message_scroll_"+ID).style.height = (_height + _offset)+"px";
-                Element('tr_signature_'+ID).style.display = 'none';
-                Element('td_signature_'+ID).style.display = 'none';
-
-            }
-            else{
-                this.value = 'more_cert';
-                Element("div_message_scroll_"+ID).style.height = (_height - _offset)+"px";
-                Element('tr_signature_'+ID).style.display = '';
-                Element('td_signature_'+ID).style.display = '';
-            }
-	};
-
-            tr_signature.appendChild(td_signature);
-            tbody_message_options.appendChild(tr_signature);
-	}
-	//////////// END SIGNATURE ////////////////
-
-	table_message_options.appendChild(tbody_message_options);
-	td0.appendChild(table_message_options);
-	tr0.appendChild(td0);
-	tbody_message.appendChild(tr0);
-	}
-	// IF DRAFT
-	else
-	{
-		var options = document.createElement("TD");
-		//options.width = "1%";
-		options.setAttribute("noWrap","true");
-		var option_edit	  = ' | <span class="message_options" onclick="new_message(\'edit\',\''+ID+'\');">'+get_lang('Edit')+'</span>';
-		var option_print = ' | <span class="message_options" onclick="print_msg(\''+info_msg.msg_folder+'\',\''+info_msg.msg_number+'\',\''+ID+'\');">'+get_lang('Print')+'</span>';
-		var option_hide_more = document.createElement("SPAN");
-		option_hide_more.className = 'message_options';
-		options.align = 'right';
-		option_hide_more.value = 'more_options';
-		option_hide_more.id = 'option_hide_more_'+ID;
-		option_hide_more.innerHTML = get_lang('Show details');
-		option_hide_more.onclick = function(){
-			var _height = Element("div_message_scroll_"+ID).style.height;
-			_height = parseInt(_height.replace("px",""));
-			var _offset = 35;
-			if (this.value == 'more_options'){
-				this.innerHTML = "<b><u>"+get_lang('Hide details')+"</u></b>";
-				this.value = 'hide_options';
-				Element("div_message_scroll_"+ID).style.height = (_height - _offset)+"px";
-				Element('table_message_others_options_'+ID).style.display = '';
-			}
-			else{
-				this.innerHTML = get_lang('Show details');
-				this.value = 'more_options';
-				Element("div_message_scroll_"+ID).style.height = (_height + _offset)+"px";
-				Element('table_message_others_options_'+ID).style.display = 'none';
-			}
-		};
-		options.appendChild(option_hide_more);
-		options_actions = document.createElement('SPAN');
-		options_actions.innerHTML = option_edit + option_print;
-		options.appendChild(options_actions);
-		tr.appendChild(td);
-		tr.appendChild(options);
-		tr.appendChild(next_previous_msg_td);
-		tbody_message_options.appendChild(tr);
-		table_message_options.appendChild(tbody_message_options);
-		td0.appendChild(table_message_options);
-		tr0.appendChild(td0);
-		tbody_message.appendChild(tr0);
-
-		var important_message = document.createElement("INPUT");
-		important_message.id = "is_important_"+ID;
-		important_message.name = "is_important";
-		important_message.type = "HIDDEN";
-		important_message.value = (info_msg.Importance == "" || info_msg.Importance == "Normal") ? "0": "1";
-
-		options.appendChild(important_message);
-	}
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	// END options message.
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-
-	var table_message_others_options = document.createElement("TABLE");
-	table_message_others_options.id = 'table_message_others_options_' + ID;
-	table_message_others_options.width = "100%";
-	table_message_others_options.style.display = 'none';
-	if(navigator.appName.indexOf('Internet Explorer')>0){
-		table_message_others_options.className = "table_message_options_ie";
-	}else{
-		table_message_others_options.className = "table_message_options";
-	}
-	
-	var tbody_message_others_options = document.createElement("TBODY");
-	var tr1 = document.createElement("TR");
-	tr1.className = "tr_message_header";
-	var td1 = document.createElement("TD");
-	td1.innerHTML = get_lang("From: ");
-	td1.appendChild(deny_email(info_msg.from.email));
-	td1.width = "7%";
-
-	if (info_msg.sender){
-		var tr111 = document.createElement("TR");
-		tr111.className = "tr_message_header";
-		var td111 = document.createElement("TD");
-		td111.innerHTML = get_lang("Sent by")+": ";
-		td111.appendChild(deny_email(info_msg.sender.email));
-		td111.setAttribute("noWrap","true");
-		var sender = document.createElement("TD");
-		sender.id = "sender_"+ID;
-		var sender_values = document.createElement("INPUT");
-		sender_values.id = "sender_values_"+ID;
-		sender_values.type = "HIDDEN";
-		sender_values.value = info_msg.sender.full; //Veio do IMAP, sem images nem links.
-		sender.innerHTML += draw_plugin_cc(ID, info_msg.sender.full);
-		sender.className = "header_message_field";
-		tr111.appendChild(td111);
-		tr111.appendChild(sender);
-		tr111.appendChild(sender_values);
-		tbody_message_others_options.appendChild(tr111);
-	}
-
-	var from = document.createElement("TD");
-	from.id = "from_"+ID;
-	from.innerHTML = info_msg.from.full;
-	if (info_msg.Draft != "X"){
-		from.innerHTML += draw_plugin_cc(ID, info_msg.from);
-		tbody_message_others_options.appendChild(tr1);
-	}
-	from.className = "header_message_field";
-	var from_values = document.createElement("INPUT");
-	from_values.id = "from_values_"+ID;
-	from_values.type = "HIDDEN";
-	from_values.value = info_msg.from.full; //Veio do IMAP, sem images nem links.
-
-	var local_message = document.createElement("INPUT");
-	local_message.id = "is_local_"+ID;
-	local_message.name = "is_local";
-	local_message.type = "HIDDEN";
-	local_message.value = (info_msg.local_message)?"1":"0";
-
-	tr1.appendChild(td1);
-	tr1.appendChild(from);
-	tr1.appendChild(from_values);
-	tr1.appendChild(local_message);
-
-	if (info_msg.reply_to){
-		var tr11 = document.createElement("TR");
-		tr11.className = "tr_message_header";
-		var td11 = document.createElement("TD");
-		td11.innerHTML = get_lang("Reply to")+": ";
-		td11.setAttribute("noWrap","true");
-		var reply_to = document.createElement("TD");
-		reply_to.id = "reply_to_"+ID;
-
-		var reply_to_values = document.createElement("INPUT");
-		reply_to_values.id = "reply_to_values_"+ID;
-		reply_to_values.type = "HIDDEN";
-		reply_to_values.value = info_msg.reply_to; //Veio do IMAP, sem images nem links.
-		$.each(break_comma(info_msg.reply_to), function(index, value){
-			reply_to.innerHTML += draw_plugin_cc(ID, value);	
-		})
-		reply_to.className = "header_message_field";
-		tr11.appendChild(td11);
-		tr11.appendChild(reply_to);
-		tr11.appendChild(reply_to_values);
-		tbody_message_others_options.appendChild(tr11);
-	}
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	var tr2 = document.createElement("TR");
-	tr2.className = "tr_message_header";
-	var td2 = document.createElement("TD");
-	td2.width = "7%";
-	td2.innerHTML = get_lang("To: ");
-	var to = document.createElement("TD");
-	to.id = "to_"+ID;
-
-	var to_values = document.createElement("INPUT");
-	to_values.id = "to_values_"+ID;
-	to_values.type = "HIDDEN";
-	to_values.value = info_msg.toaddress2; //Veio do IMAP, sem images nem links.
-	// Salva a pasta da mensagem
-	var input_current_folder = document.createElement('input');
-	input_current_folder.id = "input_folder_"+ID;
-	input_current_folder.name = "input_folder";
-	input_current_folder.type = "hidden";
-	input_current_folder.value = info_msg.msg_folder;
-	td2.appendChild(input_current_folder);
-	// fim
-	// ALEXANDRE LUIZ CORREIA
-	if(info_msg.toaddress2 != null)
-	{
-		toaddress_array[ID] = break_comma(info_msg.toaddress2);
-		if (toaddress_array[ID].length > 1)
-		{
-			to.innerHTML += draw_plugin_cc(ID, toaddress_array[ID][0]);
-			var div_toaddress = document.createElement("SPAN");
-			div_toaddress.id = "div_toaddress_"+ID;
-			div_toaddress.style.display="";
-			div_toaddress.innerHTML += " (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+ID+"','to');>"+get_lang('more')+"</a>)";
-			to.appendChild(div_toaddress);
-		}
-		else
-		{
-			toAdd = toaddress_array[ID].toString()
-			if( trim(toAdd) != "" ) {
-				toAdd = toAdd.replace("<","&lt;").replace(">","&gt;");
-			} else {
-				toAdd = get_lang("without destination");
-			}
-
-			to.innerHTML += draw_plugin_cc(ID,toAdd);
-		}
-
-		to.className = "header_message_field";
-		tr2.appendChild(td2);
-		tr2.appendChild(to);
-		tr2.appendChild(to_values);
-	}
-
-	tbody_message_others_options.appendChild(tr2);
-
-	if (info_msg.cc){
-		var tr3 = document.createElement("TR");
-		tr3.className = "tr_message_header";
-		var td3 = document.createElement("TD");
-		td3.innerHTML = "CC: ";
-		var cc = document.createElement("TD");
-		cc.id = "cc_"+ID;
-
-		var cc_values = document.createElement("INPUT");
-		cc_values.id = "cc_values_"+ID;
-		cc_values.type = "HIDDEN";
-		cc_values.value = info_msg.cc;
-
-		ccaddress_array[ID] = break_comma(info_msg.cc);
-		if (ccaddress_array[ID].length > 1){
-			var div_ccaddress = document.createElement("SPAN");
-			div_ccaddress.id = "div_ccaddress_"+ID;
-			var div_ccaddress_full = document.createElement("SPAN");
-			div_ccaddress_full.id = "div_ccaddress_full_"+ID;
-			div_ccaddress.style.display="";
-			cc.innerHTML = draw_plugin_cc(ID, ccaddress_array[ID][0]);
-			div_ccaddress.innerHTML += " (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+ID+"','cc');>"+get_lang('more')+"</a>)";
-			cc.appendChild(div_ccaddress);
-		}
-		else{
-			cc.innerHTML = draw_plugin_cc(ID, info_msg.cc);
-		}
-		cc.className = "header_message_field";
-		tr3.appendChild(td3);
-		tr3.appendChild(cc);
-		tr3.appendChild(cc_values);
-		tbody_message_others_options.appendChild(tr3);
-	}
-
-	/*
-	 * @AUTHOR Rodrigo Souza dos Santos
-	 * @MODIFY-DATE 2008/09/11
-	 * @BRIEF Adding routine to create bcc field if there is one.
-	 */
-	if (info_msg.bcc)
-	{
-		var tr3 = document.createElement("tr");
-		tr3.className = "tr_message_header";
-		var td3 = document.createElement("td");
-		td3.innerHTML = get_lang("BCC") + " : ";
-		var cco = document.createElement("td");
-		cco.id = "cco_"+ID;
-
-		var cco_values = document.createElement("input");
-		cco_values.id = "cco_values_"+ID;
-		cco_values.type = "hidden";
-		cco_values.value = info_msg.bcc;
-
-		ccoaddress_array[ID] = info_msg.bcc.split(",");
-		if (ccoaddress_array[ID].length > 1){
-			var div_ccoaddress = document.createElement("SPAN");
-			div_ccoaddress.id = "div_ccoaddress_"+ID;
-			var div_ccoaddress_full = document.createElement("SPAN");
-			div_ccoaddress_full.id = "div_ccoaddress_full_"+ID;
-			div_ccoaddress.style.display="";
-
-			//cco.innerHTML = draw_plugin_cc(ID, ccoaddress_array[ID][0]);
-			cco.innerHTML = ccoaddress_array[ID][0];
-			div_ccoaddress.innerHTML += " (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+ID+"','cco');>"+get_lang('more')+"</a>)";
-			cco.appendChild(div_ccoaddress);
-		}
-		else{
-			//cco.innerHTML = draw_plugin_cc(ID, info_msg.cco);
-			cco.innerHTML = info_msg.bcc;
-		}
-		cco.className = "header_message_field";
-		tr3.appendChild(td3);
-		tr3.appendChild(cco);
-		tr3.appendChild(cco_values);
-		tbody_message_others_options.appendChild(tr3);
-	}
-
-	var tr4 = document.createElement("TR");
-	tr4.className = "tr_message_header";
-	var td4 = document.createElement("TD");
-	td4.innerHTML = get_lang("Date: ");
-	var date = document.createElement("TD");
-	date.id = "date_"+ID;
-	date.innerHTML = info_msg.fulldate;
-	var date_day = document.createElement("INPUT");
-	date_day.id = "date_day_"+ID;
-	date_day.type = "HIDDEN";
-	date_day.value = info_msg.msg_day;
-	var date_hour = document.createElement("INPUT");
-	date_hour.id = "date_hour_"+ID;
-	date_hour.type = "HIDDEN";
-	date_hour.value = info_msg.msg_hour
-	date.className = "header_message_field";
-	tr4.appendChild(td4);
-	tr4.appendChild(date);
-	tr4.appendChild(date_day);
-	tr4.appendChild(date_hour);
-	tbody_message_others_options.appendChild(tr4);
-
-	var tr5 = document.createElement("TR");
-	tr5.className = "tr_message_header";
-	var td5 = document.createElement("TD");
-	td5.innerHTML = get_lang("Subject");
-	var subject = document.createElement("TD");
-	subject.id = "subject_"+ID;
-	subject.innerHTML = html_entities(info_msg.subject); 
-	subject.className = "header_message_field";
-	if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){
-		var new_event_logo = document.createElement("IMG");
-		new_event_logo.title = "Criar evento a partir deste email";
-		new_event_logo.alt = "Criar evento a partir deste email";
-		new_event_logo.src = "./templates/default/images/calendar_add.png";
-		new_event_logo.style.cursor = "pointer";
-		new_event_logo.style.marginLeft = "5px";
-		new_event_logo.onclick = function(){
-		import_implements_calendar();
-		
-		
-			DataLayer.dispatchPath = "../prototype/";
-			var path = "../prototype/modules/calendar/";
-
-			var startEvent = new Date();  
-			if(startEvent.toString('mm') < 30) 
-				startEvent.add({minutes: (30 - parseInt(startEvent.toString('mm')))}); 
-			else 
-				startEvent.add({hours: 1, minutes: '-'+startEvent.toString('mm')}); 
-			var endEvent = function(date){ 
-				if(!!User.preferences.defaultCalendar){ 
-					return  new Date(parseInt(date.getTime()) + 
-						    (!!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ?  
-							(Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration * 60000) :
-							(User.preferences.defaultDuration * 60000)
-						));
-				}else 
-					return new Date(parseInt(date.getTime()) + (User.preferences.defaultDuration * 60000)); 
-			};       
-
-			var emails = $("#to_values_"+ID).val().split(',');
-			
-			
-			//Normalizaï¿œï¿œo dos dados evita ter que reemplementar toda as funcionalidades do calendar
-			eventDetails({ 
-					
-					acl: {inviteGuests: true, organization: true ,participationRequired: false, read: true, write: true},
-					alarms: [],
-					allDay: false,
-					attachments: [],
-					isAttendee: true,
-					attendee: '',//TODOOOOOO,
-					calendar: User.preferences.defaultCalendar ? User.preferences.defaultCalendar : Calendar.calendars[0],
-					calendars: Calendar.calendars,
-					category: '',
-					'class': '1',
-					delegatedFrom: {},
-					endDate: startEvent.toString(User.preferences.dateFormat),
-					startDate: endEvent(startEvent).toString(User.preferences.dateFormat),
-					startHour: startEvent.toString(User.preferences.hourFormat),
-					endHour: endEvent(startEvent).toString(User.preferences.hourFormat),
-					timezone: User.preferences.defaultCalendar ? Calendar.signatureOf[User.preferences.defaultCalendar].calendar.timezone : User.preferences.timezone,
-					summary : $("#subject_"+ID).text(),
-					description : $("#body_" + ID).text(),
-					startTime: startEvent.getTime(),
-					endTime: endEvent(startEvent),
-					timezones: Timezone.timezones,
-					me: {name: User.me.name, mail: User.me.mail, acl: 'rowi', status: '1', delegatedFrom: '0', id: User.me.id},
-					organizer: {name: User.me.name, mail: User.me.mail, acl: 'rowi', status: '1', delegatedFrom: '0' , id: User.me.id},
-					statusParticipants: {accepted: 0, cancelled: 0, tentative: 0, unanswered:emails.length},
-					location: '',
-					attendee: $.map(emails, function( mail ){			
-						var contact = false;
-						var decoded =  Encoder.htmlDecode(mail);
-						var newAttendeeName = "";
-
-						var name = decoded.match(/"([^"]*)"/) ? decoded.match(/"([^"]*)"/)[1] : '';
-						var mail = decoded.match(/<([^<]*)>[\s]*$/) ? decoded.match(/<([^<]*)>[\s]*$/)[1].toLowerCase() : decoded; 
-
-
-						var user = DataLayer.get('user', ["=", "mail", mail], true);
-						
-						if( $.type(user) == "array")
-						    user = user[0];
-
-						if(user != ''){
-						    //user = {name : name , mail : mail};
-						    if(User.me.mail == user.mail)
-							    return(null);
-						    user.isExternal = (!!user && !(!!user.isExternal)) ? 0 : 1;
-
-						    return  DataLayer.merge({
-							    name: user.name,
-							    mail: user.mail,
-							    acl:  'r',
-							    delegatedFrom: '0',
-							    status: '4',
-							    isExternal: user.isExternal
-						    }, !!user.id ? {id : DataLayer.put('participant', {user: user.id, isExternal: user.isExternal})} : {id: DataLayer.put('participant', {user: user})}); 
-						}else if(mail.match(/[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])/)){
-						    
-						    var userId = DataLayer.put('user', {
-							name: name, 
-							mail: mail, 
-							isExternal: '1'
-						    });
-						    var newAttendeeId = DataLayer.put('participant', {
-							user: userId, 
-							isExternal: '1'
-						    });
-
-						    return  {
-							    id: newAttendeeId,
-							    name: name,
-							    mail: mail,
-							    acl:  'r',
-							    delegatedFrom: '0',
-							    status: '4',
-							    isExternal: '1'
-						    };
-						    
-						}else
-						    return (null);
-					})	
-					
-			}, true, path, true);
-		}
-		subject.appendChild(new_event_logo);
-	}
-	tr5.appendChild(td5);
-	tr5.appendChild(subject);
-	tbody_message_others_options.appendChild(tr5);
-	//k!
-	
-	
-	var update_labeleds_msg = function(){
-		//TODO Mudar quando API abstrair atualizaï¿œï¿œes no cache
-		DataLayer.remove('labeled', false);
-		//DataLayer.get('labeled');
-		var labels = DataLayer.get("labeled", {filter: [
-				'AND',
-					['=', 'folderName', current_folder], 
-					['=','messageNumber',folder_id]], 
-				criteria : {deepness: 2}} );
-		
-		if(labels.length != 0){
-			var tr8 = document.createElement("TR");
-			tr8.className = "tr_message_header";
-			var td8 = document.createElement("TD");
-			td8.innerHTML = get_lang("Labels: ");
-			var markers = document.createElement("TD");
-			markers.id = "markers_"+ID;
-			
-			for(var i=0; i<labels.length; i++){
-				fontColor = labels[i].label.fontColor;
-				borderColor = labels[i].label.borderColor;
-				backgroundColor = labels[i].label.backgroundColor;
-				nameLabel = labels[i].label.name;
-				id = labels[i].id;
-				markers.innerHTML+= "<div  style='height: 15px; background:"+backgroundColor+"; float: left; -webkit-border-radius: 3px; -moz-border-radius: 3px; margin:0 0 1px 1px; border: 1px solid "+borderColor+"'><span style='color: "+fontColor+"; margin: 5px;'>"+nameLabel+"</span><span class='removeLabeledMsg' id='"+id+"' title='"+get_lang("Remove Label")+"'>x</span></div>";
-				
-			}
-			$(markers).find('span.removeLabeledMsg').click(function(event){
-				var id_labeled = $(event.target).attr("id");
-				//TODO Mudar quando API abstrair atualizaï¿œï¿œes no cache
-				//DataLayer.remove('labeled', false);
-				//DataLayer.get('labeled');
-				DataLayer.remove('labeled', id_labeled);
-				DataLayer.commit(false, false, function(){
-					var index_folder = id_labeled.lastIndexOf('/');
-					var folder_name = id_labeled.slice(0,index_folder);
-					var index_number = id_labeled.lastIndexOf('#');
-					var msg_number = id_labeled.slice(index_folder + 1,index_number);
-					updateLabelsColumn({msg_number:msg_number, boxname:folder_name, labels:false});
-					update_labeleds_msg();
-					tbody_message_others_options.removeChild(tr8);
-				});
-				
-			});
-			markers.className = "header_message_field";
-			tr8.appendChild(td8);
-			tr8.appendChild(markers);
-			tbody_message_others_options.appendChild(tr8);
-		}
-	}
-
-	if ( info_msg.attachments && info_msg.attachments.length > 0 )
-	{
-		//Cï¿œdigo no padrï¿œo expresso 2.2
-	var tr6 = document.createElement("TR");
-		tr6.className = "tr_message_header";
-		var td6 = document.createElement("TD");
-		td6.innerHTML = get_lang("Attachments: ");
-		
-		
-		var attachments = document.createElement("TD");
-		td6.valign = "top";
-		attachments.align = 'left';
-		if(info_msg.attachments.length >= 1){
-			if(info_msg.attachments.length > 1) {
-				var link_attachment	 = document.createElement("A");
-				 if(proxy_mensagens.is_local_folder(current_folder))
-					link_attachment.setAttribute("href", "javascript:expresso_local_messages.download_all_local_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");
-				else
-					link_attachment.setAttribute("href", "javascript:download_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");
-				link_attachment.innerHTML = " "+info_msg.attachments.length+' '+get_lang('files')+' :: '+get_lang('Download all atachments');
-                    attachments.appendChild(link_attachment);
-			}
-			if(parseInt(preferences.remove_attachments_function))
-			{
-                    attachments.appendChild(document.createTextNode('  '));
-                    var del_attachments = document.createElement("A");
-                    del_attachments.setAttribute("href", "javascript:remove_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");
-                    del_attachments.innerHTML = get_lang('remove all attachments');
-                    attachments.appendChild(del_attachments);
-			}
-                attachments.appendChild(document.createElement('BR'));
-        }
-		attachments.id = "attachments_" + ID;
-		var parserImport = false;
-		for (var i=0; i<info_msg.attachments.length; i++)
-		{
-			var import_url = '$this.db_functions.import_vcard&msg_folder='+info_msg.msg_folder+"&msg_number="+info_msg.msg_number+"&msg_part="+info_msg.attachments[i].pid+"&idx_file="+i+"&encoding="+info_msg.attachments[i].encoding;
-			var link_attachment = document.createElement("a");
-			link_attachment.setAttribute("class", "type_images");
-			link_attachment.style.display = "block";
-			link_attachment.setAttribute("href", proxy_mensagens.link_anexo(info_msg,i));
-			link_attachment.innerHTML = url_decode(info_msg.attachments[i].name) + " ("+borkb(info_msg.attachments[i].fsize)+")";
-			//link_attachment.innerHTML += " ("+borkb(info_msg.attachments[i].fsize)+")";
-
-			//k trocar por match???
-			if((url_decode(info_msg.attachments[i].name).indexOf(".ics")!=-1) || (url_decode(info_msg.attachments[i].name).indexOf(".vcard")!=-1))
-			{
-				//Link para importar calendï¿œrio
-				var link_import_attachment = new Image();
-				link_import_attachment.src = "templates/"+template+"/images/new.png";
-				link_import_attachment.setAttribute("onclick","javascript:import_calendar('"+info_msg.msg_folder+"&msg_number="+info_msg.msg_number+"&msg_part="+info_msg.attachments[i].pid+"&idx_file="+i+"&encoding="+info_msg.attachments[i].encoding+"'); return false;");
-				link_import_attachment.title = get_lang("Import to calendar");
-				link_import_attachment.style.display = "inline";
-				link_import_attachment.align = "top";
-				link_import_attachment.style.marginLeft = "5px";
-				link_import_attachment.style.cursor = "pointer";
-				link_attachment.appendChild(link_import_attachment);
-				parserImport = true;
-			}
-
-            if((url_decode(info_msg.attachments[i].name).indexOf(".eml") != -1))
-			{
-				//Link para importar calendï¿œrio
-				var link_open_msg = new Image();
-				link_open_msg.src = "templates/"+template+"/images/email.png";
-				//link_open_msg.setAttribute("onclick","javascript:import_calendar('"+info_msg.msg_folder+"&msg_number="+info_msg.msg_number+"&msg_part="+info_msg.attachments[i].pid+"&idx_file="+i+"&encoding="+info_msg.attachments[i].encoding+"'); return false;");
-				link_open_msg.setAttribute("onclick","javascript:open_msg_part('"+info_msg.msg_folder+"&msg_number="+info_msg.msg_number+"&msg_part="+info_msg.attachments[i].pid+"'); return false;");
-				link_open_msg.title = get_lang("Open message");
-				link_open_msg.align = "top";
-				link_open_msg.style.marginLeft = "5px";
-				link_open_msg.style.cursor = "pointer";
-				link_attachment.appendChild(link_open_msg);
-			}
-		
-            //link_attachment.innerHTML += '<br/>';
-            attachments.appendChild(link_attachment);
-            }
-		tr6.appendChild(td6);
-        tr6.appendChild(attachments);
-		tbody_message_others_options.appendChild(tr6);
-	}
-
-	if (parserImport){
-		$.ajax({
-			url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(),
-			async: true,
-			success: function(data){
-				data = connector.unserialize(data);
-
-				if(typeof(data) == "object"){
-				    var calendarPermission = data.calendar;
-				    data = data.action;
-				}
-					
-				switch(parseInt(data)){
-				case 5:
-					$('.type_images').append('<img class="loader" src="templates/default/images/ajax-loader.gif" align="top" style="margin-left: 5px; cursor: pointer; display: inline">');
-					$.ajax({
-						url: "controller.php?action="+import_url+'&from_ajax=true&selected=true',
-						success: function(msg){		
-							$('.type_images').append('<img src="../prototype/modules/mail/img/flagDone.png" align="top" style="margin: 3px 0 0 5px; cursor: pointer; display: inline">').parent().find('.loader').remove();
-							write_msg( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi Atualizado com sucesso" : "Ocorreu um erro ao atualizar evento" );
-						}
-					});
-					return;
-					break;		
-				case 4:
-					$('.type_images').append('<img src="../prototype/modules/mail/img/flagDone.png" align="top" style="margin: 3px 0 0 5px; cursor: pointer; ">');
-					write_msg("Seu evento encontra-se atualizado.");
-					return;
-					break;
-				case 12:
-					write_msg('Este evento nï¿œo existe mais.');
-					return;
-					break;			
-				}
-			}
-		});
-	}
-	//k!!
-	
-	var div = document.createElement("DIV");
-	div.id = "div_message_scroll_"+ID;
-        div.style.background = 'WHITE';
-        div.style.overflow = "auto";
-	table_message_others_options.appendChild(tbody_message_others_options);
-	var tr = document.createElement("TR");
-		tr.className = "tr_message_header";
-	var td = document.createElement("TD");
-		td.colspan = '2';
-	td.style.fontSize = '10pt'; 
- 	td.style.fontFamily = 'Arial,Verdana'; 
- 	td.style.verticalAlign = 'top'; 
- 	td.style.height = '100%';
-	div.appendChild(table_message_others_options);
-	var imgTag = info_msg.body.match(/(<img[^>]*src[^>=]*=['"]?[^'">]*["']?[^>]*>)|(<[^>]*(style[^=>]*=['"][^>]*background(-image)?:[^:;>]*url\()[^>]*>)/gi);
-	var newBody = info_msg.body;
-	if(!info_msg.showImg && imgTag)
-	{
-		var domains = '';
-		var blocked = false;
-		var forbidden = true;
-
-		if (preferences.notification_domains != null && typeof(preferences.notification_domains) != 'undefined')
-		{
-			domains = preferences.notification_domains.split(',');
-			for(var j = 0; j < imgTag.length; j++)
-			{
-				for (var i = 0; i < domains.length; i++)
-				{
-					if (imgTag[j].match(/cid:([\w\d]){5,}/) || imgTag[j].match(/src=\"\.\/inc\/get_archive\.php/g)) 
-					{
-						forbidden = false;
-						continue;
-					}
-					imgSource = imgTag[j].match(/=['"](http:\/\/)+[^'"\/]*/);
-					if (imgSource && imgSource.toString().substr(5).match(domains[i]))
-						forbidden = false;
-				}
-				if (forbidden)
-				{
-					newBody = newBody.replace(imgTag[j],"<img src='templates/"+template+"/images/forbidden.png'>");
-					blocked=true;
-				}
-			}
-			if (blocked)
-			{
-				var showImgLink = document.createElement('DIV');
-				showImgLink.id="show_img_link_"+ID;
-				showImgLink.onclick = function(){show_msg_img(info_msg.msg_number,info_msg.msg_folder)};
-				showImgLink.className="show_img_link";
-				showImgLink.innerHTML = get_lang("Show images from")+": "+info_msg.from.email;
-				td.appendChild(showImgLink);
-			}
-		}
-	}
-	td.appendChild(div);
-	tr.appendChild(td)
-	tbody_message.appendChild(tr);
-
-
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	//Make the body message.
-	///////////////////////////////////////////////////////////////////////////////////////////////////////
-	var tr = document.createElement("TR");
-	tr.className = "tr_message_body";
-	var td = document.createElement("TD");
-	//td.setAttribute("colSpan","2");
-	
-	//Comentado pois estes replaces e a tentativa de remover as tags <span> vazias faz com que seja 
-	//eliminado os estilos aplicados no corpo do texto quando utilizado o Firefox.
-	//newBody = newBody.replace("<body","<span");
-	//newBody = newBody.replace("<BODY","<span");
-	//while ( ( /<span[^>]*><span[^>]*>/ig ).test( newBody ) )
-	//	newBody = newBody.replace( /(<span[^>]*>)<span[^>]*>/ig, '$1' );
-
-	var _body = document.createElement( 'div' );
-	_body.id = 'body_' + ID;
-	_body.innerHTML = newBody;
-	_body.style.marginLeft = '5px';
-
-	var _elements = _body.getElementsByTagName( '*' );
-	for( var i = 0; i < _elements.length; i++ )
-		if ( _elements[ i ].attributes && _elements[ i ].attributes.getNamedItem( 'id' ) )
-			_elements[ i ].attributes.removeNamedItem( 'id' );	
-	
-	div.appendChild( _body );
-	
-	 //window.setTimeout(function() { $("#div_message_scroll_"+ID).focus() },250);
-	
-	function mailto( link )
-	{
-		var mail = link.href.substr( 7 );
-		link.onclick = function( )
-		{
-			new_message_to( mail );
-			return false;
-		};
-	}
-	var links = div.getElementsByTagName( 'a' );
-	for ( var i = 0; i < links.length; i++ ){
-		try{
-			if ( links.item( i ).href.indexOf( 'mailto:' ) === 0 ){
-				mailto( links.item( i ) );
-			}
-			else{
-				var anchor_pattern = "http://"+location.host+location.pathname+"#";
-
-				if ( ( links.item( i ).href.indexOf( 'javascript:' ) !== 0 ) &&
-					(links.item( i ).href.indexOf(anchor_pattern) !== 0) ) //se nï¿œo for ï¿œncora
-						links.item( i ).setAttribute( 'target', '_blank' );
-			}
-		}catch(e){
-		}
-	}
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	//Make the thumbs of the message.
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	//k
-	
-	if ((info_msg.thumbs)&&(info_msg.thumbs.length > 0)){
-		var thumbs = jQuery.parseJSON(info_msg.thumbs);
-		var div_thumbs = document.createElement("div");
-		
-		div_thumbs.setAttribute("class", "expressomail-thumbs");
-		div_thumbs.setAttribute("className", "expressomail-thumbs"); //for IE
-		
-		var div_thumbs_lbl = document.createElement("DIV");
-		div_thumbs_lbl.setAttribute("class", "expressomail-thumbs-label");
-		div_thumbs_lbl.setAttribute("className", "expressomail-thumbs-label"); //for IE
-		
-		var div_thumbs_lbl_sp = document.createElement("SPAN");
-		div_thumbs_lbl_sp.setAttribute("class", "message_options");
-		div_thumbs_lbl_sp.setAttribute("className", "message_options"); //for IE
-		var div_thumbs_lbl_st = document.createElement("STRONG");
-		div_thumbs_lbl_st.innerHTML = info_msg.attachments.length+" "+get_lang("attachment")+(info_msg.attachments.length > 1 ? "s" : "")+" "+get_lang("in this message");
-		var div_thumbs_lbl_a  = document.createElement("A");
-
-		if(info_msg.thumbs.length > 1){
-			 if(proxy_mensagens.is_local_folder(current_folder))
-				div_thumbs_lbl_a.setAttribute("href", "javascript:expresso_local_messages.download_all_local_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");
-			else
-				div_thumbs_lbl_a.setAttribute("href", "javascript:download_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");
-			div_thumbs_lbl_a.innerHTML = get_lang('Download all atachments');
-		} else {
-			div_thumbs_lbl_a.setAttribute("style", "display:none; visibility:hidden;");
-		}
-
-		div_thumbs_lbl_sp.appendChild(div_thumbs_lbl_st);
-		div_thumbs_lbl_sp.appendChild(document.createTextNode(' :: '));
-		div_thumbs_lbl_sp.appendChild(div_thumbs_lbl_a);
-		div_thumbs_lbl.appendChild(div_thumbs_lbl_sp);
-
-		var div_thumbs_lbl_sp2   = document.createElement("SPAN");
-		div_thumbs_lbl_sp2.setAttribute("class", "message_tips");
-		div_thumbs_lbl_sp2.setAttribute("className", "message_tips"); //for IE
-		div_thumbs_lbl_sp2.innerHTML = get_lang("<strong>Tip:</strong> <span>For faster save, click over the image with <em>right button</em>.</span>");
-
-		var ul_thumbs_list = document.createElement("UL");
-		ul_thumbs_list.setAttribute("class", "expressomail-thumbs-list");
-		ul_thumbs_list.setAttribute("className", "expressomail-thumbs-list"); //for IE
-
-	                var msg = info_msg.msg_number; 
-	                var fdr = info_msg.msg_folder; 
-					var i = 0;
-				//verifica se estï¿œ no novo padrï¿œo de montagem das mensagens ou no antigo, necessï¿œrio
-				//para exibir as imagens no arquivamento local arquivamento local.
-				if(thumbs){
-	                jQuery.each(thumbs, function(i, thumb) {
-							if(fdr.indexOf("local_") >= 0){
-								var href = info_msg.array_attach[i].url + '&image=true'; 
-								var src  = info_msg.array_attach[i].url+ '&image=thumbnail'; 
-								i++;
-							}else{
-								var href = './inc/get_archive.php?msgFolder=' + fdr + '&msgNumber=' + msg + '&indexPart=' + thumb.pid + '&image=true'; 
-								//var href = thumb.url; 
-								var src  = 'inc/get_archive.php?msgFolder=' + fdr + '&msgNumber=' + msg + '&indexPart=' + thumb.pid + '&image=thumbnail'; 
-	                        }
-	                        var msgid= fdr+";;"+msg+";;"+i+";;"+thumb.pid+";;"+thumb.encoding; 
-	                        var image_info = '{"folder":"'+fdr+'","message":"'+msg+'","thumbIndex":"'+i+'","pid":"'+thumb.pid+'","encoding":"'+thumb.encoding+'","type":"'+thumb.type+'"}'; 
-	                         
-	                        var image= '<img id="' + msgid + '" title="' +  
-	                                                        get_lang('Click here do view (+)') + '" src="' + src + '" style="width:auto;height:100%;" />'; 
-	                                                 
-	                        var content = '<a title="'+thumb.name+ '" rel="thumbs'+ID+'" class="expressomail-thumbs-link" onMouseDown="save_image(event,this,\'' +thumb.type+'\')" href="'+href+'" onclick="window.open(\''+href+'\',\'mywindow\',\'width=700,height=600,scrollbars=yes\');return false;">'+image+'</a>'; 
-	                        content += '<input id="thumb_'+ID+'_'+i+'" type="hidden" value="' +escape(image_info) +'" />'; 
-	                        jQuery(ul_thumbs_list).append('<li>'+content+'</li>'); 
-	                         
-	                });    
-		
-		div_thumbs.appendChild(div_thumbs_lbl);
-		div_thumbs.appendChild(div_thumbs_lbl_sp2);
-		div_thumbs.appendChild(ul_thumbs_list);
-		
-				}else{
-					div_thumbs.appendChild(div_thumbs_lbl);
-					div_thumbs.appendChild(div_thumbs_lbl_sp2);
-					div_thumbs.innerHTML = div_thumbs.innerHTML + info_msg.thumbs;
-					
-					
-				}
-		
-		div.appendChild(div_thumbs);
-	}
-	//k!!
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	table_message.appendChild(tbody_message);
-	content.appendChild(table_message);
-	resizeWindow();
-	var msg_number = document.createElement('INPUT');
-	msg_number.id = "msg_number_" + ID;
-	msg_number.type = "hidden";
-	msg_number.value = info_msg.msg_number;
-	content.appendChild(msg_number);
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-
-	//Exibe o cabecalho da mensagem totalmente aberto caso esteja setado nas preferencias do usuario
-	if (preferences.show_head_msg_full == 1)
-	{
-		option_hide_more.onclick();
-		if (Element('div_toaddress_'+ID) != null)
-			show_div_address_full(ID,'to');
-		if (Element('div_ccaddress_'+ID) != null)
-			show_div_address_full(ID,'cc');
-	}
-
-	/*
-	 * TODO: implementar o controle como preferï¿œncia do usuï¿œrio
-	 *
-	 */
-	var jcarousel = false;
-	if (jcarousel) {
-		//carousel 
-		jQuery(document).ready(function() {
-	 		jQuery('.expressomail-thumbs-list').attr('id', 'expressomail-thumbs-list'+ID) 
-	 	    .addClass('jcarousel-skin-default').jcarousel(); 
-
-			jQuery('.expressomail-thumbs-link img').attr('style', ''); 
-		
-		//fancybox
-			jQuery(".expressomail-thumbs-list li a").attr('onclick', 'return true;');
-			jQuery(".expressomail-thumbs-list li a").fancybox({
-				'hideOnContentClick': true,
-					'type': 'image', 
-					'titlePosition': 'over',                                         
-					'titleFormat' : function(name, currentArray, currentIndex, currentOpts) {                        
-							var image_info = $('#thumb_'+ID+'_'+currentIndex).val(); 
-
-							return '<div id="fancybox-title" class="fancybox-title-over" style="width: 100%; display: block;">' + 
-										'<div id="fancybox-title-over">' + 
-											'<a title="Anterior" onclick="javascript:$.fancybox.prev();" style="float:left;">' + 
-													'<img src="./templates/'+template+'/images/left_arrow_white.png" width="30" height="30" />' + 
-											'</a>'+ 
-											'<a title="Baixar imagem" onclick="javascript:save_image2(\''+image_info+'\');" style="padding:0 5px;">' + 
-													'<img src="./templates/'+template+'/images/image_down.png" width="22" height="22" />' + 
-											'</a>'+ 
-											'<a title="Baixar todas de uma vez" onclick="javascript:download_all_attachments(\''+info_msg.msg_folder+"','"+info_msg.msg_number+'\')" style="padding:0 5px;">'+ 
-													'<img src="./templates/'+template+'/images/package_down.png" width="26" height="26" />' + 
-											'</a>'+ 
-											'<span style="margin-left:5px; margin-top:7px; position:absolute;">'+name+'</span>'+ 
-											'<a title="Prï¿œxima" onclick="javascript:$.fancybox.next();" style="float:right;">' + 
-												'<img src="./templates/'+template+'/images/right_arrow_white.png" width="30" height="30" />' + 
-											'</a>' + 
-										'</div>' + 
-									'</div>'; 
-					} 
-			});
-		});
-	}  
-	if ( is_webkit ){ //Corrige o bug de foco no Chrome
-	       var ev = document.createEvent('MouseEvents');
-           ev.initEvent(
-				'click'    
-				,false 
-				,true
-			);
-	       var divScroll = Element('div_message_scroll_'+ID);
-			if (divScroll) {
-				divScroll.setAttribute('tabindex','-1');
-				divScroll.onclick = function() {setTimeout(function(){$("#div_message_scroll_"+ID).focus();},0);};
-				divScroll.dispatchEvent(ev);
-			}
-		}
-	else  $("#div_message_scroll_"+ID).focus();
-	update_labeleds_msg();
-
-	resizeWindow(); 
-	
-	$("#div_message_scroll_"+ID).scrollTo( 0, 400, {queue:true} );
-}
  
 function changeLinkState(el,state){
@@ -3807,12 +1928,4 @@
 			}
 	}
-}
-
-function mySplit( val ) {
-	return val.split( /,\s*/ );
-}
-
-function extractLast( term ) {
-	return mySplit( term ).pop();
 }
 
@@ -4516,10 +2629,8 @@
 	.end().filter(".cco-button").click(function(){
 		show_hide(content.find(".cco-tr"), $(this));
-		change_text($(this).find(".ui-button-text"), get_lang("Add BCC"), get_lang('Remove CCo'));
 	})
 	//Botï¿œo Adicionar/Remover CC
 	.end().filter(".cc-button").click(function(){
 		show_hide(content.find(".cc-tr"), $(this));
-		change_text($(this).find(".ui-button-text"), get_lang("Add CC"), get_lang('Remove CC'));
 	})
     //Botï¿œo Responder a
@@ -4527,9 +2638,11 @@
         show_hide(content.find(".reply-to-tr"), $(this));
     });
-	
+
+	content.find(".field-buttons").buttonset();
+
 	//BOTAO ENVIAR
 	content.find(".send").button({
 		icons : {
-			primary : "expressomail-icon-send"
+			primary : "ui-icon-mail-closed"
 		}
 	}).click(function(){
@@ -4547,5 +2660,5 @@
 	.end().find(".save").button({
 		icons : {
-			primary : "expressomail-icon-save"
+			primary : "ui-icon-disk"
 		}
 	}).click(function(){
@@ -4555,6 +2668,7 @@
 	.end().find(".return-recept").button({
 		icons : {
-			primary : "expressomail-icon-read-confirmation"
-		}
+			primary : "ui-icon-transfer-e-w"
+		},
+		text:false
 	}).click(function(){
 		check_input(content.find('[name="input_return_receipt"]'));
@@ -4564,6 +2678,7 @@
 	.end().find(".important").button({
 		icons : {
-			primary : "expressomail-icon-important"
-		}
+			primary : "ui-icon-notice"
+		},
+		text:false
 	}).click(function(){
 		check_input(content.find('[name="input_important_message"]'));
@@ -4573,20 +2688,22 @@
 	.end().find(".return_digital").button({
 		icons : {
-			primary : "expressomail-icon-signature"
-		}
+			primary : "ui-icon-key"
+		},
+		text:false
 	}).click(function(){
 		check_input(content.find('[name="input_return_digital"]'));
-		$(this).toggleClass("expressomail-button-icon-ative");
 	})
 	//BOTAO EMAIL CRYPT
 	.end().find(".return_cripto").button({
 		icons : {
-			primary : "expressomail-icon-encryption"
-		}
+			primary : "ui-icon-locked"
+		},
+		text:false
 	}).click(function(){
 		check_input(content.find('[name="input_return_cripto"]'));
-		$(this).toggleClass("expressomail-button-icon-ative");
 	});
 	
+	content.find(".flags-buttons").buttonset();
+
 	content.find(".attachment td").filter(".value").prepend(DataLayer.render("../prototype/modules/mail/templates/attachment.ejs", {ID:ID}));
 	var fileUploadMSG = $('#fileupload_msg'+ID);
Index: /sandbox/newExpressoMail/expressoMail1_2/js/doiMenuData.js
===================================================================
--- /sandbox/newExpressoMail/expressoMail1_2/js/doiMenuData.js	(revision 6943)
+++ /sandbox/newExpressoMail/expressoMail1_2/js/doiMenuData.js	(revision 7167)
@@ -7,5 +7,5 @@
 				var msg_folder = current_folder;
 				var messages = new Array();
-				if(currentTab == 0){
+				if(indexTab() == 0){
 					var id = get_selected_messages().split(',');
 					for (i = 0; i < id.length; i++){
