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 5048)
+++ /sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/mail_archiver.js	(revision 5070)
@@ -155,4 +155,5 @@
     this.drawdata = null;
     this.onprocess = false;
+    this.folder_data = false;
     this.queryconfig = new MAQueryConfig();
     this.pattern = new MAPattern();
@@ -674,4 +675,5 @@
             //var folderData = new Array(folderlist.getReturn()[i].getName(), folderlist.getReturn()[i].getMessageCount(), folderChild, folderlist.getReturn()[i].getId(), folderlist.getReturn()[i].getParentId(), folderlist.getReturn()[i].getPath());
             var folderData = {name: folderlist.getReturn()[i].getName(), messages: folderlist.getReturn()[i].getMessageCount(), haschild: folderChild, id: folderlist.getReturn()[i].getId(), parentid: folderlist.getReturn()[i].getParentId(), path: folderlist.getReturn()[i].getPath()};
+            //window.alert('folder ' + folderData.name + ' tem ' + folderData.messages + ' mensagens.');
             lfolders.push(folderData);
         }
@@ -875,4 +877,10 @@
 MailArchiver.prototype.getFolderInfoOperationFailure = function (ServiceFault){
     window.alert('getFolderInfo service fails...\n->' + ServiceFault.getReturn()); 
+    expresso_mail_archive.folder_data = true;
+}
+
+function foo(){
+    var a = 0;
+    a++;
 }
 
@@ -893,5 +901,6 @@
         
         //window.alert('vai chamar o listMessages com testing_data = ' + testing_data);
-        
+        expresso_mail_archive.getFolderInfo(folderid);     
+        //window.alert('HÃ¡ ' + expresso_mail_archive.folder.nummessages +' no folder ' + expresso_mail_archive.folder.name);
         ArchiveServices.listMessages(expresso_mail_archive.listMessagesOperationOK, expresso_mail_archive.listMessagesOperationFailure, sessid, testing_data);
     }
@@ -938,4 +947,14 @@
 }
 
+MailArchiver.prototype.getFolderMessagesNumber = function(){
+    var n = 0;
+    for(var i=0; i < expresso_mail_archive.folders.length; i++){
+        if(expresso_mail_archive.folders[i]["id"] == expresso_mail_archive.currentfolder){
+            n = expresso_mail_archive.folders[i]["messages"];
+        }
+    }
+    return(n);
+}
+
 MailArchiver.prototype.drawMessagesList = function(){
     var data_to_draw = expresso_mail_archive.drawdata.messagesList;  
@@ -950,10 +969,14 @@
         }
     }
-
+    //var folder_num_msgs = expresso_mail_archive.getFolderMessagesNumber();
+    var folder_num_msgs = expresso_mail_archive.folder.nummessages;
+    //window.alert('num = ' + folder_num_msgs);
     alternate_border(0);
     Element("border_id_0").innerHTML = "&nbsp;" + lang_folder(fcaption) + '&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">&nbsp;</span> / <span id="tot_m"></span>]</font>';
     draw_box(data_to_draw, 'local_' + expresso_mail_archive.currentfolder, true);
-    draw_paging(expresso_mail_archive.drawdata.messagesList.length);
-    Element("tot_m").innerHTML = expresso_mail_archive.drawdata.messagesList.length;
+    //draw_paging(expresso_mail_archive.drawdata.messagesList.length);
+    //draw_paging(preferences.max_email_per_page);
+    draw_paging(folder_num_msgs);
+    Element("tot_m").innerHTML = folder_num_msgs;
     //update_menu();
     
@@ -1034,5 +1057,6 @@
 
 MailArchiver.prototype.Query = function(offlow, offup, qdata){
-    var querystring = this.queryconfig.query(offlow, preferences.max_email_per_page, qdata);
+    window.alert('Query offlow = ' + offlow + ' - offup= ' + offup); 
+    var querystring = this.queryconfig.query(offlow, offup, qdata);
     this.listMessages();
 }
Index: /sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/MAQueryConfig.js
===================================================================
--- /sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/MAQueryConfig.js	(revision 5048)
+++ /sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/MAQueryConfig.js	(revision 5070)
@@ -63,4 +63,5 @@
    //expresso default argument list => new Array(baseFolder,msg_range_begin,emails_per_page,sort_box_type,sort_box_reverse,preview_msg_subject,preview_msg_tip);
    this.setFolder(data_default[0]);
+   //window.alert('vai setar defaults low e high com ' + data_default[1] +  ' - ' + data_default[2]);
    this.setBounds(data_default[1], data_default[2]);
    
@@ -107,4 +108,5 @@
 //setbounds up and down
 MAQueryConfig.prototype.setBounds = function(low, high){
+  //window.alert('setbounds low = ' + low + ' high = ' + high);
   this.lowerIndex = '"@lowerIndex":"'+(parseInt(low)-1)+'",';
   this.upperIndex = '"@upperIndex":"'+(parseInt(high)-1)+'",';
@@ -347,4 +349,5 @@
 //Query criteria (core api)
 MAQueryConfig.prototype.query = function(offsetlow,offsethight, criterialist){
+  //window.alert('MAquery low = ' + offsetlow + ' - hight = ' + offsethight);
   if ((offsetlow) && (offsethight))
     this.setBounds(offsetlow, offsethight);
@@ -355,4 +358,5 @@
   //window.alert('em qc com lower = ' + this.lowerIndex + ' e upper = ' + this.upperIndex);
   var querystring = '{"query":{' + this.lowerIndex + this.upperIndex;
+  //window.alert('queryString init = ' + querystring);
   querystring += this.getFrom();
   querystring += this.getTo();
Index: /sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/draw_api.js
===================================================================
--- /sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/draw_api.js	(revision 4972)
+++ /sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/draw_api.js	(revision 5070)
@@ -586,4 +586,5 @@
 var last_folder = 'INBOX';
 function draw_paging(num_msgs){
+        //window.alert('em draw_paging com num_msgs = ' + num_msgs);
 	num_msgs = parseInt(num_msgs);
 	total_pages = 1;
