Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 12124)
+++ wp-includes/post.php	(working copy)
@@ -1250,6 +1250,8 @@
 
 	if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
 		return $post;
+	elseif ($post['post_status'] == 'trash')
+		return false;
 
 	do_action('trash_post', $post_id);
 
@@ -1277,6 +1279,8 @@
 function wp_untrash_post($post_id = 0) {
 	if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
 		return $post;
+	elseif ($post['post_status'] != 'trash')
+		return false;
 
 	do_action('untrash_post', $post_id);
 
Index: wp-includes/js/swfupload/handlers.dev.js
===================================================================
--- wp-includes/js/swfupload/handlers.dev.js	(revision 12124)
+++ wp-includes/js/swfupload/handlers.dev.js	(working copy)
@@ -83,6 +83,28 @@
 			});
 		return false;
 	});
+	// Bind AJAX to the new Undo button
+	jQuery('#media-item-' + fileObj.id + ' a.undo').click(function(){
+		// Tell the server to untrash it. TODO: handle exceptions
+		jQuery.ajax({url:'admin-ajax.php',type:'post',id:fileObj.id,data:{
+			id : this.id.replace(/[^0-9]/g,''),
+			action : 'untrash-post',
+			_ajax_nonce : this.href.replace(/^.*wpnonce=/,'')},
+			success:function(data, textStatus){
+				if ( type = jQuery('#type-of-' + fileObj.id).val() )
+					jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-0+1);
+				if ( jQuery('#media-item-' + fileObj.id).hasClass('child-of-'+post_id) )
+					jQuery('#attachments-count').text(jQuery('#attachments-count').text()-0+1);
+				
+				jQuery('#media-item-' + fileObj.id + ' .filename .trashnotice').remove();
+				jQuery('#media-item-' + fileObj.id + ' a.undo').addClass('hidden');
+				jQuery('#media-item-' + fileObj.id + ' .filename').siblings('a.toggle.describe-toggle-on').show();
+				jQuery('#media-item-' + fileObj.id).animate({backgroundColor:'#fff'}, {queue:false,duration:200,complete:function(){jQuery(this).css({backgroundColor:''})}});
+				jQuery('#media-item-' + this.id + ' .menu_order_input').show();
+			}
+			});
+		return false;
+	});
 
 	// Open this item if it says to start open (e.g. to display an error)
 	jQuery('#media-item-' + fileObj.id + '.startopen').removeClass('startopen').slideToggle(500).parent().children('.toggle').toggle();
@@ -101,6 +123,7 @@
 	if ( data == '0' )
 		return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?');
 
+	var id = this.id;
 	var item = jQuery('#media-item-' + this.id);
 
 	// Decrement the counters.
@@ -109,19 +132,13 @@
 	if ( item.hasClass('child-of-'+post_id) )
 		jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1);
 
-	if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) {
-		jQuery('.toggle').toggle();
-		jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
-	}
-
-	// Vanish it.
+	jQuery('#media-item-' + this.id + ' .toggle').toggle();
+	jQuery('#media-item-' + this.id + ' .slidetoggle').slideUp(200).siblings().removeClass('hidden');
+	jQuery('#media-item-' + this.id).css({backgroundColor:'#fff'}).animate({backgroundColor:'#ffc0c0'}, {queue:false,duration:500});
 	jQuery('#media-item-' + this.id + ' .filename:empty').remove();
-	jQuery('#media-item-' + this.id + ' .filename').append(' <span class="file-error">'+swfuploadL10n.deleted+'</span>').siblings('a.toggle').remove();
-	jQuery('#media-item-' + this.id).children('.describe').css({backgroundColor:'#fff'}).end()
-			.animate({backgroundColor:'#ffc0c0'}, {queue:false,duration:50})
-			.animate({minHeight:0,height:36}, 400, null, function(){jQuery(this).children('.describe').remove()})
-			.animate({backgroundColor:'#fff'}, 400)
-			.animate({height:0}, 800, null, function(){jQuery(this).remove();updateMediaForm();});
+	jQuery('#media-item-' + this.id + ' .filename').append('<span class="trashnotice"> '+swfuploadL10n.deleted+' </span>').siblings('a.toggle').hide();
+	jQuery('#media-item-' + this.id + ' .filename').append(jQuery('#media-item-' + this.id + ' a.undo').removeClass('hidden'));
+	jQuery('#media-item-' + this.id + ' .menu_order_input').hide();
 
 	return;
 }
Index: wp-includes/script-loader.php
===================================================================
--- wp-includes/script-loader.php	(revision 12124)
+++ wp-includes/script-loader.php	(working copy)
@@ -204,7 +204,7 @@
 			'upload_stopped' => __('Upload stopped.'),
 			'dismiss' => __('Dismiss'),
 			'crunching' => __('Crunching&hellip;'),
-			'deleted' => __('Moved to Trash'),
+			'deleted' => __('moved to the trash.'),
 			'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};'
 	) );
 
Index: wp-admin/admin-ajax.php
===================================================================
--- wp-admin/admin-ajax.php	(revision 12124)
+++ wp-admin/admin-ajax.php	(working copy)
@@ -346,6 +346,19 @@
 	else
 		die('0');
 	break;
+case 'untrash-post' :
+	check_ajax_referer( "{$action}_$id" );
+	if ( !current_user_can( 'delete_post', $id ) )
+		die('-1');
+
+	if ( !get_post( $id ) )
+		die('1');
+
+	if ( wp_untrash_post( $id ) )
+		die('1');
+	else
+		die('0');
+	break;
 case 'delete-page' :
 	check_ajax_referer( "{$action}_$id" );
 	if ( !current_user_can( 'delete_page', $id ) )
Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php	(revision 12124)
+++ wp-admin/includes/media.php	(working copy)
@@ -1203,11 +1203,12 @@
 		'extra_rows' => array(),
 	);
 
-	$delete_href = wp_nonce_url("post.php?action=trash&amp;post=$attachment_id", 'trash-post_' . $attachment_id);
+	$trash_href = wp_nonce_url("post.php?action=trash&amp;post=$attachment_id", 'trash-post_' . $attachment_id);
+	$untrash_href = wp_nonce_url("post.php?action=untrash&amp;post=$attachment_id", 'untrash-post_' . $attachment_id);
 	if ( $send )
 		$send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />";
 	if ( $delete )
-		$delete = current_user_can('delete_post', $attachment_id) ? "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>" : "";
+		$delete = current_user_can('delete_post', $attachment_id) ? "<a href=\"$trash_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a> <a href=\"$untrash_href\" id=\"undo[$attachment_id]\" class=\"undo hidden\">" . __('Undo?') . "</a>" : "";
 	if ( 'image' == $type && get_post_image_id($_GET['post_id']) != $attachment_id )
 		$thumbnail = "<a class='wp-post-thumbnail' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as thumbnail" ) . "</a>";
 

