Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 336)
+++ trunk/expressoMail1_2/js/main.js	(revision 345)
@@ -160,5 +160,5 @@
 			if(data.new_msgs > 0){
 			Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) + parseInt(data.new_msgs); //refresh tab title
-			update_quota();
+			update_quota(get_current_folder());
 			}
 		}
@@ -250,5 +250,5 @@
 	var main_list = Element("tbody_resultsearch_"+border_id.substr(18)).childNodes;	
 	for (j = 0; j < main_list.length; j++)	{
-		var check_box = Element("check_box_message_"+main_list[j].id);
+		var check_box = main_list[j].firstChild.firstChild; 
 		if(check_box && check_box.checked) {
 			selected_messages += main_list[j].id + ',';
@@ -321,13 +321,17 @@
 			return false;
 		}
-
-
+		
 		Element('chk_box_select_all_messages').checked = false;
-		mail_msg = Element("tbody_box");
-		//mail_msg = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild;
+		
+		mail_msg = ( Element("divScrollMain_"+numBox) ) ? Element("divScrollMain_"+numBox).firstChild.firstChild : Element("divScrollMain_0").firstChild.firstChild;
+		if (! mail_msg)
+				mail_msg = Element("tbody_box");
 		data.msgs_number = data.msgs_number.split(",");
 
-		var msg_to_delete;		
-		all_search_msg = msgs_number.split(',');
+		var msg_to_delete;
+		if( typeof(msgs_number) == 'string' )
+			all_search_msg = msgs_number.split(',');
+		else if( typeof(msgs_number) == 'number')
+			all_search_msg = msgs_number;
 		for (var i=0; i <= all_search_msg.length; i++)
 		{
@@ -390,6 +394,7 @@
 
 function get_selected_messages(){
-	main = Element("tbody_box");
-//	main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild;
+	main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild;
+	if (! main)
+		main = Element("tbody_box");
 
 	// Get all TR (messages) in tBody.
@@ -516,5 +521,5 @@
 			}
 			else{ 
-				body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>");
+			body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>");
 			}
 			body.contentWindow.document.close();
@@ -545,5 +550,5 @@
 			}
 			else {
-				body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + block_quoted_body + "</body></html>");
+			body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+block_quoted_body+"</body></html>");
 			}
 			body.contentWindow.document.close();
@@ -590,5 +595,5 @@
 			}
 			else {
-				body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>");
+			body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>");
 			}
 			body.contentWindow.document.close();
@@ -635,5 +640,5 @@
 			}
 			else {
-				body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + block_quoted_body + "</body></html>");
+			body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+block_quoted_body+"</body></html>");
 			}
 			body.contentWindow.document.close();
@@ -683,5 +688,5 @@
 			}
 			else {
-				body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc) + "</body></html>");
+			body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)+"</body></html>");
 			}
 			body.contentWindow.document.close();
@@ -716,5 +721,5 @@
 			}
 			else {
-				body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>");
+			body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>");
 			}
 			body.contentWindow.document.close();
Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 325)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 345)
@@ -10,4 +10,5 @@
 	if (Element('dftree_tree_folders')){
 		var update_tree_folders = function(data){
+			build_quota(data);
 			for (var i=0; i<data.length; i++){
 				var folder_unseen = Element('dftree_'+data[i].folder_id+'_unseen');
@@ -34,9 +35,9 @@
 //					}
 					Element('new_m').innerHTML = data[i].folder_unseen ? '<font color="RED">'+data[i].folder_unseen+'</font>' : 0;
-					draw_paging(Element('tot_m').innerHTML);		
+					draw_paging(Element('tot_m').innerHTML);
 				}
 			}
 		}
-		cExecute ("$this.imap_functions.get_folders_list", update_tree_folders);
+		cExecute ("$this.imap_functions.get_folders_list&folder="+current_folder, update_tree_folders);
 		return;
 	}
@@ -114,5 +115,5 @@
 		draw_tree_folders(data);
 		if(data) {
-			update_quota('INBOX');			
+			build_quota(data);			
 			var f_unseen = Element('dftree_'+get_current_folder()+'_unseen');
 			if(f_unseen && f_unseen.innerHTML)
@@ -148,5 +149,4 @@
 			Element("tot_m").innerHTML = data.num_msgs;
 			update_menu();
-			update_quota(folder);
 			return true;
 		}
@@ -157,21 +157,20 @@
 
 function open_folder(folder, folder_name){
-	if (get_current_folder() != folder) {
+	if (get_current_folder()!= folder) {
 		current_folder = folder;
 		var handler_draw_box = function(data){
-			if (!verify_session(data)) 
-				return;
-			Element("border_id_0").innerHTML = "&nbsp;" + lang_folder(folder_name) + '&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">&nbsp;</span> / <span id="tot_m"></span>]</font>';
-			draw_box(data, current_folder);
-			draw_paging(data.num_msgs);
-			Element("tot_m").innerHTML = data.num_msgs;
-			update_menu();
-			update_quota(folder);
-			alternate_border(0);
-		}
-		cExecute("$this.imap_functions.get_range_msgs2&folder=" + current_folder + "&msg_range_begin=1&msg_range_end=" + preferences.max_email_per_page + "&sort_box_type=" + sort_box_type + "&search_box_type=" + search_box_type + "&sort_box_reverse=" + sort_box_reverse + "", handler_draw_box);
+			if(!verify_session(data))
+				return false;
+			numBox++;
+			create_border(folder_name,numBox.toString());
+			draw_box(data, current_folder, false);
+			alternate_border(numBox);
+			return true;
+		}
+		cExecute ("$this.imap_functions.get_range_msgs2&folder="+current_folder+"&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type="+sort_box_type+ "&search_box_type="+ search_box_type +"&sort_box_reverse="+sort_box_reverse+"", handler_draw_box);
 	}
 	else
-		alternate_border(0);
+		alternate_border(numBox);
+	return true;
 }
 
@@ -1845,5 +1844,6 @@
 	}
 	else{
-	div.innerHTML = null;
+	if(div)
+		div.innerHTML = null;
 	value = data['quota_percent'];
 	q_used = data['quota_used'];
@@ -1914,5 +1914,5 @@
 }
 
-function update_quota(folder_id){	
+function update_quota(folder_id){
 	cExecute ("$this.imap_functions.get_quota&folder_id="+folder_id,build_quota);
 }
Index: trunk/expressoMail1_2/js/TreeShow.js
===================================================================
--- trunk/expressoMail1_2/js/TreeShow.js	(revision 320)
+++ trunk/expressoMail1_2/js/TreeShow.js	(revision 345)
@@ -29,5 +29,5 @@
 				tree_folders.getNodeById(get_current_folder())._select();
 		}
-		cExecute ("$this.imap_functions.get_folders_list", handler_update_folders);		
+		cExecute ("$this.imap_functions.get_folders_list&folder="+current_folder, handler_update_folders);		
 	}
 
