Index: popups.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/popups/popups.js,v
retrieving revision 1.9.8.15
diff -u -p -r1.9.8.15 popups.js
--- popups.js	26 Mar 2009 17:30:54 -0000	1.9.8.15
+++ popups.js	24 Jun 2009 14:29:01 -0000
@@ -13,6 +13,25 @@
  * * Return key in add node form not working.
  * * Tabledrag breaking after ahah reload.
  */
+ 
+ /**
+  * Searches this_array for obj.
+  *
+  * @param this_array
+  *   The array to search for a value
+  * @param obj
+  *   The object/value to search for
+  * @return
+  *   The position of obj in this_array, or -1 if not found.
+  */
+ function arrayIndexOf (this_array, obj) {
+  for (var i=0; i<this_array.length; i++) {
+    if (this_array[i] == obj) {
+      return i;
+    }
+  }
+  return -1;
+}
 
 // ***************************************************************************
 // DRUPAL Namespace
@@ -598,7 +617,7 @@ Popups.removePopup = function(popup) {  
   }
   if (popup) {
     popup.$popup().remove();
-    Popups.popupStack.splice(Popups.popupStack.indexOf(popup), 1); // Remove popup from stack.  Probably should rework into .pop()
+    Popups.popupStack.splice(arrayIndexOf(Popups.popupStack, popup), 1); // Remove popup from stack.  Probably should rework into .pop()
   }  
 }; 
 
