Index: wp-includes/js/swfupload/swfupload.js
===================================================================
--- wp-includes/js/swfupload/swfupload.js	(revision 17488)
+++ wp-includes/js/swfupload/swfupload.js	(working copy)
@@ -23,10 +23,10 @@
 	};
 }
 
-SWFUpload.prototype.initSWFUpload = function (settings) {
+SWFUpload.prototype.initSWFUpload = function (userSettings) {
 	try {
 		this.customSettings = {};	// A container where developers can place their own settings associated with this instance.
-		this.settings = settings;
+		this.settings = {};
 		this.eventQueue = [];
 		this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
 		this.movieElement = null;
@@ -36,7 +36,7 @@
 		SWFUpload.instances[this.movieName] = this;
 
 		// Load the settings.  Load the Flash movie.
-		this.initSettings();
+		this.initSettings(userSettings);
 		this.loadFlash();
 		this.displayDebugInfo();
 	} catch (ex) {
@@ -50,7 +50,7 @@
 /* *************** */
 SWFUpload.instances = {};
 SWFUpload.movieCount = 0;
-SWFUpload.version = "2.2.0 2009-03-25";
+SWFUpload.version = "2.2.1 2009-03-30";
 SWFUpload.QUEUE_ERROR = {
 	QUEUE_LIMIT_EXCEEDED	  		: -100,
 	FILE_EXCEEDS_SIZE_LIMIT  		: -110,
@@ -79,7 +79,8 @@
 SWFUpload.BUTTON_ACTION = {
 	SELECT_FILE  : -100,
 	SELECT_FILES : -110,
-	START_UPLOAD : -120
+	START_UPLOAD : -120,
+	JAVASCRIPT   : -130
 };
 SWFUpload.CURSOR = {
 	ARROW : -1,
@@ -93,22 +94,24 @@
 
 // Private: takes a URL, determines if it is relative and converts to an absolute URL
 // using the current site. Only processes the URL if it can, otherwise returns the URL untouched
-SWFUpload.completeURL = function(url) {
-	if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
+SWFUpload.completeURL = function (url) {
+	try {
+		var path = "";
+		if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//) || url === "") {
+			return url;
+		}
+		
+		var indexSlash = window.location.pathname.lastIndexOf("/");
+		if (indexSlash <= 0) {
+			path = "/";
+		} else {
+			path = window.location.pathname.substr(0, indexSlash) + "/";
+		}
+		
+		return path + url;
+	} catch (ex) {
 		return url;
 	}
-	
-	var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
-	
-	var indexSlash = window.location.pathname.lastIndexOf("/");
-	if (indexSlash <= 0) {
-		path = "/";
-	} else {
-		path = window.location.pathname.substr(0, indexSlash) + "/";
-	}
-	
-	return /*currentURL +*/ path + url;
-	
 };
 
 
@@ -118,9 +121,24 @@
 
 // Private: initSettings ensures that all the
 // settings are set, getting a default value if one was not assigned.
-SWFUpload.prototype.initSettings = function () {
+SWFUpload.prototype.initSettings = function (userSettings) {
 	this.ensureDefault = function (settingName, defaultValue) {
-		this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+		var setting = userSettings[settingName];
+		if (setting != undefined) {
+			if (typeof(setting) === "object" && !(setting instanceof Array)) {
+				var clone = {};
+				for (var key in setting) {
+					if (setting.hasOwnProperty(key)) {
+						clone[key] = setting[key];
+					}
+				}
+				this.settings[settingName] = clone;
+			} else {
+				this.settings[settingName] = setting;
+			}
+		} else {
+			this.settings[settingName] = defaultValue;
+		}
 	};
 	
 	// Upload backend settings
@@ -177,6 +195,8 @@
 	this.ensureDefault("upload_success_handler", null);
 	this.ensureDefault("upload_complete_handler", null);
 	
+	this.ensureDefault("button_action_handler", null);
+	
 	this.ensureDefault("debug_handler", this.debugMessage);
 
 	this.ensureDefault("custom_settings", {});
@@ -190,7 +210,6 @@
 	}
 	
 	if (!this.settings.preserve_relative_urls) {
-		//this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url);	// Don't need to do this one since flash doesn't look at it
 		this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
 		this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
 	}
@@ -214,8 +233,10 @@
 		throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
 	}
 
+	var wrapperType = (targetElement.currentStyle && targetElement.currentStyle["display"] || window.getComputedStyle && document.defaultView.getComputedStyle(targetElement, null).getPropertyValue("display")) !== "block" ? "span" : "div";
+	
 	// Append the container and load the flash
-	tempParent = document.createElement("div");
+	tempParent = document.createElement(wrapperType);
 	tempParent.innerHTML = this.getFlashHTML();	// Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
 	targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
 
@@ -314,27 +335,19 @@
 		// Make sure Flash is done before we try to remove it
 		this.cancelUpload(null, false);
 		
+		// Stop the external interface check from running
+		this.callFlash("StopExternalInterfaceCheck");
+		
+		var movieElement = this.cleanUp();
 
 		// Remove the SWFUpload DOM nodes
-		var movieElement = null;
-		movieElement = this.getMovieElement();
-		
-		if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
-			// Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
-			for (var i in movieElement) {
-				try {
-					if (typeof(movieElement[i]) === "function") {
-						movieElement[i] = null;
-					}
-				} catch (ex1) {}
-			}
-
+		if (movieElement) {
 			// Remove the Movie Element from the page
 			try {
 				movieElement.parentNode.removeChild(movieElement);
 			} catch (ex) {}
 		}
-		
+
 		// Remove IE form fix reference
 		window[this.movieName] = null;
 
@@ -506,6 +519,15 @@
 	this.callFlash("StopUpload");
 };
 
+
+// Public: requeueUpload requeues any file. If the file is requeued or already queued true is returned.
+// If the file is not found or is currently uploading false is returned.  Requeuing a file bypasses the
+// file size, queue size, upload limit and other queue checks.  Certain files can't be requeued (e.g, invalid or zero bytes files).
+SWFUpload.prototype.requeueUpload = function (indexOrFileID) {
+	return this.callFlash("RequeueUpload", [indexOrFileID]);
+};
+
+
 /* ************************
  * Settings methods
  *   These methods change the SWFUpload settings.
@@ -792,17 +814,19 @@
 		return;
 	}
 
-	this.cleanUp(movieElement);
+	this.cleanUp();
 	
 	this.queueEvent("swfupload_loaded_handler");
 };
 
 // Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
 // This function is called by Flash each time the ExternalInterface functions are created.
-SWFUpload.prototype.cleanUp = function (movieElement) {
+SWFUpload.prototype.cleanUp = function () {
+	var movieElement = this.getMovieElement();
+	
 	// Pro-actively unhook all the Flash functions
 	try {
-		if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
+		if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
 			this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
 			for (var key in movieElement) {
 				try {
@@ -817,7 +841,7 @@
 	
 	}
 
-	// Fix Flashes own cleanup code so if the SWFMovie was removed from the page
+	// Fix Flashes own cleanup code so if the SWF Movie was removed from the page
 	// it doesn't display errors.
 	window["__flash__removeCallback"] = function (instance, name) {
 		try {
@@ -828,10 +852,15 @@
 		
 		}
 	};
+	
+	return movieElement;
+};
 
+/* When the button_action is set to JavaScript this event gets fired and executes the button_action_handler */
+SWFUpload.prototype.buttonAction = function () {
+	this.queueEvent("button_action_handler");
 };
 
-
 /* This is a chance to do something before the browse window opens */
 SWFUpload.prototype.fileDialogStart = function () {
 	this.queueEvent("file_dialog_start_handler");
Index: wp-includes/js/swfupload/plugins/swfupload.queue.js
===================================================================
--- wp-includes/js/swfupload/plugins/swfupload.queue.js	(revision 17488)
+++ wp-includes/js/swfupload/plugins/swfupload.queue.js	(working copy)
@@ -16,9 +16,9 @@
 	SWFUpload.queue = {};
 	
 	SWFUpload.prototype.initSettings = (function (oldInitSettings) {
-		return function () {
+		return function (userSettings) {
 			if (typeof(oldInitSettings) === "function") {
-				oldInitSettings.call(this);
+				oldInitSettings.call(this, userSettings);
 			}
 			
 			this.queueSettings = {};
@@ -31,7 +31,7 @@
 			this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
 			this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
 			
-			this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
+			this.settings.queue_complete_handler = userSettings.queue_complete_handler || null;
 		};
 	})(SWFUpload.prototype.initSettings);
 
Index: wp-includes/js/swfupload/plugins/swfupload.swfobject.js
===================================================================
--- wp-includes/js/swfupload/plugins/swfupload.swfobject.js	(revision 17488)
+++ wp-includes/js/swfupload/plugins/swfupload.swfobject.js	(working copy)
@@ -51,13 +51,13 @@
 	});
 	
 	SWFUpload.prototype.initSettings = (function (oldInitSettings) {
-		return function () {
+		return function (userSettings) {
 			if (typeof(oldInitSettings) === "function") {
-				oldInitSettings.call(this);
+				oldInitSettings.call(this, userSettings);
 			}
 
 			this.ensureDefault = function (settingName, defaultValue) {
-				this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+				this.settings[settingName] = (userSettings[settingName] == undefined) ? defaultValue : userSettings[settingName];
 			};
 
 			this.ensureDefault("minimum_flash_version", "9.0.28");
Index: wp-includes/js/swfupload/plugins/swfupload.cookies.js
===================================================================
--- wp-includes/js/swfupload/plugins/swfupload.cookies.js	(revision 17488)
+++ wp-includes/js/swfupload/plugins/swfupload.cookies.js	(working copy)
@@ -9,9 +9,9 @@
 var SWFUpload;
 if (typeof(SWFUpload) === "function") {
 	SWFUpload.prototype.initSettings = function (oldInitSettings) {
-		return function () {
+		return function (userSettings) {
 			if (typeof(oldInitSettings) === "function") {
-				oldInitSettings.call(this);
+				oldInitSettings.call(this, userSettings);
 			}
 			
 			this.refreshCookies(false);	// The false parameter must be sent since SWFUpload has not initialzed at this point
Index: wp-includes/js/swfupload/plugins/swfupload.speed.js
===================================================================
--- wp-includes/js/swfupload/plugins/swfupload.speed.js	(revision 17488)
+++ wp-includes/js/swfupload/plugins/swfupload.speed.js	(working copy)
@@ -3,9 +3,9 @@
 	
 	Features:
 		*Adds several properties to the 'file' object indicated upload speed, time left, upload time, etc.
-			- currentSpeed -- String indicating the upload speed, bytes per second
-			- averageSpeed -- Overall average upload speed, bytes per second
-			- movingAverageSpeed -- Speed over averaged over the last several measurements, bytes per second
+			- currentSpeed -- String indicating the upload speed, bits per second
+			- averageSpeed -- Overall average upload speed, bits per second
+			- movingAverageSpeed -- Speed over averaged over the last several measurements, bits per second
 			- timeRemaining -- Estimated remaining upload time in seconds
 			- timeElapsed -- Number of seconds passed for this upload
 			- percentUploaded -- Percentage of the file uploaded (0 to 100)
@@ -29,13 +29,13 @@
 	SWFUpload.speed = {};
 	
 	SWFUpload.prototype.initSettings = (function (oldInitSettings) {
-		return function () {
+		return function (userSettings) {
 			if (typeof(oldInitSettings) === "function") {
-				oldInitSettings.call(this);
+				oldInitSettings.call(this, userSettings);
 			}
 			
 			this.ensureDefault = function (settingName, defaultValue) {
-				this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+				this.settings[settingName] = (userSettings[settingName] == undefined) ? defaultValue : userSettings[settingName];
 			};
 
 			// List used to keep the speed stats for the files we are tracking
@@ -339,4 +339,4 @@
 		return mSum / mCount;
 	};
 	
-}
\ No newline at end of file
+}
Index: wp-includes/js/swfupload/swfupload.swf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = (application/octet-stream, application/x-shockwave-flash)

Property changes on: wp-includes/js/swfupload/swfupload.swf
___________________________________________________________________
Modified: svn:mime-type
   - application/octet-stream
   + application/x-shockwave-flash

