Index: trunk/expressoMail1_2/js/shortcut.js
===================================================================
--- trunk/expressoMail1_2/js/shortcut.js	(revision 790)
+++ trunk/expressoMail1_2/js/shortcut.js	(revision 1390)
@@ -22,5 +22,5 @@
 			}
 		}
-
+		
 		var ele = opt.target
 		if(typeof opt.target == 'string') ele = document.getElementById(opt.target);
@@ -226,4 +226,6 @@
 var shift_up_count = 0;
 var shift_down_count = 0;
+var selMessageShortcut = "";
+
 shortcut.add("N",function(){ new_message("new","null"); },{'disable_in_input':true});
 
@@ -245,24 +247,35 @@
 shortcut.add("E",function(){ exec_msg_action('forward'); },{'disable_in_input':true});
 shortcut.add("R",function(){ exec_msg_action('reply'); },{'disable_in_input':true});
+
 shortcut.add("Delete",function(){
+	
+	var selected_shortcut_msgs = '';
+	var tbody_box = Element('tbody_box');
+	all_messages = Element('tbody_box').childNodes;
+	
+	for ( var i=0; i < all_messages.length; i++ )
+	{
+		if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
+		{
+			selected_shortcut_msgs += all_messages[i].id + ',';
+			
+			if( all_messages[i].nextSibling )
+				selMessageShortcut = all_messages[i].nextSibling.id + "-" + "down";
+			else if(all_messages[i].previousSibling)
+				selMessageShortcut = all_messages[i].previousSibling.id + "-" + "up";
+		}
+	}
+	selected_shortcut_msgs = selected_shortcut_msgs.substring(0,(selected_shortcut_msgs.length-1));
+	
 	if ( Element('border_id_0').className==='menu-sel' )
 	{
-		var selected_shortcut_msgs = '';
-		var tbody_box = Element('tbody_box');
-		all_messages = Element('tbody_box').childNodes;
-		
-		for (var i=0; i < all_messages.length; i++)
-		{
-			if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
-			{
-				selected_shortcut_msgs += all_messages[i].id + ',';
-			}
-		}
-		
-		selected_shortcut_msgs = selected_shortcut_msgs.substring(0,(selected_shortcut_msgs.length-1));
 		proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null');
 	}
 	else
+	{
 		exec_msg_action('delete');
+		select_msg(selMessageShortcut.substring(0, selMessageShortcut.indexOf("-")),
+				   selMessageShortcut.substring(selMessageShortcut.indexOf("-")), true );
+	}
 }
 ,{'disable_in_input':true});
@@ -299,5 +312,5 @@
 {
 	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("up",function(){ select_msg('null', 'up');},{'type':'keypress', 'disable_in_input':false});
 	
 	shortcut.add("Shift+down",function(){
@@ -387,15 +400,6 @@
 	else
 	{
-		all_messages = Element('tbody_box').childNodes;
-		if (keyboard_action == 'down')
-		{
-			// Ultimo elemento ja esta selecionado
-			if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') )
-			{
-				unselect_all_msgs();
-				add_className(all_messages[all_messages.length-1], 'selected_shortcut_msg')
-				return false;
-			}
-			
+		if( keyboard_action == 'down')
+		{
 			for (var i=all_messages.length-1; i >=0; i--)
 			{
@@ -407,45 +411,35 @@
 				}
 			}
+			
 			for (; i>=0; i--)
 			{
-				remove_className(all_messages[i], 'selected_shortcut_msg');
-			}
-		var scrollMain = Element('divScrollMain_0');
-//		var selection_size = all_messages[1].offsetTop; 
-		var selection_size = parseInt(preferences.line_height) + 10;
-		
-		if ((mailPos) && (parseInt(scrollMain.style.height.substr(0,scrollMain.style.height.length-2)) + scrollMain.scrollTop < all_messages[mailPos].offsetTop + selection_size))
-			scrollMain.scrollTop += selection_size;
-		}
-		else
-		{
-			if ( exist_className(all_messages[0], 'selected_shortcut_msg') )
-			{
-				unselect_all_msgs();
-				add_className(all_messages[0], 'selected_shortcut_msg')
-				return false;
-			}
-			
+				if( all_messages[i].nextSibling )
+					remove_className(all_messages[i], 'selected_shortcut_msg');
+			}
+		}
+		else if( keyboard_action == 'up')
+		{
 			for (var i=0; i < all_messages.length; i++)
 			{
 				if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
 				{
-					add_className(all_messages[i-1], 'selected_shortcut_msg')
-					var mailPos = i;
-					break;
+					if( all_messages[i].previousSibling )
+					{
+						add_className(all_messages[i-1], 'selected_shortcut_msg')
+						var mailPos = i;
+						break;
+					}
 				}
 			}
+			
 			for (; i< all_messages.length; i++)
 			{
 				remove_className(all_messages[i], 'selected_shortcut_msg')
 			}
-		var scrollMain = Element('divScrollMain_0');
-		var selection_size = parseInt(preferences.line_height) + 10;
-		if (all_messages[mailPos].offsetTop <= scrollMain.scrollTop)
-			scrollMain.scrollTop -= selection_size+10;
-		}
-			return true;
-		}
-	}
+		}
+
+		return true;
+	}
+}
 
 function select_bottom_msg()
