Index: trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 41)
+++ trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 46)
@@ -67,9 +67,26 @@
 				$sort_array_msg = imap_sort($mbox_stream, SORTSIZE, $sort_box_reverse, SE_UID);
 				break;
+			case 'UNSEEN':
+			$sort_array_msg = imap_search($mbox_stream,"UNSEEN", SE_UID); // nao lidas
+			break;
+			case 'ANSWERED':
+			$sort_array_msg = imap_search($mbox_stream,"ANSWERED", SE_UID); // repondidas
+			break;
+			case 'SEEN':
+			$sort_array_msg = imap_search($mbox_stream,"SEEN", SE_UID); // lidas
+			break;
+			case 'FLAGGED':
+			$sort_array_msg = imap_search($mbox_stream,"FLAGGED", SE_UID); // importantes
+			break;
+			case 'ALL':
+			$sort_array_msg = imap_search($mbox_stream,SORTARRIVAL,$sort_box_reverse,  SE_UID); // Todas
+			break;
 		}
 		
 		$return = array();
 		$i = 0;
-		for ($msg_range_begin; (($msg_range_begin <= $msg_range_end) && ($msg_range_begin <= count($sort_array_msg))); $msg_range_begin++)
+		$num_msgs = (is_array($sort_array_msg) ? count($sort_array_msg) : 0);
+		if($num_msgs) { 
+			for ($msg_range_begin; (($msg_range_begin <= $msg_range_end) && ($msg_range_begin <= $num_msgs)); $msg_range_begin++)
 		{
 			$msg_number = $sort_array_msg[$msg_range_begin-1];
@@ -122,5 +139,6 @@
 			$i++;
 		}
-		$return['num_msgs'] = imap_num_msg($mbox_stream);		
+		}
+		$return['num_msgs'] = $num_msgs;		
 		return $return;
 	}
@@ -804,4 +822,16 @@
 			case 'SORTSIZE':
 				$sort_array_msg = imap_sort($mbox_stream, SORTSIZE, $sort_box_reverse, SE_UID);
+				break;
+			case 'ANSWERED':
+				$sort_array_msg = imap_search($mbox_stream,"ANSWERED", SE_UID); // repondidas
+				break;
+			case 'SEEN':
+				$sort_array_msg = imap_search($mbox_stream,"SEEN", SE_UID); // lidas
+				break;
+			case 'FLAGGED':
+				$sort_array_msg = imap_search($mbox_stream,"FLAGGED", SE_UID); // importantes
+				break;
+			case 'ALL':
+				$sort_array_msg = imap_search($mbox_stream,SORTARRIVAL,$sort_box_reverse,  SE_UID); // Todas
 				break;
 		}
@@ -1701,5 +1731,5 @@
 	function empty_trash()
 	{
-		$folder = 'INBOX' . $this->imap_delimiter . 'Lixeira';
+		$folder = 'INBOX' . $this->imap_delimiter . 'Trash';
 		$mbox_stream = $this->open_mbox($folder);
 		$return = imap_delete($mbox_stream,'1:*');
@@ -1811,5 +1841,5 @@
 		$params_tmp1['msgs_number'] = $params['msg_number'];
 		$params_tmp1['folder'] = $params['msg_folder'];
-		$params_tmp1['new_folder'] = 'INBOX'.$this->imap_delimiter.'Lixeira';
+		$params_tmp1['new_folder'] = 'INBOX'.$this->imap_delimiter.'Trash';
 		
 		$return_tmp1 = $this->move_messages($params_tmp1);
@@ -1825,5 +1855,5 @@
 		$before_date = date("m/d/Y", strtotime("-".$params['before_date']." day"));
 		$criteria =  'BEFORE "'.$before_date.'"';
-		$mbox_stream = $this->open_mbox('INBOX'.$this->imap_delimiter."Lixeira");
+		$mbox_stream = $this->open_mbox('INBOX'.$this->imap_delimiter."Trash");
 		$messages = imap_search($mbox_stream, $criteria, SE_UID);
 		if (is_array($messages)){
Index: trunk/expressoMail1_2/js/InfoContact.js
===================================================================
--- trunk/expressoMail1_2/js/InfoContact.js	(revision 37)
+++ trunk/expressoMail1_2/js/InfoContact.js	(revision 46)
@@ -25,6 +25,6 @@
 
 	var card = Element("card_cc");
-
-	if(_this.td != td){
+	
+	if(this.td != td){
 		this.email = email;
 		this.td = td;
Index: trunk/expressoMail1_2/js/common_functions.js
===================================================================
--- trunk/expressoMail1_2/js/common_functions.js	(revision 37)
+++ trunk/expressoMail1_2/js/common_functions.js	(revision 46)
@@ -34,7 +34,7 @@
 			div.style.height = defaultHeight - 73;
 	}
-	Element('content_folders').style.height = defaultHeight - 160;	
+	Element('content_folders').style.height = defaultHeight - (is_ie ? 160 : 150);
 	if(Element("divScrollMain"))
-		Element("divScrollMain").style.height 	= defaultHeight - 118;	
+		Element("divScrollMain").style.height 	= defaultHeight - (is_ie ? 118 : 110);	
 }
 // END: FUNCTION RESIZE WINDOW
@@ -654,2 +654,11 @@
 }
 
+function array_search(needle, haystack) {
+	var n = haystack.length;
+	for (var i=0; i<n; i++) {
+		if (haystack[i]==needle) {
+			return true;
+		}
+	}
+	return false;
+}
Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 37)
+++ trunk/expressoMail1_2/js/main.js	(revision 46)
@@ -9,4 +9,6 @@
 		Element("tot_m").innerHTML = data;
 		draw_menu();
+		//Cria Menu Ferramentas
+		ConstructMenuTools();
 	}
 	var save_contacts = function(data){
@@ -132,6 +134,6 @@
 		folder = get_current_folder();
 
-	if ((parseInt(preferences.save_deleted_msg)) && (folder!='INBOX'+cyrus_delimiter+'Lixeira')){
-		move_msgs(folder, msgs_number, border_ID, 'INBOX'+cyrus_delimiter+'Lixeira', 'Lixeira');
+	if ((parseInt(preferences.save_deleted_msg)) && (folder!='INBOX'+cyrus_delimiter+'Trash')){
+		move_msgs(folder, msgs_number, border_ID, 'INBOX'+cyrus_delimiter+'Trash', 'Trash');
 		return;
 	}
@@ -733,10 +735,10 @@
 		if(!verify_session(data))
 			return;
-		if (get_current_folder() == 'INBOX'+cyrus_delimiter+'Lixeira'){
+		if (get_current_folder() == 'INBOX'+cyrus_delimiter+'Trash'){
 			draw_paging(0);
 			kill_current_box();
 		}
-		tree_folders.getNodeById('INBOX'+cyrus_delimiter+'Lixeira').alter({caption: 'Lixeira'});
-		tree_folders.getNodeById('INBOX'+cyrus_delimiter+'Lixeira')._refresh();
+		tree_folders.getNodeById('INBOX'+cyrus_delimiter+'Trash').alter({caption: 'Trash'});
+		tree_folders.getNodeById('INBOX'+cyrus_delimiter+'Trash')._refresh();
 		update_quota();
 		if (data)
Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 41)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 46)
@@ -6,5 +6,8 @@
 function draw_tree_folders(folders){
 	// Check if the tree folders alredy exist.
+	var defaultFolders = new Array("Trash","INBOX", "Sent", "Drafts");	
+	
 	if (Element('dftree_tree_folders')){
+
 		var update_tree_folders = function(data){
 			for (var i=0; i<data.length; i++){
@@ -17,19 +20,23 @@
 				else if (data[i].folder_unseen > 0)
 				{
-					tree_folders.getNodeById(data[i].folder_id).alter({caption: data[i].folder_name + '<font style=color:red>&nbsp(</font><span id="dftree_'+data[i].folder_id+'_unseen" style=color:red>'+data[i].folder_unseen+'</span><font style=color:red>)</font>'});
+					tree_folders.getNodeById(data[i].folder_id).alter({caption:(array_search(data[i].folder_name, defaultFolders) ? get_lang(data[i].folder_name) : data[i].folder_name) + '<font style=color:red>&nbsp(</font><span id="dftree_'+data[i].folder_id+'_unseen" style=color:red>'+data[i].folder_unseen+'</span><font style=color:red>)</font>'});
 					tree_folders.getNodeById(data[i].folder_id)._refresh();
 				}
 				else if (data[i].folder_unseen <= 0)
 				{
-					tree_folders.getNodeById(data[i].folder_id).alter({caption: data[i].folder_name});
+					tree_folders.getNodeById(data[i].folder_id).alter({caption:(array_search(data[i].folder_name, defaultFolders) ? get_lang(data[i].folder_name) : data[i].folder_name)});
 					tree_folders.getNodeById(data[i].folder_id)._refresh();
 				}
 
-				if(data[i].folder_id == get_current_folder()){					
-					var old_new_m = isNaN(parseInt(Element('new_m').innerHTML)) ? parseInt(Element('new_m').firstChild.innerHTML) : parseInt(Element('new_m').innerHTML);
+				if(data[i].folder_id == get_current_folder()){
+					var old_new_m = 0;
+					
+					if(Element('new_m')){
+						old_new_m = isNaN(parseInt(Element('new_m').innerHTML)) ? parseInt(Element('new_m').firstChild.innerHTML) : parseInt(Element('new_m').innerHTML);
+						Element('new_m').innerHTML = data[i].folder_unseen ? '<font color="RED">'+data[i].folder_unseen+'</font>' : 0;
+					}
 					if(!isNaN(old_new_m) && old_new_m < data[i].folder_unseen){
 						Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) + (parseInt(data[i].folder_unseen)-old_new_m);
 					}
-					Element('new_m').innerHTML = data[i].folder_unseen ? '<font color="RED">'+data[i].folder_unseen+'</font>' : 0;
 					draw_paging(Element('tot_m').innerHTML);
 				}
@@ -44,10 +51,11 @@
 		var n_root = new dNode({id:'root', caption:'Minhas Pastas'});
 		tree_folders.add(n_root,'anything'); //Places the root; second argument can be anything.
-	
+
 		for (var i=0; i<folders.length; i++){
+						
 			if (folders[i].folder_unseen > 0)
-				var nn = new dNode({id:folders[i].folder_id, caption:folders[i].folder_name + '<font style=color:red>&nbsp(</font><span id="dftree_'+folders[i].folder_id+'_unseen" style=color:red>'+folders[i].folder_unseen+'</span><font style=color:red>)</font>', onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')", plusSign:folders[i].folder_hasChildren}); 
+				var nn = new dNode({id:folders[i].folder_id, caption:(array_search(folders[i].folder_name, defaultFolders) ? get_lang(folders[i].folder_name) : folders[i].folder_name) + '<font style=color:red>&nbsp(</font><span id="dftree_'+folders[i].folder_id+'_unseen" style=color:red>'+folders[i].folder_unseen+'</span><font style=color:red>)</font>', onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')", plusSign:folders[i].folder_hasChildren}); 
 			else
-				var nn = new dNode({id:folders[i].folder_id, caption:folders[i].folder_name, onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')", plusSign:folders[i].folder_hasChildren}); 
+				var nn = new dNode({id:folders[i].folder_id, caption:(array_search(folders[i].folder_name, defaultFolders) ? get_lang(folders[i].folder_name) : folders[i].folder_name), onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')", plusSign:folders[i].folder_hasChildren}); 
 			
 			if (folders[i].folder_parent == '')
@@ -127,5 +135,5 @@
 			if(!verify_session(data))
 				return;
-			Element("border_id_0").innerHTML = "&nbsp;" + folder_name + '&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">&nbsp;</span> / <span id="tot_m">0</span>]</font>';
+			//Element("border_id_0").innerHTML = "&nbsp;" + folder_name + '&nbsp;<font face="Verdana" size="1" color="#505050">[ '+ (sort_box_type == 'SORTARRIVAL' ? '<span id="new_m">0</span> /' : '') + ' <span id="tot_m">0</span> ]</font>';
 			draw_box(data, get_current_folder());
 			draw_paging(data.num_msgs);
@@ -250,4 +258,5 @@
 // Draw the inbox and another folders
 function draw_box(headers_msgs, msg_folder){
+	Element("border_id_0").innerHTML = "&nbsp;" + msg_folder + '&nbsp;<font face="Verdana" size="1" color="#505050">[ '+ (sort_box_type == 'SORTARRIVAL' ? '<span id="new_m">0</span> /' : '') + ' <span id="tot_m">0</span> ]</font>';
 	kill_current_box();
 	
@@ -383,4 +392,13 @@
 		_divScroll.style.overflow = "-moz-scrollbars-vertical";
 		_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 - 118;
+		// Fim: Redimensiona DIV SCROLL
 	}
 	_divScroll.appendChild(table_element);
@@ -395,42 +413,14 @@
 			_dragArea.makeDragged(tr_element, headers_msgs[i].msg_number, headers_msgs[i].subject, true);
 	}
-
-	var span_T = document.createElement("TABLE");
-	var span_B = document.createElement("TBODY");
-	var span_R = document.createElement("TR");
-	span_R.className = "table_message";
-	var span_options = document.createElement("TD");
-	span_R.appendChild(span_options);
-	span_B.appendChild(span_R);
-	span_T.appendChild(span_B);
-	span_T.border = "0px";
-	span_T.cellPadding = "0px";
-	span_T.cellSpacing = "0px";
-	span_T.width = "100%";
-	span_T.style.height = "10";
-	span_options.style.fontSize = "12";
-	span_options.width = "50%";
-	span_options.innerHTML = 
-	'<span title="'+get_lang("Delete")+'" style="margin-left:8px" class="message_options" onclick=delete_msgs(\'null\',\'selected\',\'null\')>'+get_lang("Delete")+'</span> | '+
-	'<span title="'+get_lang("Move")+'" class="message_options" onclick=wfolders.makeWindow(\"\",\"move_to\")>'+get_lang("Move")+'</span> | '+
-   	'<span title="'+get_lang("Print")+'" class="message_options" onclick=print_all()>'+get_lang("Print")+'</span> | '+
-   	'<span title="'+get_lang("Export")+'" class="message_options" onclick="export_all_selected_msgs()">'+get_lang("Export")+'</span>';
-	var span_D = document.createElement("TD");
-	span_R.appendChild(span_D);
-	span_D.align = "right";
-	span_T.style.borderTop = "1px solid black";
-	span_D.style.fontSize = "12";
-	span_D.innerHTML = '<span title="'+get_lang("View tips")+'" class="message_options" onclick="openWindow(443,520,\'help/dicas.html\',null,\'CartelaExpressoMail.pdf\')">&nbsp;'+get_lang("View tips")+'</span>';
-	span_D.innerHTML +='&nbsp;&nbsp;|&nbsp;<span style="margin-right:25px" title="'+get_lang("Download manual")+'" class="message_options" onclick="download_attachments(null,null,\'../help/CartelaExpressoMail.pdf\',null,null,\'CartelaExpressoMail.pdf\')">&nbsp;'+get_lang("Download manual")+'</span>';
-	span_T.style.visibility = 'hidden';
-	content_id_0.appendChild(span_T);
+	if(!headers_msgs.length) {
+		write_msg( get_lang("No messages found."));
+	}
+
 	var tdFolders  =  Element("folderscol");
 	tdFolders.style.display = preferences.hide_folders == '1'  ? "none" : "";
-	//Cria Menu Ferramentas
-	ConstructMenuTools();
 	alternate_border(0);
 	resizeWindow();
+	draw_footer_box(headers_msgs.num_msgs);	
 	Element('main_table').style.display = '';
-	span_T.style.visibility = 'visible';
 	if(debug) {
 		var _eTime = new Date();
@@ -448,4 +438,5 @@
 		Element('msg_number').value = '';
 	}
+
 
 	if(!is_ie) {
@@ -464,6 +455,7 @@
 							"TreeShow");
 							
-		connector.loadAllScripts(scripts);
-	}
+		connector.loadAllScripts(scripts);	
+	}
+
 }
 
@@ -567,5 +559,5 @@
 		}
 		else{
-			td_element3.onmouseover = function (event) {try {InfoContact.begin(this,headers_msgs.from.email)} catch(e){};};
+			td_element3.onmouseover = function () {try {InfoContact.begin(this,headers_msgs.from.email)} catch(e){};};
 			td_element3.onmouseout = function (){ try {clearTimeout(InfoContact.timeout);} catch(e){}};
 			if (headers_msgs.Draft == 'X'){
@@ -640,4 +632,5 @@
 function sort_box(type){
 	var message_header = Element("message_header_"+type);
+	
 	var handler_draw_box = function(data){
 		draw_box(data, get_current_folder());
@@ -645,15 +638,13 @@
 	}
 
-	if(sort_box_type == type) {
-		if(sort_box_reverse == 1)
-			sort_box_reverse = 0;
-		else
-			sort_box_reverse = 1;
-	}
+	if(sort_box_type == type)
+		sort_box_reverse = sort_box_reverse ? 0 : 1;
 	else
 		sort_box_reverse = 0;
 		
+	// Global variable.
+	sort_box_type = type;
+
 	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="+type+"&sort_box_reverse="+sort_box_reverse+"", handler_draw_box);
-	sort_box_type = type;
 	current_page = 1;
 	update_menu();
@@ -677,9 +668,9 @@
 		default:
 			type_name = get_lang("Date");
-			sort_box_type = 'SORTARRIVAL';
+
 		break;
 	}
 
-	Element("message_header_"+sort_box_type).innerHTML = "<B>"+type_name+"</B><img src ='templates/default/images/arrow_"+(sort_box_reverse == 1 ? 'desc' : 'asc')+"endant.gif'>";
+	Element("message_header_"+(sort_box_type.lastIndexOf("SORT") != "-1" ? sort_box_type : "SORTARRIVAL") ).innerHTML = "<B>"+type_name+"</B><img src ='templates/default/images/arrow_"+(sort_box_reverse == 1 ? 'desc' : 'asc')+"endant.gif'>";
 }
 function draw_message(info_msg, ID){
@@ -2125,2 +2116,45 @@
 	div_address_full.style.display='';
 }
+
+function draw_footer_box(num_msgs){
+	var span_T = document.createElement("TABLE");
+	span_T.style.visibility = 'hidden';	
+	span_T.id = "footer_box";
+	span_T.border = "0px";
+	span_T.cellPadding = "0px";
+	span_T.cellSpacing = "0px";
+	span_T.width = "100%";
+	span_T.style.height = "10";
+	span_T.style.borderTop = "1px solid black";		
+	var span_B = document.createElement("TBODY");
+	var span_R = document.createElement("TR");
+	span_R.className = "table_message";
+	span_B.appendChild(span_R);
+	span_T.appendChild(span_B);
+	var span_options = document.createElement("TD");	
+	span_options.style.fontSize = "12";
+	span_options.innerHTML = 
+	'<span title="'+get_lang("Delete")+'" style="margin-left:8px" class="message_options" onclick=delete_msgs(\'null\',\'selected\',\'null\')>'+get_lang("Delete")+'</span> | '+
+	'<span title="'+get_lang("Move")+'" class="message_options" onclick=wfolders.makeWindow(\"\",\"move_to\")>'+get_lang("Move")+'</span> | '+
+   	'<span title="'+get_lang("Print")+'" class="message_options" onclick=print_all()>'+get_lang("Print")+'</span> | '+
+   	'<span title="'+get_lang("Export")+'" class="message_options" onclick="export_all_selected_msgs()">'+get_lang("Export")+'</span>';
+   	
+	var span_D = document.createElement("TD");	
+	span_D.align = "right";
+	span_D.style.fontSize = "12";
+	span_D.innerHTML = 
+   	 get_lang("List")+': '+
+   	'<span id="span_flag_SORTARRIVAL" style="'+(sort_box_type == 'SORTARRIVAL' ? 'font-weight:bold;text-decoration:underline' : '')+'" title="'+get_lang("All")+'" class="message_options" onclick="sort_box(\'SORTARRIVAL\')">'+get_lang("all")+'</span>, '+
+   	'<span id="span_flag_UNSEEN" style="'+(sort_box_type == 'UNSEEN' ? 'font-weight:bold;text-decoration:underline' : '')+'" title="'+get_lang("Unseen")+'" class="message_options" onclick="sort_box(\'UNSEEN\',this)">'+get_lang("Unseen")+'s</span>, '+
+  	'<span id="span_flag_SEEN" style="'+(sort_box_type == 'SEEN' ? 'font-weight:bold;text-decoration:underline' : '')+'" title="'+get_lang("Seen")+'" class="message_options" onclick="sort_box(\'SEEN\',this)">'+get_lang("Seen")+'s</span>, '+
+   	'<span id="span_flag_ANSWERED" style="'+(sort_box_type == 'ANSWERED' ? 'font-weight:bold;text-decoration:underline' : '')+'" title="'+get_lang("Answered")+'" class="message_options" onclick="sort_box(\'ANSWERED\',this)">'+get_lang("answered").toLowerCase()+'s</span>, '+
+   	'<span id="span_flag_FLAGGED" style="'+(sort_box_type == 'FLAGGED' ? 'font-weight:bold;text-decoration:underline' : '')+'" title="'+get_lang("Flagged")+'" class="message_options" onclick="sort_box(\'FLAGGED\',this)">'+get_lang("important")+'s</span>&nbsp;&nbsp;';
+
+	span_R.appendChild(span_options);
+	span_R.appendChild(span_D);		
+	var content_id_0 = document.getElementById("content_id_0");
+	content_id_0.appendChild(span_T);
+	span_T.style.visibility = 'visible';
+	draw_paging(num_msgs);
+	Element("tot_m").innerHTML = num_msgs;	
+}
Index: trunk/expressoMail1_2/js/color_palette.js
===================================================================
--- trunk/expressoMail1_2/js/color_palette.js	(revision 2)
+++ trunk/expressoMail1_2/js/color_palette.js	(revision 46)
@@ -1,3 +1,5 @@
 // Inicializa palheta de cores;
+
+str
 function cColorPalette(){
 	this.editor;
@@ -12,5 +14,5 @@
 						new Array("#000000","#330000","#663300","#663333","#333300","#003300","#003333","#000066","#330099","#330033"));
 	this.buildPalette();
-}
+};
 
 // funçoes
