Index: branches/2.2/expressoMail1_2/js/abas.js
===================================================================
--- branches/2.2/expressoMail1_2/js/abas.js	(revision 1994)
+++ branches/2.2/expressoMail1_2/js/abas.js	(revision 3018)
@@ -113,4 +113,5 @@
 			return alternate_border(id_value);
 		var ID = id_value;
+		openTab.imapBox[ID] = current_folder;
 	}
 	td = document.createElement("TD");
@@ -124,5 +125,5 @@
 
 	td.setAttribute("align", "right");
-	td.onclick = function(){alternate_border(ID);};
+	td.onclick = function(){alternate_border(ID);resizeWindow()};
 	td.setAttribute("noWrap","true");
         td.alt = borderTitle;
@@ -152,20 +153,6 @@
 	div.style.display='';
 
-	var bar = document.getElementById("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden')
-		offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;
-
-	div.style.height = document.body.clientHeight - offset - (is_ie ? 76 : 86);
 	div.style.overflow = "hidden";
 
-	if(!is_ie) {
-		var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
-		var defaultWidth = document.body.clientWidth - 27;
-		if(!menuHidden)
-			defaultWidth -= Element("folderscol").offsetWidth;
-
-		div.style.width = defaultWidth;
-	}
 	Element("exmail_main_body").insertBefore(div,Element("footer_menu"));
 	alternate_border(ID);
@@ -213,25 +200,25 @@
 		if (body)
 		{
-				var save_link = Element("save_message_options_"+ID);
-				if (openTab.toPreserve[ID] == undefined)
-					openTab.toPreserve[ID] = false;
-				if ((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on') && (save_link.onclick != ''))
-				{
-					var discard_msg = confirm(get_lang("Your message has not been sent. Discard your message?"), "");
-					if (!discard_msg)
-					{
-						Element("border_id_"+ID).onclick = function () { alternate_border(ID);};
-						return;
+			var save_link = Element("save_message_options_"+ID);
+			if (openTab.toPreserve[ID] == undefined)
+				openTab.toPreserve[ID] = false;
+			if ((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on') && (save_link.onclick != ''))
+			{
+				var discard_msg = confirm(get_lang("Your message has not been sent. Discard your message?"), "");
+				if (!discard_msg)
+				{
+					Element("border_id_"+ID).onclick = function () { alternate_border(ID);};
+					return;
+				}
+				else
+				{
+					if (openTab.imapBox[ID] && openTab.imapUid[ID] && !openTab.toPreserve[ID]){
+						delete_msgs(openTab.imapBox[ID], openTab.imapUid[ID].toString(), 0)
+							openTab.toPreserve[ID] = false;
 					}
-					else
-					{
-						if (openTab.imapBox[ID] && !openTab.toPreserve[ID]){
-							delete_msgs(openTab.imapBox[ID], openTab.imapUid[ID].toString(), 0)
-							delete(openTab.imapBox[ID]);
-							openTab.toPreserve[ID] = false;
-							}
-							// Element('to_'+ID).focus(); It crash on IE
-					}
-				}
+					delete(openTab.imapBox[ID]);
+					// Element('to_'+ID).focus(); It crash on IE 
+				}
+			}
 		}
 	}
@@ -273,4 +260,5 @@
 	content = Element('content_id_' + ID);
 	content.parentNode.removeChild(content);
+	resizeWindow();
 	return true;
 }
Index: branches/2.2/expressoMail1_2/js/messages_proxy.js
===================================================================
--- branches/2.2/expressoMail1_2/js/messages_proxy.js	(revision 1969)
+++ branches/2.2/expressoMail1_2/js/messages_proxy.js	(revision 3018)
@@ -90,5 +90,5 @@
 	
 	messages_proxy.prototype.is_local_folder = function(folder) {
-		if(folder.indexOf("local_")==-1)
+		if(typeof(folder) == "undefined" || folder.indexOf("local_")==-1)
 			return false;
 		return true;
@@ -179,6 +179,5 @@
 	messages_proxy.prototype.proxy_move_messages = function (folder, msgs_number, border_ID, new_folder, new_folder_name) {
 		if (! folder || folder == 'null')
-			folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : get_current_folder();
-
+			folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder());
 		if ((this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { //Move entre pastas não locais...
 			if (folder == new_folder){
Index: branches/2.2/expressoMail1_2/js/filters.js
===================================================================
--- branches/2.2/expressoMail1_2/js/filters.js	(revision 810)
+++ branches/2.2/expressoMail1_2/js/filters.js	(revision 3018)
@@ -1,3 +1,3 @@
-var rules_limit = 300;
+var rules_limit = 3000;
 
 	function cfilterSh(){
@@ -67,14 +67,15 @@
 
 		this.showWindow(form);
-		filter.load_rules();
-		this.list_rules();			
-	
+		if ( filter.rulest.length > 0 ) 
+			this.list_rules(); 
+		else 
+			filter.load_rules(this.list_rules); 
 	}
 
 	cfilterSh.prototype.list_rules = function(){
-		if(filter.rulest.length == 0)
-			setTimeout("filters.mount_list()",2500);
-		else
-			this.mount_list();
+			if(filter.criticalError) 
+				return false; 
+			else 
+				filters.mount_list(); 
 	}
 
Index: branches/2.2/expressoMail1_2/js/common_functions.js
===================================================================
--- branches/2.2/expressoMail1_2/js/common_functions.js	(revision 1899)
+++ branches/2.2/expressoMail1_2/js/common_functions.js	(revision 3018)
@@ -35,11 +35,13 @@
 function resizeWindow(){
 
-	var bar = Element("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
-		offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight);	
-
-	var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight;
-	var defaultHeight = screenHeight - offset;
+	var divScrollMain = Element("divScrollMain_"+numBox); 
+	var table_message = Element("table_message"); 
+	var content_folders = Element("content_folders"); 
+	var clientHeight = ((window.innerHeight ? window.innerHeight : document.body.offsetHeight) - 8); 
+	var clientWidth = window.innerWidth ? window.innerWidth : document.body.offsetWidth;
+
+	if(divScrollMain){ 
+		divScrollMain.style.height = (clientHeight - (findPosY(divScrollMain) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight))) + "px"; 
+	} 
 
 	if(typeof(BordersArray) != 'undefined') {
@@ -48,18 +50,20 @@
 			var div = Element("content_id_"+BordersArray[i].sequence);
 
-			// This comented code cause/avoid (!?) Firefox to stuck some request
-			if(div)
-//				div.setAttribute("style","height: "+parseInt(defaultHeight - 90)+"px;");
-				div.style.height = defaultHeight - 90;
-			if(div_scroll)
-//				div_scroll.setAttribute("style","height: "+parseInt(defaultHeight - 130)+"px;");
-				div_scroll.style.height = defaultHeight - 130;
-		}
-	}
-
-	if(Element('content_folders'))
-		Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150);
-	if(Element("divScrollMain_"+numBox))
-		Element("divScrollMain_"+numBox).style.height 	= defaultHeight - (is_ie ? 111 : 110);
+			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"; 
+			} 
+		} 
+	} 
+
+	if(content_folders){ 
+		var search_div = Element("search_div"); 
+		var contentFoldersY = findPosY(content_folders); 
+		content_folders.style.height = (clientHeight - (contentFoldersY + (contentFoldersY > findPosY(search_div) ? 0 : (search_div.clientHeight ? search_div.clientHeight : search_div.offsetHeight) + 5))) + "px"; 
+	} 
 }
 // END: FUNCTION RESIZE WINDOW
@@ -90,4 +94,6 @@
 // Translate words and phrases using user language from eGroupware.
 function get_lang(_key) {
+	if (typeof(_key) == 'undefined') 
+		return false; 
 	var key = _key.toLowerCase();
 	if(array_lang[key])
@@ -116,4 +122,5 @@
 	remove_className(tr_message, 'tr_msg_unread');
 	remove_className(tr_message, 'selected_msg');
+	Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/seen.gif' title='"+get_lang('Seen')+"'>"; 
 	connector.purgeCache();
 	return true;
@@ -131,4 +138,5 @@
 	remove_className(tr_message, 'selected_msg');
 	add_className(tr_message, 'tr_msg_unread');
+	Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/unseen.gif' title='"+get_lang('Unseen')+"'>"; 
 }
 
@@ -215,5 +223,5 @@
 	}
 	if(new_file_name)
-		params = "&newfilename="+new_file_name;
+		params = "&newfilename="+escape(new_file_name);
 	if(encoding)
 		params += "&encoding="+encoding;
@@ -862,4 +870,23 @@
 	}
 }
+
+function borkb(size){ 
+	kbyte = 1024; 
+	mbyte = kbyte*1024; 
+	gbyte = mbyte*1024; 
+	if (!size) 
+		size = 0; 
+	if (size < kbyte) 
+		return size + ' B'; 
+	else if (size < mbyte) 
+		return parseInt(size/kbyte) + ' KB'; 
+	else if (size < gbyte) 
+		if (size/mbyte > 100) 
+			return (size/mbyte).toFixed(0) + ' MB'; 
+		else 
+			return (size/mbyte).toFixed(1) + ' MB'; 
+	else 
+		return parseInt(size/gbyte).toFixed(1) + ' GB'; 
+} 
 
 function validate_date(date){
Index: branches/2.2/expressoMail1_2/js/main.js
===================================================================
--- branches/2.2/expressoMail1_2/js/main.js	(revision 1989)
+++ branches/2.2/expressoMail1_2/js/main.js	(revision 3018)
@@ -59,4 +59,5 @@
 		cExecute ("$this.db_functions.get_dropdown_contacts", save_contacts); //Save contacts needs preferences.
 		cExecute ("$this.imap_functions.get_folders_list&onload=true", update_menu);
+		cExecute ("$this.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1", handler_draw_box);
 		
 	}
@@ -320,6 +321,8 @@
 
 		
-		if(Element("border_id_" + id_msg_read)) 
-			alternate_border(id_msg_read);		
+		if(Element("border_id_" + id_msg_read)) {
+			alternate_border(id_msg_read);	
+			resizeWindow(); 	
+		}
 		else {
 			var border_id = create_border(msg_info.subject, id_msg_read);
@@ -393,10 +396,15 @@
 		if (box.childNodes.length == 0)
 		{
-			td_info = document.createElement("H3");
-			td_info.setAttribute("height", "25%");
+		        var tr_info = document.createElement("TR"); 
+                	var td_info = document.createElement("TD"); 
+                        td_info.setAttribute("colspan", "10"); 
 			td_info.setAttribute("background", "#FFF");
-			td_info.setAttribute("id", "msg_info");
+			tr_info.setAttribute("id", "msg_info");
 			td_info.align = "center";
-			td_info.innerHTML = get_lang("This mail box is empty");
+		        td_info.style.padding = "25px";                  
+               		td_info.style.fontWeight = "bold"; 
+                        td_info.style.fontSize = "11pt";   
+			td_info.innerHTML = get_lang("This mail box is empty");i
+			tr_info.appendChild(td_info); 
 			box.appendChild(td_info);
 		}
@@ -410,9 +418,15 @@
 			var box = Element("tbody_box");
 			table_element.appendChild(box);
-			
+			if (data[0].msg_folder != current_folder) // Bad request 
+                        	return false;
+
 			for (var i=0; i<data.length; i++){
-				var new_msg = this.make_tr_message(data[i], current_folder);				
-				_dragArea.makeDragged(new_msg, data[i].msg_number, data[i].subject, true);
-				eval(data[i].command);
+				var existent = document.getElementById(data[i].msg_number); 
+				if (!existent) 
+				{ 
+					var new_msg = this.make_tr_message(data[i], current_folder);                             
+					_dragArea.makeDragged(new_msg, data[i].msg_number, data[i].subject, true); 
+					eval(data[i].command); 
+				} 
 			}
 			if (! typeof(data.msgs_to_delete) == 'undefined')
@@ -633,6 +647,5 @@
 function move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,show_success_msg){
 	if (! folder || folder == 'null')
-		folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : get_current_folder();
-
+		folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder());
 	if(openTab.type[currentTab] == 1)
 		return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name);
@@ -1334,5 +1347,5 @@
 
 	// IM Module Enabled
-	if( window.parent.loadscript )
+	if( window.parent.loadscript && loadscript.autoStatusIM ) 
 	{
 		config_events( body.contentWindow.document, "onkeypress", loadscript.autoStatusIM );	
@@ -1429,4 +1442,5 @@
 
 function send_message_return(data, ID){
+    watch_changes_in_msg(ID); 
 
     var sign = false;
@@ -1702,4 +1716,5 @@
 function return_save(data,border_id,folder_name,folder_id,message_id)
 {
+	Element("send_button_"+border_id).style.visibility="visible"; 
 	var handler_delete_msg = function(data){ refresh(preferences.alert_new_msg); };
 
@@ -1839,5 +1854,4 @@
 		save_link.className = 'message_options_inactive';
 		watch_changes_in_msg(border_id);
-		Element("send_button_"+border_id).style.visibility="visible";
 		write_msg(get_lang('Your message was save as draft in folder %1.', lang_folder(folder_name)));
 	}		
@@ -1858,5 +1872,5 @@
 		sendButton.style.visibility="hidden";
 
-	if (openTab.imapBox[border_id]) //Gets the imap folder
+	if (openTab.imapBox[border_id] && openTab.type[border_id] != 6 && openTab.type[border_id] != 7) //Gets the imap folder 
 		var folder_id = openTab.imapBox[border_id];
 	else
@@ -2159,13 +2173,16 @@
 		if(!verify_session(data))
 			return;
-		if (get_current_folder() == 'INBOX'+cyrus_delimiter+trashfolder){
-			draw_paging(0);
-			kill_current_box();
-		}
 		tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder).alter({caption: get_lang("Trash")});
 		tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder)._refresh();
 		update_quota(get_current_folder());
-		if (data)
+		if (data){
 			write_msg(get_lang('Your Trash folder was empty.'));
+			if (get_current_folder() == 'INBOX'+cyrus_delimiter+trashfolder){
+				draw_paging(0);
+				kill_current_box();
+				Element('tot_m').innerHTML = 0;
+				Element('new_m').innerHTML = 0;
+			}
+		}
 		else
 			write_msg(get_lang('ERROR emptying your Trash folder.'));
@@ -2386,5 +2403,5 @@
 	else{
 		if(data == 'Post-Content-Length')
-			write_msg(get_lang('The size of this message has exceeded  the limit (%1B).',Element('upload_max_filesize').value));
+			write_msg(get_lang('The size of this message has exceeded  the limit (%1B).', preferences.max_attachment_size ? preferences.max_attachment_size : Element('upload_max_filesize').value));
 		else {	/*
 			* @author Rommel Cysne (rommel.cysne@serpro.gov.br)
Index: branches/2.2/expressoMail1_2/js/connector.js
===================================================================
--- branches/2.2/expressoMail1_2/js/connector.js	(revision 1965)
+++ branches/2.2/expressoMail1_2/js/connector.js	(revision 3018)
@@ -340,4 +340,20 @@
 								if ( typeof data == 'undefined' )
 									data = oxmlhttp.responseText;
+								// Verify user session 
+								if(data && data.nosession){ 
+									// If hold session is setted, dont reload the page ... 
+									if(hold_session) { 
+										if(typeof(write_msg) == "function" && typeof(get_lang) == "function") 
+											write_msg(get_lang("your session could not be verified.")); 
+										else 
+											alert("your session could not be verified."); 
+									} 
+									else 
+										window.location.reload(); 
+
+									delete _thisObject.requests[id]; 
+									_thisObject.requests[id] = null; 
+									return false; 
+								} 
 								if(debug_controller) {
 									document.getElementById("debug_controller").innerHTML += oxmlhttp.responseText;
Index: branches/2.2/expressoMail1_2/js/search.js
===================================================================
--- branches/2.2/expressoMail1_2/js/search.js	(revision 1969)
+++ branches/2.2/expressoMail1_2/js/search.js	(revision 3018)
@@ -203,146 +203,54 @@
 		ttree.make_tree(folders,"div_folders_search","_folders_tree_search","","","","");
 	}
-	
-	//This func returns the most recent date
-	function date_comp(a,b)
-	{
-		var data1 = a.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
-		data1 = data1[0].substr(0, data1[0].indexOf('--'))
-		with ( data1 ) 
-			data1 = Date.UTC(substr(6), substr(3, 2), substr(0, 2));
-		var data2 = b.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
-		data2 = data2[0].substr(0, data2[0].indexOf('--'))
-		with ( data2 )
-			data2 = Date.UTC(substr(6), substr(3, 2), substr(0, 2));
-		return data2 - data1;
-	}
-	function date_comp_reverse(a,b)
-	{
-		return date_comp(b,a);
-	}
-	
-	function box_comp(a,b)
-	{
-	var compare = [];
-	compare[0] = a.substr(0, a.indexOf('--'));
-	compare[0] = compare[0].toLowerCase();
-	var temp=compare[0];
-	compare[1] = b.substr(0, b.indexOf('--'))
-	compare[1] = compare[1].toLowerCase();
-	compare.sort();
-	if (temp != compare[0])
-		return +1;
-	else
-		return -1;
-	}
-	function box_comp_reverse(a,b)
-	{
-		return box_comp(b,a);
-	}
-
-	function who_comp(a,b)
-	{
-	var compare = [];
-	compare[0] = a.substr(a.indexOf('--')+2);
-	compare[0] = compare[0].toLowerCase();
-	var temp=compare[0];
-	compare[1] = b.substr(b.indexOf('--')+2);
-	compare[1] = compare[1].toLowerCase();
-	compare.sort();
-	if (temp != compare[0])
-		return +1;
-	else
-		return -1;
-	}
-	function who_comp_reverse(a,b)
-	{
-		return who_comp(b,a);
-	}
-
-	function subject_comp(a,b)
-	{
-	var compare = [];
-	compare[0] = a.substr(a.indexOf('--')+2);
-	compare[0] = compare[0].substr(compare[0].indexOf('--')+2);
-	compare[0] = compare[0].toLowerCase();
-	var temp=compare[0];
-	compare[1] = b.substr(b.indexOf('--')+2);
-	compare[1] = compare[1].substr(compare[1].indexOf('--')+2);
-	compare[1] = compare[1].toLowerCase();
-	compare.sort();
-	if (temp != compare[0])
-		return +1;
-	else
-		return -1;
-	}
-	function subject_comp_reverse(a,b)
-	{
-		return subject_comp(b,a);
-	}
-
-	function size_comp(a,b)
-	{
-		var data1 = a.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
-		data1 = data1[0].substr(data1[0].indexOf('--')+2)
-		data1 = data1.substr(0,data1.indexOf('--'))
-		var size_a = parseInt(data1.substr(0,data1.indexOf(' ')));
-		if (data1.match("k"))
-			size_a = size_a * 1024;
-		else
-			if (data1.match("m"))
-				size_a = size_a * 1048576;
-		var data2 = b.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
-		data2 = data2[0].substr(data2[0].indexOf('--')+2)
-		data2 = data2.substr(0,data2.indexOf('--'))
-		var size_b = parseInt(data2.substr(0,data2.indexOf(' ')));
-		if (data2.match("k"))
-			size_b = size_b * 1024;
-		else
-			if (data2.match("m"))
-				size_b = size_b * 1048576;
-		return size_b - size_a;
-	}
-	function size_comp_reverse(a,b)
-	{
-		return size_comp(b,a);
-	}
 
 	// Form resultado
 	searchE.prototype.mount_result = function(data,sort_type){
-		var nw_array = new Array;
-		var var_tmp = data.substr(2, data.length - 4);
-		var_tmp  = var_tmp.split("####");
+		if (data == undefined)
+			return;
 		var cont = parseInt(0);
+
+                //This func returns the comparison between criterias 
+                var date_comp = function(a,b){ return a.udate > b.udate;}; 
+                var date_comp_reverse = function(a,b){ return date_comp(b,a);}; 
+                var box_comp = function(a,b){   return a.boxname > b.boxname; } 
+                var box_comp_reverse = function(a,b){   return box_comp(b,a); } 
+                var who_comp = function(a,b){ return a.from > b.from; } 
+                var who_comp_reverse = function(a,b){ return who_comp(b,a); } 
+                var subject_comp = function(a,b){ return a.subject > b.subject; } 
+                var subject_comp_reverse = function(a,b){ return subject_comp(b,a); } 
+                var size_comp = function(a,b){ return a.size > b.size; } 
+                var size_comp_reverse = function(a,b){ return size_comp(b,a); }
+
 		switch (sort_type)
 		{
 			case 'SORTDATE':
-				var_tmp.sort(date_comp);
+				data.sort(date_comp);
 				break;
 			case 'SORTDATE_REVERSE':
-				var_tmp.sort(date_comp_reverse);
+				data.sort(date_comp_reverse);
 				break;
 			case 'SORTBOX':
-				var_tmp.sort(box_comp);
+				data.sort(box_comp);
 				break;
 			case 'SORTBOX_REVERSE':
-                                var_tmp.sort(box_comp_reverse);
+                                data.sort(box_comp_reverse);
                                 break;
 			case 'SORTSUBJECT':
-				var_tmp.sort(subject_comp);
+				data.sort(subject_comp);
 				break;
 			case 'SORTSUBJECT_REVERSE':
-                                var_tmp.sort(subject_comp_reverse);
+                                data.sort(subject_comp_reverse);
 				break;
 			case 'SORTWHO':
-				var_tmp.sort(who_comp);
+				data.sort(who_comp);
 				break;
 			case 'SORTWHO_REVERSE':
-                                var_tmp.sort(who_comp_reverse);
+                                data.sort(who_comp_reverse);
 				break;
 			case 'SORTSIZE':
-				var_tmp.sort(size_comp);
+				data.sort(size_comp);
 				break;
 			case 'SORTSIZE_REVERSE':
-				var_tmp.sort(size_comp_reverse);
+				data.sort(size_comp_reverse);
 				break;
 			default:
@@ -350,13 +258,8 @@
 		}
 
-		for(var i=0; i < var_tmp.length; i++){
-			if(var_tmp[i] != "")
-			{
-				nw_array[cont] = var_tmp[i];
-				cont++;
-			}
-		}
-
-                if( (preferences.search_result_number != '65536') && (nw_array.length > 0) && (nw_array.length >= preferences.search_result_number) ){
+		if(data.length > 0 && showMsg) 
+	                        write_msg(data.length + " "+ get_lang('results found')); 
+                /* This code was lost on merge 
+		if( (preferences.search_result_number != '65536') && (nw_array.length > 0) && (nw_array.length >= preferences.search_result_number) ){
                     nw_array.length = preferences.search_result_number;
                     write_msg(get_lang("More than %1 results. Please, try to refine your search.",preferences.search_result_number));
@@ -365,4 +268,5 @@
                         write_msg(nw_array.length + " "+ get_lang('results found'));
                 }
+		*/
 
 		numBox++;
@@ -386,28 +290,11 @@
 		tbody.id    = "tbody_box_" + numBox;
 
-		for( var i=0; i < nw_array.length; i++){
+		for( var i=0; i < data.length; i++){
 			var tr = document.createElement("TR");
 			tr.style.height = preferences.line_height;
-
-			if (nw_array[i].match(/.*--.*--\w*--\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g) != null) //subject with "--"
-			{
-				var aux1 = nw_array[i].match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
-				aux1 = aux1[0].split("--");
-				nw_array[i] = nw_array[i].substr(0, nw_array[i].indexOf(aux1[0])-2);
-				var aux = [];
-				aux[0] = nw_array[i].substr(0, nw_array[i].indexOf('--'));
-				nw_array[i] = nw_array[i].substr(nw_array[i].indexOf('--')+2);
-				aux[1] = nw_array[i].substr(0, nw_array[i].indexOf('--'));
-				aux[2] = nw_array[i].substr(nw_array[i].indexOf('--')+2);
-				aux = aux.concat(aux1);
-			}
-			else
-			{
-				var aux = nw_array[i].split("--");
-			}
-
-			var mailbox = aux[0];
-			var uid_msg = aux[6];
-			var subject = aux[2];
+			var aux = data[i]; 
+			var mailbox = aux.boxname; 
+			var uid_msg = aux.uid; 
+			var subject = aux.subject; 
 			tr.id = uid_msg+"_s"+global_search;
 
@@ -416,5 +303,5 @@
 			tr.name = mailbox;
 
-			if (aux[5].match("U"))
+			if (aux.flag.match("U"))
 				add_className(tr,'tr_msg_unread');
 			add_className(tr, i%2 != 0 ? 'tr_msg_read2' : 'tr_msg_read');
@@ -432,7 +319,7 @@
 				{
 					td.style.width = "2%";
-					if (aux[5].match('T'))
+					if (aux.flag.match('T'))
 					{
-						attachNum = parseInt(aux[5].substr(aux[5].indexOf('T')+1));
+						attachNum = parseInt(aux.flag.substr(aux.flag.indexOf('T')+1));
 						td1 = "<img src='templates/"+template+"/images/clip.gif' title='"+attachNum +' '+ get_lang('attachment(s)')+"'>";
 					}
@@ -444,8 +331,8 @@
 					td.style.width = "1%";
 					td.id = "td_message_answered_"+uid_msg;
-					if (aux[5].match('X'))
+					if (aux.flag.match('X'))
 						td1 = '<img src=templates/'+template+'/images/forwarded.gif title=Forwarded>';
 					else
-						if (aux[5].match('A'))
+						if (aux.flag.match('A'))
 							td1 = '<img src=templates/'+template+'/images/answered.gif>';
 						else
@@ -456,5 +343,5 @@
 					td.style.width = "1%";
 					td.id = "td_message_important_"+uid_msg;
-					if (aux[5].match("F"))
+					if (aux.flag.match("F"))
 					{
 						add_className(tr, 'flagged_msg');
@@ -474,5 +361,5 @@
 					td.style.width = "14%";
 					td.onclick = _onclick;
-					var nm_box = aux[0].split(cyrus_delimiter);
+					var nm_box = aux.boxname.split(cyrus_delimiter);
 					var td1 = nm_box.pop();
 					td.setAttribute("NoWrap","true");
@@ -493,11 +380,11 @@
 				if( j == 6)
 				{
-					if (aux[1].length > 29)
-						aux[1] = aux[1].substr(0,29) + "...";
+					if (aux.from.length > 29)
+						aux.from = aux.from.substr(0,29) + "...";
 					td.style.width = "20%";
 					td.onclick = _onclick;
 					td.setAttribute("NoWrap","true");
                                         td.style.overflow = "hidden";
-					var td1  =  '<div style="width:100%;overflow:hidden">'+aux[1]+"</div>";
+					var td1  =  '<div style="width:100%;overflow:hidden">'+aux.from+"</div>";
 				}
 				if( j == 7)
@@ -505,12 +392,12 @@
 					var subject_encode = url_encode(subject);
 					if (! subject_encode)
-						aux[2] = get_lang("no subject") + "...";
-					if (aux[2].length > 70)
-						aux[2] = aux[2].substr(0,70) + "...";
+						aux.subject = get_lang("no subject") + "...";
+					if (aux.subject.length > 70)
+						aux.subject = aux.subject.substr(0,70) + "...";
 					td.style.width = "35%";
 					td.onclick = _onclick;
                                         td.setAttribute("NoWrap","true");
                                         td.style.overflow = "hidden";
-					var td1  = aux[2];
+					var td1  = aux.subject;
 
 				}
@@ -520,5 +407,6 @@
 					td.align = "center";
 					td.onclick = _onclick;
-					var td1  = aux[3];
+					var _dat = new Date(aux.udate*1000); 
+                                        var td1 = _dat.getDate()+"/"+(_dat.getMonth()+1)+"/"+_dat.getFullYear(); 
 				}
 				if( j == 9)
@@ -527,11 +415,11 @@
 					td.align = "center";
 					td.onclick = _onclick;
-					var td1  = aux[4];
+					var td1  = borkb(aux.size);
 				}
 				if (j == 10)
 				{
-					if (aux[5].match("U"))
+					if (aux.flag.match("U"))
 						add_className(tr, 'tr_msg_unread');
-					if (aux[5].match("F"))
+					if (aux.flag.match("F"))
 						add_className(tr, 'flagged_msg');
 					var td1 = '';
@@ -550,21 +438,7 @@
 
 	var content_search =  Element('content_id_search_' + numBox);
-	// BEGIN MAKE THE SCROLL HEIGHT		
-	var defaultWidth = document.body.offsetWidth - 31;
-	var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
-	if(!menuHidden)
-		defaultWidth -= Element("folderscol").offsetWidth;			
-	var bar = Element("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
-		offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;		
 	var div_scroll_result = document.createElement("DIV");
 	div_scroll_result.id = "divScrollMain_"+numBox;
-	div_scroll_result.style.height = document.body.clientHeight - offset - 120;
-	content_search.style.height = document.body.clientHeight - offset - 80;
 	div_scroll_result.style.overflow = "auto";
-	div_scroll_result.style.width = defaultWidth - (is_ie ? 7 : 0);
-	// END MAKE THE SCROLL HEIGHT		
-		
 	
 		if(is_ie)
@@ -711,4 +585,5 @@
 			content_search.appendChild(div_scroll_result);
 		}
+		resizeWindow(); 
 	}
 
@@ -923,5 +798,4 @@
 		var handler = function(data){
 			var tmp;
-			var countTmp= new Array();
 
                         var dataTemp = data.split('=sumResults=');
@@ -934,17 +808,12 @@
 				if (tmp!=false) {
 					var tmp2 = tmp.substr(2, data.length - 4);
-					countTmp = tmp.split('####');
-				}
-			}
-//			if((data == "none") && (countTmp.length==0)){alert(get_lang("None result was found."));}
-//			if (preferences.search_result_number == '65536' || (data != 'many results' && countTmp.length < preferences.search_result_number))
-//                        {
-//                            EsearchE.mount_result((data=='none')?tmp:(countTmp.length==0)?data:data+tmp);
-//                        }
-//                        else if (data == 'many results' || countTmp.length >= preferences.search_result_number)
-//                        {
-//                            alert(get_lang("More than %1 results. Please, try to refine your search.",preferences.search_result_number));
-//                        }
-
+	                                } 
+	                        } 
+	                        if((data == "none") || (data.length==0)){alert(get_lang("None result was found."));} 
+	                        else if(data.length > 1000){alert(get_lang("More than %1 results. Please, try to refine your search.",1000));}
+			else if(data == "many results"){alert(get_lang("More than %1 results. Please, try to refine your search.",50));} 
+			else{EsearchE.mount_result(data);}
+
+			/* Lost code on merge
                         if ((sumResults == "none") && (countTmp.length==0)){
                             alert(get_lang("None result was found."));
@@ -953,5 +822,5 @@
                         {
                             EsearchE.mount_result((sumResults=='none')?tmp:(countTmp.length==0)?data:data+tmp);
-                        }
+                        }*/
 
 		}
Index: branches/2.2/expressoMail1_2/js/local_messages.js
===================================================================
--- branches/2.2/expressoMail1_2/js/local_messages.js	(revision 1982)
+++ branches/2.2/expressoMail1_2/js/local_messages.js	(revision 3018)
@@ -119,5 +119,6 @@
 
 	local_messages.prototype.create_objects = function() {
-		if(this.dbGears == null)
+		if(window.google){
+		if (this.dbGears == null)
 			this.dbGears = google.gears.factory.create('beta.database');
 		if(this.localServer == null)
@@ -125,4 +126,5 @@
 		if(this.store == null)
 			this.store = this.localServer.createStore('test-store');
+		}
 	}
 
Index: branches/2.2/expressoMail1_2/js/filter.js
===================================================================
--- branches/2.2/expressoMail1_2/js/filter.js	(revision 1546)
+++ branches/2.2/expressoMail1_2/js/filter.js	(revision 3018)
@@ -11,4 +11,5 @@
 	function cfilter(){
 
+		this.criticalError = false;
 		this.mode_in   = "";
 		this.rulest		 = new Array;
@@ -41,14 +42,21 @@
 
 	
-	cfilter.prototype.load_rules = function()
+	cfilter.prototype.load_rules = function(posHandler, param)
 	{
 		var _this = this;
 		var cont1 = parseInt(0);
 		var cont2 = parseInt(0);
-				
+	
 		if( _this.rulest.length == 0 )
 		{
 			var handler_sieve = function(data)
 			{
+				if (data.toString().indexOf('Error:') == 0) 
+				{
+					_this.criticalError = true;
+					alert(get_lang('The filters service is out of service, try again later...'));
+				}
+				else
+				try{
 				if(data.rule.length > 0){
 					for(var i=0 ; i < data.rule.length; i++)
@@ -64,4 +72,11 @@
 				_this.out_officeR = _this.out_officeR ? trim(_this.out_officeR.toString().replace("\n","")) : "";
 				if(data.mode.length > 0){_this.mode_in = data.mode[0];}
+				}
+				catch(e){
+					_this.criticalError = true;
+					alert(get_lang('The filters service is out of service, try again later...'));
+				}
+				if (typeof(posHandler) == 'function')  
+					posHandler(param);  
 			}
 			if(Element('form_status') != null)
@@ -381,35 +396,37 @@
 		this.reload_rules();
 	}
-	
-	cfilter.prototype.new_rule = function(email){
-
-		if(this.email_deny.length > 0){
-			for(var i=0 ; i < this.email_deny.length; i++){
-				if(this.email_deny[i] == email){
-					alert(get_lang("Sender blocked")+"!");
-					return false;
-				}
-			}
-		}
-
-		// Verifica Email
-		var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i
-    	if(!emailReg.test(email)){
-			alert(get_lang("Inform a valid e-mail!"));
-			return false;
-		}
-
-		this.load_rules();
-		if(confirm(get_lang("Do you want to block this e-mail?"))){
-			new_r = "&&ENABLED&&" + email + "&&&&&&discard&&&&0&&&&&&0";
-//			setTimeout("filter.e_newrule('" + new_r + "')",2000);		
-			if (filter.e_newrule(new_r)){
-				this.email_deny.push(email);
-				write_msg(get_lang("The sender was blocked"));							
-			}else
-				write_msg(get_lang("You have reached the maximum number of rules"));
-		}
-	}
-	
+
+cfilter.prototype.new_rule = function(email){
+
+	var createFilter = function (param){ 
+		if (filter.criticalError){ 
+			alert(get_lang('The filters service is out of service, try again later...')); 
+			return false; 
+		} 
+		if(filter.rulest.length > 0){ 
+			var blockedReg = new RegExp('#rule&&[0-9]+&&ENABLED&&'+param+'&&&&&&discard&&&&0&&&&&&0'); 
+			for(var i=0 ; i < filter.rulest.length; i++){ 
+				if(blockedReg.test(filter.rulest[i])){ 
+					alert(get_lang("Sender blocked")+"!"); 
+					return false; 
+				} 
+			} 
+		}                        
+		if(confirm(get_lang("Do you want to block this e-mail?"))){ 
+			new_r = "&&ENABLED&&" + param + "&&&&&&discard&&&&0&&&&&&0"; 
+			//setTimeout("filter.e_newrule('" + new_r + "')",2000);          
+			if (filter.e_newrule(new_r)){ 
+				filter.email_deny.push(new_r); 
+				write_msg(get_lang("The sender was blocked"));                                                   
+			}else 
+				write_msg(get_lang("You have reached the maximum number of rules")); 
+		} 
+	}; 
+	if ( filter.rulest.length > 0 ) 
+		createFilter(email); 
+	else 
+		this.load_rules( createFilter, email ); 
+}
+
 	cfilter.prototype.e_newrule = function(nw_rule)
 	{
@@ -747,5 +764,6 @@
 		var args   = "$this.ScriptS.rec_rules";
 		var params = "arfilter="+aux_rul;
-		cExecute(args,h_filter,params);
+		if(!_this.criticalError)
+			cExecute(args,h_filter,params);
 	}
 
Index: branches/2.2/expressoMail1_2/js/draw_api.js
===================================================================
--- branches/2.2/expressoMail1_2/js/draw_api.js	(revision 1969)
+++ branches/2.2/expressoMail1_2/js/draw_api.js	(revision 3018)
@@ -436,5 +436,4 @@
 			}
 			folders = data;
-			cExecute ("$this.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1", handler_draw_box);
 		}
 }
@@ -726,6 +725,4 @@
 	var _divScroll = document.getElementById("divScrollMain_"+numBox);
 
-	var bar = document.getElementById("toolbar");
-	var offset = 0;
 
 	if(!_divScroll){		
@@ -742,14 +739,4 @@
 		_divScroll.style.width	="99.3%";
 	}
-	// Inicio: Redimensiona DIV SCROLL
-	var bar = Element("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
-		offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight);		
-	var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight;
-	var defaultHeight = screenHeight - offset;		
-	_divScroll.style.height 	= defaultHeight - 110;
-	Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150);
-	// Fim: Redimensiona DIV SCROLL
 	_divScroll.appendChild(table_element);
 	openTab.content_id[numBox].appendChild(_divScroll);
@@ -758,10 +745,15 @@
 
 		if (headers_msgs.num_msgs == 0){
-			td_info = document.createElement("H3");
-			td_info.setAttribute("height", "25%");
+		        var tr_info = document.createElement("TR"); 
+               		var td_info = document.createElement("TD"); 
+                        td_info.setAttribute("colspan", "10"); 
 			td_info.setAttribute("background", "#FFF");
-			td_info.setAttribute("id", "msg_info");
+			tr_info.setAttribute("id", "msg_info");
 			td_info.align = "center";
+			td_info.style.padding = "25px"; 
+			td_info.style.fontWeight = "bold"; 
+                        td_info.style.fontSize = "11pt"; 
 			td_info.innerHTML = get_lang("This mail box is empty");
+			tr_info.appendChild(td_info); 
 			tbody_element.appendChild(td_info);
 		}
@@ -788,4 +780,8 @@
 	draw_footer_box(headers_msgs.num_msgs);	
 	Element('main_table').style.display = '';
+	if(is_ie6)      // Stupid Fixing on IE6. 
+		setTimeout("resizeWindow()",1); 
+	else 
+		resizeWindow(); 
 	if(debug) {
 		var _eTime = new Date();
@@ -954,4 +950,16 @@
 		_img_sent.src 	 = "templates/"+template+"/images/sent.gif";
 
+
+
+		var td_element25 = document.createElement("TD"); 
+		td_element25.className = "td_msg"; 
+		td_element25.setAttribute("width", "1%"); 
+		td_element25.id = "td_message_unseen_"+headers_msgs.msg_number; 
+		if ((headers_msgs.Unseen == 'U') || (headers_msgs.Recent == 'N')) 
+			td_element25.innerHTML = "<img src ='templates/"+template+"/images/unseen.gif' title='"+get_lang('Unseen')+"'>"; 
+		else 
+			td_element25.innerHTML = "<img src ='templates/"+template+"/images/seen.gif' title='"+get_lang('Seen')+"'>"; 
+
+
 		td_element3 = document.createElement("TD");
 		td_element3.className = "td_msg";
@@ -964,5 +972,5 @@
 		if (typeof(headers_msgs.from) == 'undefined')
 			return false;
-		if(headers_msgs.from.email.toLowerCase() == Element("user_email").value)
+		if( headers_msgs.from.email && headers_msgs.from.email.toLowerCase() == Element("user_email").value )
 		{ 
 			td_element3.onmouseover = function () {this.title=headers_msgs.to.email;};
@@ -970,5 +978,5 @@
 				td_element3.innerHTML += "<span style=\"color:red\">("+get_lang("Draft")+") </span>";
 			else{				
-				if(headers_msgs.to.email.toLowerCase() != Element("user_email").value)
+				if(headers_msgs.to.email != null && headers_msgs.to.email.toLowerCase() != Element("user_email").value) 
 					td_element24.innerHTML = "<img valign='center' src ='templates/"+template+"/images/sent.gif' title='"+get_lang('Sent')+"'>";
 			
@@ -1048,5 +1056,6 @@
 		tr_element.appendChild(td_element22);
 		tr_element.appendChild(td_element23);
-        tr_element.appendChild(td_element24);
+	        tr_element.appendChild(td_element24);
+		tr_element.appendChild(td_element25); 
 		tr_element.appendChild(td_element3);
 		tr_element.appendChild(td_element4);
@@ -1115,9 +1124,6 @@
 function draw_message(info_msg, ID){
 	var content = document.getElementById('content_id_' + ID);
-	var defaultWidth = document.body.offsetWidth - 37;
 	
 	var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
-	if(!menuHidden)
-		defaultWidth -= Element("folderscol").offsetWidth;
 	 //////////////////////////////////////////////////////////////////////////////////////////////////////
 	//Make the next/previous buttom.
@@ -1239,5 +1245,5 @@
 	var tbody_message = document.createElement("TBODY");
 	table_message.border = "0";
-	table_message.width = defaultWidth ;
+	table_message.width = "100%"; 
 
 	//////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1268,5 +1274,5 @@
 
 	td.innerHTML = _name.bold() + ', ' + info_msg.smalldate;
-	if (info_msg.attachments.length > 0)
+	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.names+"'>";
 	
@@ -1296,11 +1302,7 @@
 	option_hide_more.id = 'option_hide_more_'+ID;
 	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('Options')+"</u></b>";
 			this.value = 'hide_options';
-			Element("div_message_scroll_"+ID).style.height = (_height - _offset)+"px";
 			Element('table_message_others_options_'+ID).style.display = '';
 			Element('tr_other_options_'+ID).style.display = '';
@@ -1310,8 +1312,8 @@
 			this.innerHTML = get_lang('Options');
 			this.value = 'more_options';
-			Element("div_message_scroll_"+ID).style.height = (_height + _offset)+"px";
 			Element('table_message_others_options_'+ID).style.display = 'none';
 			Element('tr_other_options_'+ID).style.display = 'none';			
 		}
+		resizeWindow();
 	};
 	var option_mark = document.createElement('TD');
@@ -1510,5 +1512,5 @@
 	var table_message_others_options = document.createElement("TABLE");
 	table_message_others_options.id = 'table_message_others_options_' + ID;
-	table_message_others_options.width =  defaultWidth - 30;
+	table_message_others_options.width = "100%";
 	table_message_others_options.style.display = 'none';
 	table_message_others_options.className = "table_message";
@@ -1619,5 +1621,7 @@
 	}
 	else {
-		to.innerHTML += draw_plugin_cc(ID,toaddress_array[ID]);
+		toAdd = toaddress_array[ID].toString().replace("<","&lt;"); 
+                toAdd = toAdd.replace(">","&gt;"); 
+                to.innerHTML += draw_plugin_cc(ID,toAdd); 
 	}
 	to.className = "header_message_field";
@@ -1747,6 +1751,6 @@
 	tr5.appendChild(subject);
 	tbody_message_others_options.appendChild(tr5);
-	if (info_msg.attachments.length > 0){
-		var tr6 = document.createElement("TR");
+	if ( info_msg.attachments && info_msg.attachments.length > 0 ){	
+	var tr6 = document.createElement("TR");
 		tr6.className = "tr_message_header";
 		var td6 = document.createElement("TD");
@@ -1826,17 +1830,9 @@
 
 
-	// BEGIN MAKE THE SCROLL HEIGHT
-	var bar = document.getElementById("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden')
-		offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;
 	var div = document.createElement("DIV");
 	div.id = "div_message_scroll_"+ID;
 	div.style.background = 'WHITE';
-	div.style.height = document.body.clientHeight - offset - 125;
-	content.style.height = document.body.clientHeight - offset - 90;
 	div.style.overflow = "auto";
-	div.style.width = defaultWidth - (is_ie ? 5 : 0);
-	// END MAKE THE SCROLL HEIGHT
+	div.style.width = "100%"; 
 	table_message_others_options.appendChild(tbody_message_others_options);
 	var tr = document.createElement("TR");
@@ -1844,5 +1840,5 @@
 	td.colSpan = '2';
 	div.appendChild(table_message_others_options);
-	var imgTag = info_msg.body.match(/(<img[^>]*src[^=]*=['"][^'"]*["'][^>]*>)|(<td[^>]*background[^=]*=['"][^'"]*["'][^>]*>)/gi);
+	var imgTag = info_msg.body.match(/(<img[^>]*src[^>=]*=['"]?[^'">]*["']?[^>]*>)|(<[^>]*(style[^=>]*=['"][^>]*background(-image)?:[^:;>]*url\()[^>]*>)/gi);
 	var newBody = info_msg.body;
 	if(!info_msg.showImg && imgTag)
@@ -1859,4 +1855,9 @@
 				for (var i = 0; i < domains.length; i++)
 				{
+					if (imgTag[j].match(/cid:([\w\d]){5,}/) || imgTag[j].match(/src=\"\.\/inc\/show_embedded_attach\.php/g))  
+					{
+						forbidden = false;
+						continue;
+					}
 					imgSource = imgTag[j].match(/=['"](http:\/\/)+[^'"\/]*/);
 					if (imgSource && imgSource.toString().substr(5).match(domains[i]))
@@ -1894,5 +1895,40 @@
 	newBody = newBody.replace("<body","<span");
 	newBody = newBody.replace("<BODY","<span");
-	div.innerHTML+= "<span id='body_"+ID+"'>"+newBody+"</span><br><br>";
+	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; 
+
+	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 ); 
+
+	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{ 
+				if ( links.item( i ).href.indexOf( 'javascript:' ) !== 0 ) 
+					links.item( i ).setAttribute( 'target', '_blank' ); 
+			} 
+		}catch(e){ 
+		} 
+	} 	
 	//////////////////////////////////////////////////////////////////////////////////////////////////////	
 	//Make the thumbs of the message.
@@ -1942,4 +1978,5 @@
 	table_message.appendChild(tbody_message);
 	content.appendChild(table_message);
+	resizeWindow(); 
 	var msg_number = document.createElement('INPUT');
 	msg_number.id = "msg_number_" + ID;
@@ -2481,17 +2518,8 @@
 	tr5.appendChild(td_body);
 	tbody_message.appendChild(tr5);
-// BEGIN MAKE THE SCROLL HEIGHT
-    var defaultWidth = document.body.clientWidth - (is_ie ? 200 : 195);
-	var _bar = document.getElementById("toolbar");
-	var _offset = 0;
-	if(_bar.style.visibility != 'hidden') 
-		_offset = _bar.offsetHeight ? _bar.offsetHeight :  _bar.clientHeight;		
-	var _div = document.createElement("DIV");
+   	var _div = document.createElement("DIV");
 	_div.id = "div_message_scroll_"+ID;
-	_div.style.height = document.body.clientHeight - _offset - 105;
-	content.style.height = document.body.clientHeight - _offset - 80;
 	_div.style.overflow = "auto";
-	_div.style.width = defaultWidth;
-	// END MAKE THE SCROLL HEIGHT
+	_div.style.width = "100%"; 
 
 	// Hide the contac tips and re-position the pallete color.
@@ -2512,4 +2540,5 @@
 	if(!expresso_offline)
 		draw_from_field(sel_from,tr1_1);
+	resizeWindow(); 
 	return ID;
 }
Index: branches/2.2/expressoMail1_2/js/DropDownContacts.js
===================================================================
--- branches/2.2/expressoMail1_2/js/DropDownContacts.js	(revision 804)
+++ branches/2.2/expressoMail1_2/js/DropDownContacts.js	(revision 3018)
@@ -81,4 +81,5 @@
 	for (var i=0; i<match_contacts.length; i++)
 	{
+		match_contacts[i] = unescape(match_contacts[i]); 
 		var aux = match_contacts[i].split("");
 		for(var j in aux){
Index: branches/2.2/expressoMail1_2/js/TreeShow.js
===================================================================
--- branches/2.2/expressoMail1_2/js/TreeShow.js	(revision 1558)
+++ branches/2.2/expressoMail1_2/js/TreeShow.js	(revision 3018)
@@ -147,4 +147,6 @@
 
 		var aux   = ttree.FOLDER.split(cyrus_delimiter);
+		var delimExp = new RegExp(cyrus_delimiter,"g"); 
+	        newp = newp.replace(delimExp,'_'); 
 		var newp2 = "";
 		if( aux[0] == "root"){
