diff --git a/js/media.browser.js b/js/media.browser.js
index c81e733..53fe721 100644
--- a/js/media.browser.js
+++ b/js/media.browser.js
@@ -7,7 +7,6 @@
 namespace('Drupal.media.browser');
 
 Drupal.media.browser.selectedMedia = [];
-Drupal.media.browser.activeTab = 0;
 Drupal.media.browser.mediaAdded = function () {};
 Drupal.media.browser.selectionFinalized = function (selectedMedia) {
   // This is intended to be overridden if a callee wants to be triggered
@@ -15,6 +14,7 @@ Drupal.media.browser.selectionFinalized = function (selectedMedia) {
   // This is used for the file upload form for instance.
 };
 
+
 Drupal.behaviors.MediaBrowser = {
   attach: function (context) {
     if (Drupal.settings.media && Drupal.settings.media.selectedMedia) {
@@ -23,24 +23,45 @@ Drupal.behaviors.MediaBrowser = {
       Drupal.media.browser.finalizeSelection();
     }
 
+    var showFunc = function(event, ui) {
+      // store index of the tab being activated.
+      if (parent_iframe = Drupal.media.browser.getParentIframe(window)) {
+        $(parent_iframe).attr('current_tab', $('#media-tabs-wrapper > ul > li.ui-state-active').index());
+      }
+      // Ensure that the modal resizes to the content on each tab switch.
+      Drupal.media.browser.resizeIframe(event);
+    };
+    var activeTab = Drupal.media.browser.tabFromHash();
     // Instantiate the tabs.
     $('#media-browser-tabset').tabs({
-      // Ensure that the modal resizes to the content on each tab switch.
-      show: Drupal.media.browser.resizeIframe, // jquery ui < 1.8
-      activate: Drupal.media.browser.resizeIframe // jquery ui >= 1.8
-    });
-
-    $('.ui-tabs-nav li').mouseup(function() {
-      Drupal.media.browser.activeTab = $(this).index();
+      selected: activeTab, // jquery < 1.9
+      active: activeTab, // jquery >= 1.9
+      show: showFunc, // jquery ui < 1.8
+      activate: showFunc // jquery ui >= 1.8
     });
 
     $('.media-browser-tab').each( Drupal.media.browser.validateButtons );
+  }
+  // Wait for additional params to be passed in.
+};
 
-    Drupal.media.browser.selectActiveTab();
-    Drupal.media.browser.selectErrorTab();
+Drupal.media.browser.getParentIframe = function (window) {
+  var arrFrames = parent.document.getElementsByTagName("IFRAME");
+  for (var i = 0; i < arrFrames.length; i++) {
+    if (arrFrames[i].contentWindow === window) {
+      return arrFrames[i];
+    }
+  }
+}
 
+/**
+ * Get index of the active tab from window.location.hash
+ */
+Drupal.media.browser.tabFromHash = function () {  
+  if (parent_iframe = Drupal.media.browser.getParentIframe(window)) {
+    return $(parent_iframe).attr('current_tab');
   }
-  // Wait for additional params to be passed in.
+  return 0;
 };
 
 Drupal.media.browser.launch = function () {
@@ -113,31 +134,6 @@ Drupal.media.browser.resizeIframe = function (event) {
   $(parent.window.document).find('#mediaBrowser').height(h);
 };
 
-Drupal.media.browser.selectErrorTab = function() {
-  // Find the ID of a tab with an error in it
-  var errorTabID = $('#media-browser-tabset')
-    .find('.error')
-    .parents('.media-browser-tab')
-    .attr('id');
-
-  if (errorTabID !== undefined) {
-    // Find the Tab Link with errorTabID
-    var tab = $('a[href="#' + errorTabID + '"]');
-    // Find the index of the tab
-    var index = $('#media-browser-tabset a').index(tab);
-    // Select the tab
-    Drupal.media.browser.selectTab(index);
-  }
-}
-
-Drupal.media.browser.selectActiveTab = function() {
-  // Find the index of the last active tab.
-  setTimeout(function() {
-    Drupal.media.browser.selectTab(Drupal.media.browser.activeTab);
-    Drupal.media.browser.resizeIframe();
-  }, 10);
-};
-
 /**
  * Helper function to change the media browser jQuery UI tabs
  * since it requires two different methods dependingon the version.
