Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 7477)
+++ trunk/expressoMail1_2/js/main.js	(revision 7481)
@@ -454,5 +454,6 @@
 			folderName = folderName.replace(/=/gi, '');
 			delete_border(msg_num+'_r_'+folderName,'false'); //close email tab
-		}
+
+        }
 	};
 	if (confirm(get_lang("delete all attachments confirmation")))
@@ -530,4 +531,5 @@
 
 function show_msg(msg_info){
+    console.log(msg_info);
 	if(!verify_session(msg_info))
 		return;
@@ -606,6 +608,8 @@
 					 
 					if(msg_info.alarm == false){
-						if ((openTab.type[currentTab] == 2 || openTab.type[currentTab] == 3) && isPartMsg === false)
-								delete_border(currentTab,'false');
+						if ((openTab.type[currentTab] == 2 || openTab.type[currentTab] == 3) && isPartMsg === false){
+                            delete_border(currentTab,'false');
+                        }
+							
 					}
 					
@@ -985,5 +989,5 @@
 
 function delete_msgs(folder, msgs_number, border_ID, show_success_msg,archive){	
-			if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( msgs_number, folder ) ){
+            if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( msgs_number, folder ) ){
 			  alert( "Impossivel deletar mensagens que estão ainda estão sendo arquivadas." );
 			  return;
@@ -1092,9 +1096,13 @@
 					});
  				} 
-				else
-					delete_border(currentTab,'false');
-			}
-			else
-				delete_border(currentTab,'false');
+				else{
+                    delete_border(currentTab,'false');
+                }
+					
+			}
+			else{
+                delete_border(currentTab,'false');
+            }
+				
 		}
 		for (var i=0; i<data.msgs_number.length; i++){
@@ -1111,4 +1119,21 @@
 	    	if ($("#"+tabToRemove)){
 	    		delete_border(tabToRemove,'false');
+                var border_id = create_border(msg_info.subject, id_msg_read);
+            if(border_id)
+            {
+                openTab.type[border_id] = 2;
+                openTab.imapBox[border_id] = msg_info.msg_folder;
+                draw_message(msg_info,border_id);
+                var unseen_sort = document.getElementById('span_flag_UNSEEN').getAttribute('onclick');
+                unseen_sort = unseen_sort.toString();
+                if ( !(unseen_sort.indexOf("'UNSEEN' == 'UNSEEN'") < 0) )
+                {
+                    var sort_type = sort_box_type;
+                    sort_box_type = null;
+                    sort_box('UNSEEN', sort_type,false); 
+                    delete selectedPagingMsgs[msg_info.msg_number];
+                    totalFolderMsgs--;
+                }
+            }
 	    	}
 	    });
@@ -1368,6 +1393,35 @@
 					$('#msg_opt_previous_'+msg_to_delete.getAttribute('id') + '_r').trigger('click');
 				}
-				else
-					delete_border(currentTab,'false');
+				else{
+                    
+                    var border_id = $("#tbody_box").find("tr:eq(1)").attr("id");
+                    var folderName = current_folder;
+                    if(border_id){
+                        $.ajax({
+                              url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg',
+                                                  msg_number: border_id, 
+                                                  msg_folder: folderName,
+                                                  decoded: true } ),
+                              success: function( data ){
+                                  data = connector.unserialize( data );
+                                  
+                                  delete_border(currentTab,'false');
+
+                                  if( data )
+                                  show_msg( data );
+                              },
+                              beforeSend: function( jqXHR, settings ){
+                                connector.showProgressBar();
+                              },
+                              complete: function( jqXHR, settings ){
+                                connector.hideProgressBar();
+                              }
+                        });
+                    } else {
+                        delete_border(currentTab,'false');
+                    }
+                    
+                }
+					
 			}
 			else{
@@ -1438,6 +1492,8 @@
 				show_msg(data.previous_msg);
 				}
-			else
-				delete_border(data.border_ID,'false');
+			else{
+                delete_border(data.border_ID,'false');
+            }
+				
 		}
 		if(folder == get_current_folder()){
@@ -1558,5 +1614,5 @@
 						    	tabToRemove = value + "_r_" + msgFolder.replace(/=/g,"");
 						    	if ($("#"+tabToRemove)){
-						    		delete_border(tabToRemove,'false');
+						    		//delete_border(tabToRemove,'false');
 						    	}
 						    });
