Index: /sandbox/2.5.0-expresso1/prototype/modules/mail/js/foldertree.js
===================================================================
--- /sandbox/2.5.0-expresso1/prototype/modules/mail/js/foldertree.js	(revision 7263)
+++ /sandbox/2.5.0-expresso1/prototype/modules/mail/js/foldertree.js	(revision 7270)
@@ -93,5 +93,5 @@
 if(preferences.use_local_messages != 0){
 
-    if(expresso_mail_archive.folders){  //MailArchive
+    if(expresso_mail_archive.folders && !expresso_offline && expresso_mail_archive.enabled == true) { //MailArchive
         //pega pastas locais do mailarchiver e insere no array de pastas
             expresso_mail_archive.getFoldersList("home");
@@ -163,4 +163,12 @@
             animated: "fast"
     }).find(".folder").unbind("click").click(function(event){
+
+        if ($(this).next().hasClass("local-connect")) {
+            return;
+        }
+
+        if ($(this).hasClass("local-folder")) {
+            return;
+        }
         
         // MUDANÃA DE PASTAS!
@@ -347,5 +355,5 @@
         function(){
             //CASO A LI NÃO TENHA UM eventNU FLUTUANTE AINDA, O eventNU Ã ADICIONADO!
-            if(!$(this).children(":last").hasClass("float-menu") && !$(this).children(":last").hasClass("new_folder")){
+            if(!$(this).children(":last").hasClass("float-menu") && !$(this).children(":last").hasClass("new_folder") && !($(this).next().hasClass("local-connect"))){ /*se houver a classe local-connect, nÃ£o adiciona o botÃ£o de conectar*/
                 var folder_ = $(this);
                 var folder_name;
Index: /sandbox/2.5.0-expresso1/prototype/modules/mail/templates/detailedfoldertree.ejs
===================================================================
--- /sandbox/2.5.0-expresso1/prototype/modules/mail/templates/detailedfoldertree.ejs	(revision 7202)
+++ /sandbox/2.5.0-expresso1/prototype/modules/mail/templates/detailedfoldertree.ejs	(revision 7270)
@@ -51,7 +51,16 @@
   <%}%>
   <% if(preferences.use_local_messages == 1) { %>
-  <li><span class="folder head_folder">Pastas locais</span>
-      <% recursive_forest(data.folders[2]); %>
-  </li>
+     <% if(expresso_mail_archive.enabled && data.folders[2].length > 0) { /*MailArchive ativado*/ %>
+     	<li>
+    		<span class="folder local-folder" style="display: inline;">Pastas locais</span>
+    	 	<% recursive_forest(data.folders[2]); %>
+    	</li>
+    <%} else { /*MailArchive desativado*/ %>
+    	<li>
+    		<span class="folder local-folder" style="display: inline;" title="MailArchive Desconectado">Pastas locais</span>
+    		<span class="local-connect" onclick="services_retry();" title="Conectar ao MailArchive"></span>
+    		<a class="local-admin" href="http://127.0.0.1:4333/admin" title="MailArchiver Admin" target="_blank"></a>
+    	</li>
+	<%}%>
   <%}%>
   <li><span class="folder head_folder all_accomp followup-messages">Para acompanhamento</span>
Index: /sandbox/2.5.0-expresso1/expressoMail1_2/templates/default/main.css
===================================================================
--- /sandbox/2.5.0-expresso1/expressoMail1_2/templates/default/main.css	(revision 7157)
+++ /sandbox/2.5.0-expresso1/expressoMail1_2/templates/default/main.css	(revision 7270)
@@ -1582,2 +1582,23 @@
 	vertical-align: middle;
 }
+
+/* Mail Archive */
+.local-folder {
+
+}
+
+.local-connect {
+ 	width: 16px;
+	height: 16px;
+	background: url("images/connect_delete.gif") no-repeat;
+	display: inline-block;
+	cursor: pointer;
+}
+
+.local-admin {
+	width: 16px;
+	height: 16px;
+	background: url("images/config.png") no-repeat;
+	display: inline-block;
+	cursor: pointer;
+}
Index: /sandbox/2.5.0-expresso1/expressoMail1_2/js/mail_archiver.js
===================================================================
--- /sandbox/2.5.0-expresso1/expressoMail1_2/js/mail_archiver.js	(revision 7261)
+++ /sandbox/2.5.0-expresso1/expressoMail1_2/js/mail_archiver.js	(revision 7270)
@@ -257,9 +257,6 @@
         //Redraw "Offline" linkage, intended to recoonect MailArchiver link    
         connector.purgeCache();
-        ttreeBox.name_folder = "root";
-        ttreeBox.update_folder();
-        draw_tree_local_folders();
-        ttreeBox.update_folder();
-        change_folder('INBOX', 'INBOX', ttreeBox);  
+        draw_new_tree_folder();
+        change_folder('INBOX', 'INBOX'); 
     }
 }
@@ -283,11 +280,14 @@
         else{
             window.clearInterval(expresso_mail_archive.timer);
-            write_msg(get_lang('MailArchiver does not seems to be running or installed at this workstation, local messages are disabled. Check it out!'),true);
+            write_msg(get_lang('MailArchiver does not seems to be running or installed at this workstation, local messages are disabled. Check it out!'),false);
+            expresso_mail_archive.enabled = false;
+            expresso_mail_archive.turnOffLocalTreeStructure();
         }
     }
     else{
         window.clearInterval(expresso_mail_archive.timer);
-        write_msg(get_lang('MailArchiver does not seems to be running or installed at this workstation, local messages are disabled. Check it out!'),true);
-        expresso_mail_archive.enabled = false;        
+        write_msg(get_lang('MailArchiver does not seems to be running or installed at this workstation, local messages are disabled. Check it out!'),false);
+        expresso_mail_archive.enabled = false;
+        expresso_mail_archive.turnOffLocalTreeStructure(); 
     }
     //window.alert('fooArc set to null');
@@ -301,4 +301,5 @@
     write_msg(get_lang('Mail Archiver is not responding. There is some communicating issue hang it up. Some services may not work properly. Check it out!'));
     obj.DeactivateStatusListener(obj);
+    //draw_new_tree_folder();
     return;
 }
@@ -322,5 +323,5 @@
             expresso_mail_archive.DeactivateResources(expresso_mail_archive);            
         }
-        else
+        //else
             //window.alert('ok');
         
@@ -351,6 +352,6 @@
     obj.SystemCheck();
     obj.ActivateStatusListener(obj);
-    connector.resetProgressBarText();
-    //auto_refresh();
+    //connector.resetProgressBarText();
+    auto_refresh();
 }
 
@@ -1211,9 +1212,9 @@
     }    
     catch(e){
-        if(!expresso_mail_archive.enabled)
+        if (!expresso_mail_archive.enabled)
             write_msg(get_lang('MailArchiver does not seems to be running or installed at this workstation, local messages are disabled. Check it out!'),false);
         else{
             window.clearInterval(expresso_mail_archive.timer);
-            write_msg(get_lang('There is something wrong with MailArchiver environment. Contact you support'),true);
+            write_msg(get_lang('There is something wrong with MailArchiver environment. Contact you support'), false);
             expresso_mail_archive.enabled = false;
             expresso_mail_archive.turnOffLocalTreeStructure();
@@ -1226,7 +1227,7 @@
 MailArchiver.prototype.getFaultInfoOperationOK = function(faultinfo){
     try{
-        write_msg(get_lang('MailArchiver remote service reports the following error:', true) + faultinfo.getReturn().getSoapFaultString());
+        write_msg(get_lang('MailArchiver remote service reports the following error:', false) + faultinfo.getReturn().getSoapFaultString());
     } catch(e){
-        write_msg(get_lang('The archive service reports a unknown error. Try to refresh your browser screen', true));
+        write_msg(get_lang('The archive service reports a unknown error. Try to refresh your browser screen', false));
     }
     expresso_mail_archive.resetObject();
@@ -1234,4 +1235,5 @@
     window.setTimeout("eval('document.getElementById(\"main_title\").innerHTML =\"Expresso Mail\"')",3000);        
     connector.purgeCache();
+    expresso_mail_archive.turnOffLocalTreeStructure();
 }
 
@@ -1239,7 +1241,7 @@
 MailArchiver.prototype.getFaultInfoOperationFailure = function(errorCode, errorDesc){
     try{
-        write_msg(get_lang('SoapFault capture fails at:' + errorCode + ' | ' + errorDesc, true));
+        write_msg(get_lang('SoapFault capture fails at:' + errorCode + ' | ' + errorDesc, false));
     } catch(e){
-        write_msg(get_lang('Service error mapping', true));
+        write_msg(get_lang('Service error mapping', false));
     }    
 }
@@ -1262,5 +1264,5 @@
     //window.alert('callback de createfolderoperationok');
     draw_tree_local_folders();
-    expresso_mail_archive.drawdata.treeObject._drawn = true;
+    //expresso_mail_archive.drawdata.treeObject._drawn = true;
     //ttreeBox.update_folder();    
 }
@@ -2072,54 +2074,5 @@
 
 MailArchiver.prototype.turnOffLocalTreeStructure = function (){
-    var disabled_local_span = document.getElementById('llocal_disabledtree_folders');
-
-    if((!disabled_local_span) && (!document.getElementById('services_retry'))){
-        var n_LocalDisabled = new dNode({id: "local_disabled", caption: get_lang('Offline'), onClick: "services_retry()", plusSign:false});
-        tree_folders.add(n_LocalDisabled, 'local_root');
-                            
-        var disabled_local_span = document.getElementById('llocal_disabledtree_folders');
-        disabled_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_services.png)";
-        var service_retry = document.createElement("SPAN");
-        service_retry.id = 'services_retry';
-        service_retry.className = 'clean_trash';
-        service_retry.style.cursor = 'pointer';
-        service_retry.onclick = function () {services_retry();};
-        service_retry.innerHTML = "["+get_lang("Retry")+"]";
-        service_retry.title= get_lang("Reconect to MailArchiver services");
-        service_retry.onmouseover = function() {service_retry.style.color="red";};
-        service_retry.onmouseout= function() {service_retry.style.color="#666666";}; //#114FA4
-        disabled_local_span.parentNode.appendChild(service_retry);
-                            
-        var div_ma_host = document.createElement('div');
-        div_ma_host.id = 'div_login_ma_host';
-        div_ma_host.style.position = 'absolute';
-        div_ma_host.style.padding = '0px';
-        div_ma_host.style.margin = '0px';
-        div_ma_host.style.top = '25px';
-        div_ma_host.style.left = '0px';
-        div_ma_host.style.width = '145px';
-        div_ma_host.style.height = '80px';
-        div_ma_host.style.border = '1px solid #CCCCCC';
-        div_ma_host.style.backgroundColor = '#F0F0F0';
-        div_ma_host.style.fontWeight = 'normal';
-        disabled_local_span.appendChild(div_ma_host);
-        div_ma_host.innerHTML = '<p><b>'+get_lang('In trouble?')+'</b></p><p>&rarr; ' + get_lang('Try to access') + '<br/><a href="' + mail_archive_protocol + "://" + mail_archive_host + ":" + mail_archive_port + '/admin" target="_blank" title="MailArchiver Admin">'+get_lang('MailArchiver admin console')+'.</p>';                            
-    }
-    //Only creates the MA login linkage
-    else{
-        var div_ma_host = document.createElement('div');
-        div_ma_host.id = 'div_login_ma_host';
-        div_ma_host.style.position = 'absolute';
-        div_ma_host.style.padding = '0px';
-        div_ma_host.style.margin = '0px';
-        div_ma_host.style.top = '25px';
-        div_ma_host.style.width = '145px';
-        div_ma_host.style.height = '80px';
-        div_ma_host.style.border = '1px solid #CCCCCC';
-        div_ma_host.style.backgroundColor = '#F0F0F0';
-        div_ma_host.style.fontWeight = 'normal';
-        disabled_local_span.appendChild(div_ma_host);
-        div_ma_host.innerHTML = '<p><b>'+get_lang('In trouble?')+'</b></p><p>&rarr; ' + get_lang('Try to access') + '<br/><a href="' + mail_archive_protocol + "://" + mail_archive_host + ":" + mail_archive_port + '/admin" target="_blank" title="MailArchiver Admin">'+get_lang('MailArchiver admin console')+'.</p>';                                                        
-    }    
+     draw_new_tree_folder();  
 }
 
Index: /sandbox/2.5.0-expresso1/expressoMail1_2/js/main.js
===================================================================
--- /sandbox/2.5.0-expresso1/expressoMail1_2/js/main.js	(revision 7234)
+++ /sandbox/2.5.0-expresso1/expressoMail1_2/js/main.js	(revision 7270)
@@ -4898,5 +4898,5 @@
         if ((expresso_mail_archive.enabled == null) && (expresso_mail_archive.timer == null) && (expresso_mail_archive.counter > 0)){
             connector.hideProgressBar();
-            connector.resetProgressBarText();
+            //connector.resetProgressBarText();
             write_msg(get_lang('Sorry, but you need to reload this web page. Click at reload page at web browsing top navigation.'));
             return;
@@ -4904,5 +4904,5 @@
 
         if (arguments.length == 0){
-           connector.setProgressBarText(get_lang('Trying to communicate with Mail Archiver...'));
+           write_msg(get_lang('Trying to communicate with Mail Archiver...'));
         }
 
@@ -4967,5 +4967,5 @@
         write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!'));
         connector.hideProgressBar();
-        connector.resetProgressBarText();
+        //connector.resetProgressBarText();
         check_services_tryouts = 1;
     }
@@ -4975,10 +4975,10 @@
 function check_services_restart(){
     try{
-        connector.setProgressBarText(get_lang('Wait: attempt %1 from %2...', check_services_tryouts, check_services_tryouts_limit));
+		write_msg(get_lang('Wait: attempt %1 from %2...', check_services_tryouts, check_services_tryouts_limit));
         if(check_services_tryouts <= 5){
             try{
                 ArchiveServices = new web_service_mailarchiver_serpro__ArchiveServices();
                 ArchiveServices.url = mail_archive_protocol + "://" + mail_archive_host + ":" + mail_archive_port + "/arcserv/ArchiveServices";
-                window.clearInterval(ttintval2);
+                window.clearInterval(ttintval);
                 expresso_mail_archive.Restart(expresso_mail_archive);
             }
@@ -4986,5 +4986,5 @@
                 check_services_tryouts++;
                 window.clearInterval(ttintval);
-                ttintval2 = window.setTimeout('services_retry(true)',1);
+                ttintval = window.setTimeout('services_retry(true)',1);
             }
         }
@@ -4992,5 +4992,5 @@
             write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!'));
             connector.hideProgressBar();
-            connector.resetProgressBarText();
+            //connector.resetProgressBarText();
             check_services_tryouts = 1;
         }
@@ -4999,5 +4999,5 @@
         write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!'));
         connector.hideProgressBar();
-        connector.resetProgressBarText();
+        //connector.resetProgressBarText();
         check_services_tryouts = 1;
     }
