Index: sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/mail_archiver.js
===================================================================
--- sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/mail_archiver.js	(revision 5003)
+++ sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/mail_archiver.js	(revision 5030)
@@ -141,4 +141,6 @@
     this.timer = null;
     this.counter = 0;
+    this.service_count = 0;
+    this.service_count_tryouts = 0;
     this.message_list = new Array();
     this.messageslisted = new Array();
@@ -190,5 +192,5 @@
        var reqHandler = new cxf_cors_request_object();
        reqHandler.init();
-       this.messagesourcehandler = reqHandler.handler;
+       this.messagesourcehandler = reqHandler.handler;  
     }
 }
@@ -227,10 +229,15 @@
     draw_footer_box(get_current_folder());
     auto_refresh();
-
     if(document.getElementById('mail_archiver_retry')){
         document.getElementById('mail_archiver_retry').parentNode.removeChild(document.getElementById('mail_archiver_retry'));
     }
     else{
-        //to do, by now, means nothing
+        //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);  
     }
 }
@@ -238,4 +245,6 @@
 //ServiceStatus callback OK
 MailArchiver.prototype.getServicesStatusOK = function(serviceData){
+    //window.alert('getServicesStatusOK com servicedata = ' + serviceData.getReturn());
+    expresso_mail_archive.service_count = expresso_mail_archive.counter;
     if ((serviceData.getReturn() == "STARTED") || (serviceData.getReturn() == "RUNNING")){
         //If there is no timer activated to services check interval, set it up.
@@ -260,4 +269,6 @@
         write_msg(get_lang('Your preferences are setting to use local messages, but Mail Archiver does not seems to be running or installed at this workstation. By now, we are turning off this feature. Check it out!'),true);
     }
+    //window.alert('fooArc set to null');
+    fooArc = null;
 }
 
@@ -266,5 +277,5 @@
     if(obj.timer)
         window.clearInterval(obj.timer);
-    write_msg(get_lang('3Mail Archiver is not responding. There is some communicating issue hang it up. Some services may not work properly. Check it out!'));
+    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);
     return;
@@ -273,4 +284,5 @@
 //Services Status Fail callback
 MailArchiver.prototype.getServicesStatusFailure = function(serviceData){
+    window.alert('getServicesStatusFailure incomming');
     window.alert('getServicesStatusFailure feature: ' + serviceData);
 }
@@ -278,8 +290,25 @@
 //Service Status handler
 MailArchiver.prototype.getServicesStatus = function(obj){
-    try{
-        if(ArchiveServices){
+    //window.alert('em getServicesStatus obj.enabled = ' + obj.enabled + '\nArchiveServices.enabled = ' + ArchiveServices.enabled + '\nArchiveServices = ' + ArchiveServices);
+    try{
+        //window.alert('on try 01');
+        expresso_mail_archive.service_count_tryouts++;
+        //window.alert('service_count_tryouts = ' + expresso_mail_archive.service_count_tryouts + '\nservice_count = ' + expresso_mail_archive.service_count);
+        
+        if((expresso_mail_archive.service_count_tryouts - expresso_mail_archive.service_count) > 1){
+            //window.alert('problema -> deve desligar');
+            expresso_mail_archive.DeactivateResources(expresso_mail_archive);            
+        }
+        else
+            //window.alert('ok');
+        
+        var fooArc = new web_service_mailarchiver_serpro__ArchiveServices();
+        fooArc.url = mail_archive_protocol + "://" + mail_archive_host + ":" + mail_archive_port + "/arcserv/ArchiveServices";
+        //window.alert('typeof(fooArc) = ' + typeof(fooArc) + '\nfooArc = ' + fooArc);
+        if(fooArc){
             try{
-                ArchiveServices.getState(expresso_mail_archive.getServicesStatusOK, expresso_mail_archive.getServicesStatusFailure, "true");
+                //window.alert('on try 02');
+                fooArc.getState(expresso_mail_archive.getServicesStatusOK, expresso_mail_archive.getServicesStatusFailure, "true");
+                fooArc = null;
             }catch (e){
                 throw "Service failure status: getState";
@@ -290,5 +319,5 @@
         }
     }catch (e){
-        window.alert('getServiceStatus exception:' + e);
+        //window.alert('getServiceStatus exception:' + e);
     }
     expresso_mail_archive.counter = expresso_mail_archive.counter +1;
@@ -308,4 +337,5 @@
 MailArchiver.prototype.Startup = function(){
     this.SystemCheck();
+    this.ActivateStatusListener(this);
 }
 
@@ -626,5 +656,5 @@
     }
     catch (e){
-        window.alert('AQUI MESMO\nOps...List folders fails at:\n' + e.description);
+        //window.alert('AQUI MESMO\nOps...List folders fails at:\n' + e.description);
     } 
 }
@@ -670,5 +700,5 @@
         //If something UI related have been flagged, handle it
         if (expresso_mail_archive.drawdata){
-            //window.alert('com drawdata');
+            //window.alert('com drawdata e treeName = ' + expresso_mail_archive.drawdata.treeName);
             expresso_mail_archive.drawFolderTree();
         }
@@ -690,4 +720,6 @@
     //Add nodes to tree
     if(expresso_mail_archive.folders.length > 0){
+        //window.alert('vai adicionar ' + expresso_mail_archive.folders.length + '  elementos na tree');
+        //window.alert('arvore ja tem ' + evalobjectTree.length + ' nodos');
         for(i=0; i<expresso_mail_archive.folders.length; i++){
             var folder_caption;
@@ -717,4 +749,6 @@
             }
         }
+        //window.alert('refrescando...');
+        //evalobjectTree.update_folder('local_root');
     }
 }
@@ -784,6 +818,10 @@
 //deleteFolder callback OK
 MailArchiver.prototype.deleteFolderOperationOK = function (folderObject){
+    window.alert('delete ok');
     //var fo = IterateIt(folderObject);
     write_msg(get_lang("The folder " + expresso_mail_archive.drawdata.folderName + " was successfully removed"));
+    connector.purgeCache();
+    ttreeBox.name_folder = "root";
+    ttreeBox.update_folder();
     draw_tree_local_folders();
     ttreeBox.update_folder();	
