Index: /trunk/expressoMail1_2/inc/hook_home.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/hook_home.inc.php	(revision 2)
+++ /trunk/expressoMail1_2/inc/hook_home.inc.php	(revision 139)
@@ -1,7 +1,8 @@
 <?php
+	
 	$current_app = 'expressoMail1_2';
 	$current_name	 = 'ExpressoMail 1.2';
   	$homedisplay = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['mainscreen_showmail'];
-  	
+  	$homedisplay = 'True';
 	if($homedisplay=='True')
 	{
@@ -22,7 +23,8 @@
 		$expressoMail	= CreateObject($current_app.'.imap_functions');
 		$mbox_stream = $expressoMail-> open_mbox(); 		
-		$messages	 = imap_sort($mbox_stream, SORTARRIVAL, false, SE_UID);
+		$messages	 = imap_sort($mbox_stream, SORTARRIVAL, true, SE_UID);
 		$num_new_messages = 0;
 		$subjects = array();
+		
 		for ($i = 0; $i < count($messages);$i++)
 		{
@@ -36,18 +38,24 @@
 			$new_m++;
 			if($new_m <= 10) { 				
-				$subject = $expressoMail->decode_string($header->fetchsubject);			
-				if(strlen($subject) > 65)
-					$subject = substr($subject,0,65).' ...';
+				$date_msg = date("d/m/Y",$header->udate);
+				if (date("d/m/Y") == $date_msg)
+					$date = date("H:i",$header->udate);
+				else
+					$date = $date_msg;
+				$subject = $expressoMail->decode_string($header->fetchsubject);				
+				$text = "<div style='overflow:hidden;white-space:nowrap'>".$date." .: ".$subject."</div>";
+				if(strlen($text) > 105)
+					$text = substr($text,0,105).' ...';
 			
 				$link_msg = $GLOBALS['phpgw']->link(
 						'/'.$current_app.'/index.php',
 						'msgball[msgnum]='.$msg_number.'&msgball[folder]=INBOX');
-				$data[] = array('text' => $subject,	'link' => $link_msg	);		
-			}
+				$data[] = array('text' => $text, 'link' => $link_msg);		
+			}			
 		}
-		
+				
 		imap_close($mbox_stream);
-		
-		$title = $current_name." - ".($new_m > 1 ? lang("you have %1 new messages!",$new_m) : ($new_m == 1 ? lang("you have 1 new message!") : lang("you have no new messages")));			
+				
+		$title = $current_name." - ".($new_m > 1 ? lang("You have %1 new messages!","<font color=red>".$new_m."</font>") : ($new_m == 1 ? str_replace("1","<font color=red>1</font>",lang("you have 1 new message!")) : lang("you have no new messages")));			
 		$GLOBALS['phpgw']->translation->add_app($current_app);
 
@@ -81,5 +89,6 @@
 			$portalbox->set_controls($key,$value);
 
-		$portalbox->data = $data;			
+		$portalbox->data = $data;
+					
 		echo "\n".'<!-- BEGIN Mailbox info -->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n";
 	}
Index: /trunk/expressoMail1_2/js/shortcut.js
===================================================================
--- /trunk/expressoMail1_2/js/shortcut.js	(revision 135)
+++ /trunk/expressoMail1_2/js/shortcut.js	(revision 139)
@@ -224,6 +224,22 @@
 
 /* ExpressMail Functions */
+var shift_up_count = 0;
+var shift_down_count = 0;
 shortcut.add("N",function(){ new_message("new","null"); },{'disable_in_input':true});
-shortcut.add("Esc",function(){ delete_border(get_msg_id(), 'false'); },{'disable_in_input':false});
+
+shortcut.add("Esc",function(){
+	var window_closed = false;
+	for(var window in arrayJSWin)
+	{
+		if (arrayJSWin[window].visible)
+		{
+			arrayJSWin[window].close();
+			window_closed = true;
+		}
+	}
+	if (!window_closed)
+		delete_border(get_msg_id(), 'false');
+},{'disable_in_input':false});
+
 shortcut.add("I",function(){ exec_msg_action('print'); },{'disable_in_input':true});
 shortcut.add("E",function(){ exec_msg_action('forward'); },{'disable_in_input':true});
@@ -232,4 +248,58 @@
 	if ( Element('border_id_0').className==='menu-sel' )
 	{
+		var selected_msgs = '';
+		var current_folder = get_current_folder();
+		all_messages = Element('tbody_box').childNodes;
+		
+		for (var i=0; i < all_messages.length; i++)
+			if (all_messages[i].style.backgroundColor != '')
+				selected_msgs += all_messages[i].id + ',';
+		
+		selected_msgs = selected_msgs.substring(0,(selected_msgs.length-1));
+		delete_msgs(current_folder, selected_msgs, 'null');
+	}
+	else
+		exec_msg_action('delete');
+}
+,{'disable_in_input':true});
+
+shortcut.add("Ctrl+Up",function(){ exec_msg_action('previous'); },{'disable_in_input':true});
+shortcut.add("Ctrl+Down",function(){ exec_msg_action('next'); },{'disable_in_input':true});
+if (is_ie){
+	shortcut.add("down",function(){ select_msg('null', 'down'); },{'disable_in_input':false});
+	shortcut.add("up",function(){ select_msg('null', 'up'); },{'disable_in_input':false});
+	shortcut.add("Shift+down",function(){
+		if (shift_up_count > 0)
+			unselect_top_msg();
+		else
+			select_bottom_msg();
+	},{'disable_in_input':false, 'propagate':false});
+	shortcut.add("Shift+up",function(){
+		if (shift_down_count > 0)
+			unselect_bottom_msg();
+		else
+			select_top_msg();
+	},{'disable_in_input':false, 'propagate':false});
+}
+else{
+	shortcut.add("down",function(){ select_msg('null', 'down'); },{'type':'keypress', 'disable_in_input':false});
+	shortcut.add("up",function(){ select_msg('null', 'up'); },{'type':'keypress', 'disable_in_input':false});
+	shortcut.add("Shift+down",function(){
+		if (shift_up_count > 0)
+			unselect_top_msg();
+		else
+			select_bottom_msg();
+	},{'type':'keypress','disable_in_input':false, 'propagate':false});
+	shortcut.add("Shift+up",function(){
+		if (shift_down_count > 0)
+			unselect_bottom_msg();
+		else
+			select_top_msg();
+	},{'type':'keypress','disable_in_input':false, 'propagate':false});
+}
+
+shortcut.add("return",function(){
+	if ( Element('border_id_0').className==='menu-sel' )
+	{
 		all_messages = Element('tbody_box').childNodes;
 		for (var i=0; i < all_messages.length; i++)
@@ -237,28 +307,4 @@
 			if (all_messages[i].style.backgroundColor != '')
 			{
-				delete_msgs(get_current_folder(), all_messages[i].id, 'null');
-				return;
-			}
-		}
-	}
-	else
-		exec_msg_action('delete');
-}
-,{'disable_in_input':true});
-
-shortcut.add("Ctrl+Up",function(){ exec_msg_action('previous'); },{'disable_in_input':true});
-shortcut.add("Ctrl+Down",function(){ exec_msg_action('next'); },{'disable_in_input':true});
-
-shortcut.add("down",function(){ select_msg('null', 'down'); },{'disable_in_input':false});
-shortcut.add("up",function(){ select_msg('null', 'up'); },{'disable_in_input':false});
-
-shortcut.add("return",function(){
-	if ( Element('border_id_0').className==='menu-sel' )
-	{
-		all_messages = Element('tbody_box').childNodes;
-		for (var i=0; i < all_messages.length; i++)
-		{
-			if (all_messages[i].style.backgroundColor != '')
-			{
 				Element("td_who_" + all_messages[i].id).onclick();
 				return;
@@ -269,4 +315,8 @@
 ,{'disable_in_input':true});
 
+shortcut.add("f9",function(){
+	Element("em_refresh_button").onclick();
+	return;
+},{'disable_in_input':true});
 
 function exec_msg_action(action)
@@ -300,4 +350,10 @@
 function select_msg(msg_number, keyboard_action)
 {
+	if ( Element('border_id_0').className != 'menu-sel' )
+		return;
+	
+	shift_up_count = 0;
+	shift_down_count = 0;
+
 	if (msg_number != 'null')
 	{
@@ -319,34 +375,114 @@
 	{
 		all_messages = Element('tbody_box').childNodes;
-		for (var i=0; i < all_messages.length; i++)
-		{
-			if (all_messages[i].style.backgroundColor != '')
-			{
-				if (keyboard_action == 'down')
+		if (keyboard_action == 'down')
+		{
+			if (all_messages[all_messages.length-1].style.backgroundColor != '')
+				return false;
+			
+			for (var i=all_messages.length-1; i >=0; i--)
+			{
+				if (all_messages[i].style.backgroundColor != '')
 				{
-					if (i+1 <= all_messages.length-1)
-					{
-						all_messages[i].style.color = '';
-						all_messages[i].style.backgroundColor = '';
-				
-						all_messages[i+1].style.color = 'white';
-						all_messages[i+1].style.backgroundColor = '#5194d2';
-					}
-					else
-					{
-						return false;
-					}
+					all_messages[i+1].style.color = 'white';
+					all_messages[i+1].style.backgroundColor = '#5194d2';
+					break;
 				}
-				else if ( (keyboard_action == 'up') && (i-1 >= 0) )
+			}
+			for (; i>=0; i--)
+			{
+				all_messages[i].style.color = '';
+				all_messages[i].style.backgroundColor = '';
+			}
+			return true;
+		}
+		else
+		{
+			if (all_messages[0].style.backgroundColor != '')
+				return false;
+			
+			for (var i=0; i < all_messages.length; i++)
+			{
+				if (all_messages[i].style.backgroundColor != '')
 				{
-					all_messages[i].style.color = '';
-					all_messages[i].style.backgroundColor = '';
-
 					all_messages[i-1].style.color = 'white';
 					all_messages[i-1].style.backgroundColor = '#5194d2';
-				}				
-				return;
-			}
-		}
-	}
-}
+					break;
+				}
+			}
+			for (; i< all_messages.length; i++)
+			{
+				all_messages[i].style.color = '';
+				all_messages[i].style.backgroundColor = '';
+			}
+			return true;
+		}
+	}
+}
+
+function select_bottom_msg()
+{
+	all_messages = Element('tbody_box').childNodes;
+	
+	if (all_messages[all_messages.length-1].style.backgroundColor != '')
+		return;
+	
+	for (var i=all_messages.length-1; i >=0; i--)
+	{
+		if ((all_messages[i].style.backgroundColor != '') && (i+1 <= all_messages.length-1))
+		{
+			shift_down_count++;
+			all_messages[i+1].style.color = 'white';
+			all_messages[i+1].style.backgroundColor = '#5194d2';
+			break;
+		}
+	}
+}
+
+function select_top_msg()
+{
+	all_messages = Element('tbody_box').childNodes;
+	
+	if (all_messages[0].style.backgroundColor != '')
+		return;
+	
+	for (var i=0; i <=all_messages.length-1; i++)
+	{
+		if (all_messages[i].style.backgroundColor != '')
+		{
+			shift_up_count++;
+			all_messages[i-1].style.color = 'white';
+			all_messages[i-1].style.backgroundColor = '#5194d2';
+			break;
+		}
+	}
+}
+
+function unselect_bottom_msg()
+{
+	all_messages = Element('tbody_box').childNodes;
+	for (var i=all_messages.length-1; i >=0; i--)
+	{
+		if (all_messages[i].style.backgroundColor != '')
+		{
+			shift_down_count--;
+			all_messages[i].style.color = '';
+			all_messages[i].style.backgroundColor = '';
+			break;
+		}
+	}
+}
+
+function unselect_top_msg()
+{
+	all_messages = Element('tbody_box').childNodes;
+	for (var i=0; i <=all_messages.length-1; i++)
+	{
+		if (all_messages[i].style.backgroundColor != '')
+		{
+			shift_up_count--;
+			all_messages[i].style.color = '';
+			all_messages[i].style.backgroundColor = '';
+			break;
+		}
+	}
+}
Index: /trunk/expressoMail1_2/js/main.js
===================================================================
--- /trunk/expressoMail1_2/js/main.js	(revision 135)
+++ /trunk/expressoMail1_2/js/main.js	(revision 139)
@@ -51,4 +51,6 @@
 	}
 	else{
+		if (preferences.use_shortcuts == '1')
+			select_msg(msg_info.msg_number, 'null');
 		// Call function to draw message
 		var id_msg_read = msg_info.msg_number +"_r";
@@ -71,7 +73,4 @@
 		set_msg_class_to_read(msg_info['msg_number'], true);
 		
-		if (preferences.use_shortcuts == '1')
-			select_msg(msg_info.msg_number, 'null');
-		
 		if ((msg_info.DispositionNotificationTo) && ((msg_info.Unseen == 'U') || (msg_info.Recent == 'N'))){
 			cExecute ("$this.imap_functions.send_notification&notificationto="+msg_info.DispositionNotificationTo+"&subject="+url_encode(msg_info.subject), handler_sendNotification);
@@ -90,4 +89,8 @@
 			return;
 		if (data.length > 0){
+			var msg_info = document.getElementById('msg_info')
+			if (msg_info != null)
+				main.removeChild(msg_info);
+
 			table_element = Element("table_box");
 			var box = Element("tbody_box");
@@ -101,4 +104,6 @@
 			if(parseInt(alert_new_msg) && data.new_msgs > 0)
 				alert(get_lang("You have %1 new", data['new_msgs'])+" "+(data['new_msgs'] > 1 ? get_lang("messages") : get_lang("message")) +"!");
+			if(data.new_msgs > 0)
+			Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) + parseInt(data.new_msgs);
 		}
 		update_menu();
@@ -107,15 +112,16 @@
 	msg_range_end = (current_page*preferences.max_email_per_page);
 	msg_range_begin = (msg_range_end-(preferences.max_email_per_page)+1);
+	
 	
 	//Get element tBody.
 	main = Element("tbody_box");
 	if(!main)
-		return;
+		return;	
+
 	// Get all TR (messages) in tBody.
 	main_list = main.childNodes;
-	
 	var tmp = '';
 	var string_msgs_in_main = '';
-	
+
 	var len = main_list.length; 
 	for (var j=0; j < len; j++)
@@ -123,5 +129,5 @@
 		
 	string_msgs_in_main = tmp.substring(0,(tmp.length-1));
-	
+	update_quota();
 	cExecute ("$this.imap_functions.refresh&folder="+current_folder+"&msgs_existent="+string_msgs_in_main+"&msg_range_begin="+msg_range_begin+"&msg_range_end="+msg_range_end+"&sort_box_type="+sort_box_type+"&search_box_type="+search_box_type+"&sort_box_reverse="+sort_box_reverse, handler_refresh);
 }
@@ -145,5 +151,8 @@
 			if (msg_to_delete){
 				if ( (msg_to_delete.style.backgroundColor != '') && (preferences.use_shortcuts == '1') )
-					select_msg('null', 'down');
+				{
+					if (!select_msg('null', 'down'))
+						select_msg('null', 'up')
+				}
 				mail_msg.removeChild(msg_to_delete);
 			}
Index: /trunk/expressoMail1_2/js/filter.js
===================================================================
--- /trunk/expressoMail1_2/js/filter.js	(revision 128)
+++ /trunk/expressoMail1_2/js/filter.js	(revision 139)
@@ -1,2 +1,22 @@
+function populatedropdown(dayfield, monthfield, yearfield){
+	var month=['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'];
+	var today=new Date()
+	var dayfield=document.getElementById(dayfield)
+	var monthfield=document.getElementById(monthfield)
+	var yearfield=document.getElementById(yearfield)
+	for (var i=0; i<31; i++)
+		dayfield.options[i]=new Option(i+1, i+1)
+	dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
+	for (var m=0; m<12; m++)
+	monthfield.options[m]=new Option(month[m],m)
+	monthfield.options[today.getMonth()]=new Option(month[today.getMonth()], today.getMonth(), true, true) //select today's month
+	var thisyear=today.getFullYear()
+	for (var y=0; y<7; y++){
+		yearfield.options[y]=new Option(thisyear, thisyear)
+		thisyear+=1
+	}
+	yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
+}
+
 	function cfilter(){
 
@@ -256,5 +276,6 @@
 	 					 "</tr></table></td><td width='52%' valign='top'>"+get_lang('Emails of the account')+":<br><select multiple id='select_2' name='select_2' size='6' style='width:250px'></select>"+
 	 					 "</td></tr><tr><td colspan='3'><hr size='1' width='100%'></td>"+
-	 					 "</tr><tr><td colspan='3'>"+get_lang('During (days off the office)')+": <input type='text' id='select_days' size='3'> "+get_lang('day(s)')+"</td>"+
+	 					 "</tr><tr><td colspan='3'><input name='type' id='interval' checked='checked' type='radio'>"+get_lang('During')+": <input type='text' id='select_days' size='3'> "+get_lang('day(s)')+"</td>"+
+	 					 "</tr><tr><td colspan='3'><input name='type' id='date' type='radio' onChange=\"populatedropdown('daydropdown', 'monthdropdown', 'yeardropdown')\">"+get_lang('Set date')+": <select id='daydropdown'></select><select id='monthdropdown'></select><select id='yeardropdown'></select></td>"+
 	 					 "</tr><tr><td colspan='3'><hr size='1' width='100%'></td></tr><tr><td colspan='3'>"+get_lang('With the following message')+".:</td>"+
 	 					 "</tr><tr><td colspan='3'><textarea id='field8' rows='3' cols='50'></textarea></td></tr></table></div>"+
@@ -473,16 +494,18 @@
 		}else{
 			mount_rule = "";
-			var fld_days   = Element("select_days");
+			if (Element("date").checked){
+				var today=new Date();
+				var entryDate = new Date(Date.UTC(Element("yeardropdown").value, Element("monthdropdown").value, parseInt(Element("daydropdown").value)+1, 0, 0, 0));
+				var fld_days = parseInt((entryDate.getTime()-today.getTime())/86400000);
+				}
+			else
+				var fld_days = parseInt(Element("select_days").value);
+			
 			var fld_emails = Element("select_1");
 			var fld_men	   = Element("field8");
 			mount_rule = "#vacation&&";
-			if(LTrim(fld_days.value) != ""){
-				if(fld_days.value > 0 && fld_days.value < 32){
-					mount_rule += fld_days.value + "&&";
-				}else{
-					alert(get_lang("Inform between 1 and 31!"));
-					return false;
-				}
-			}else{
+			if(fld_days != 0)
+					mount_rule += fld_days + "&&";
+			else{
 				alert(get_lang("Inform the days!"));
 				return false;
Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 128)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 139)
@@ -124,5 +124,5 @@
 			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">0</span>]</font>';
+			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);
@@ -253,5 +253,4 @@
 
 	var content_id_0 = document.getElementById("content_id_0");
-	//content_id_0.innerHTML = '';
 	
 	table_message_header_box = document.getElementById("table_message_header_box");
@@ -316,5 +315,5 @@
 		td_element6.align = "left";
 		td_element6.innerHTML = get_lang("Size");
-	
+
 		tr_element.appendChild(td_element1);
 		tr_element.appendChild(td_element2);
@@ -395,4 +394,16 @@
 	
 	var f_unseen = 0;
+
+		if (headers_msgs.num_msgs == 0){
+			td_info = document.createElement("H3");
+			td_info.setAttribute("height", "25%");
+			td_info.setAttribute("background", "#FFF");
+			td_info.setAttribute("id", "msg_info");
+			td_info.align = "center";
+			td_info.innerHTML = get_lang("This mail box is empty");
+			tbody_element.appendChild(td_info);
+		}
+	
+	
 	for (var i=0; i < headers_msgs.length; i++){
 			if ((headers_msgs[i].Unseen == 'U') || (headers_msgs[i].Recent == 'N'))
@@ -627,7 +638,10 @@
 	}
 	else if(sort_box_type != sort){
-		sort_box_reverse = 1;
-	}
-		
+		if ( (sort == 'SORTFROM') || (sort == 'SORTSUBJECT') )
+			sort_box_reverse = 0;
+		else
+			sort_box_reverse = 1;
+	}
+
 	// Global variable.
 	sort_box_type = sort;
Index: /trunk/expressoMail1_2/index.php
===================================================================
--- /trunk/expressoMail1_2/index.php	(revision 135)
+++ /trunk/expressoMail1_2/index.php	(revision 139)
@@ -53,6 +53,6 @@
     	$template->set_var("refresh", lang("Refresh"));
     	$template->set_var("tools", lang("Tools"));	
-	$template->set_var("lang_Open_Search_Window", lang("Open search window..."));
-	$template->set_var("lang_search_user", lang("Search user...")); 
+	$template->set_var("lang_Open_Search_Window", lang("Open search window") . '...');
+	$template->set_var("lang_search_user", lang("Search user") . '...'); 
 	$template->set_var("upload_max_filesize",ini_get('upload_max_filesize'));
 	$template->set_var("msg_folder",$_GET['msgball']['folder']);
Index: /trunk/expressoMail1_2/templates/default/index.tpl
===================================================================
--- /trunk/expressoMail1_2/templates/default/index.tpl	(revision 118)
+++ /trunk/expressoMail1_2/templates/default/index.tpl	(revision 139)
@@ -17,5 +17,5 @@
 							<table border="0" cellspacing="0" cellpadding="0" border="0"><tbody>
 								<tr><td class='content-menu-td' onclick='javascript:new_message("new","null");' onmouseover='javascript:set_menu_bg(this);' onmouseout='javascript:unset_menu_bg(this);'><div class='em_div_sidebox_menu'><img src='./templates/default/images/menu/createmail.gif'><span class="em_sidebox_menu">{new_message}</span></div></td></tr>
-								<tr><td class='content-menu-td' onclick='javascript:refresh();' onmouseover='javascript:set_menu_bg(this);' onmouseout='javascript:unset_menu_bg(this);'><div class='em_div_sidebox_menu'><img src='./templates/default/images/menu/checkmail.gif'><span class="em_sidebox_menu">{refresh}</span></div></td></tr>
+								<tr><td class='content-menu-td' id='em_refresh_button' onclick='javascript:refresh();' onmouseover='javascript:set_menu_bg(this);' onmouseout='javascript:unset_menu_bg(this);'><div class='em_div_sidebox_menu'><img src='./templates/default/images/menu/checkmail.gif'><span class="em_sidebox_menu">{refresh}</span></div></td></tr>
 								<tr><td id="link_tools" class='content-menu-td' onmouseover='javascript:set_menu_bg(Element("link_tools"));' onmouseout='javascript:unset_menu_bg(this);'><div class='em_div_sidebox_menu'><img height='16px' src='./templates/default/images/menu/tools.gif'><span class="em_sidebox_menu">{tools} ...</span></div></td></tr>								
 							</tbody></table>
