--- ./nuxeo-dragdrop/nuxeo-dragdrop-ff-extension/chrome/chromeFiles/content/customdragdrop.js	2010-03-29 16:51:16.000000000 +0200
+++ /Users/fguillaume/Downloads/customdragdrop.js	2010-12-10 11:16:17.000000000 +0100
@@ -86,7 +86,19 @@
   }
   initPrefDone=true;
 }
+function getDocument(){
 
+	var fs = getBrowser().contentDocument.getElementsByTagName("iframe");
+	for (var i = 0; i < fs.length; i++){
+		pluginEnabled = fs[i].contentWindow.document.getElementById("Nx5PluginEnabled");
+		if (pluginEnabled)
+			return fs[i].contentWindow.document;
+	} 
+ 	var w = getTopWin(); // get current active FF window
+ 	var browser = w.document.getElementById("content"); // get content
+	var activeBrower = browser.browsers[browser.mTabBox.selectedIndex]; // get active tab
+ 	return activeBrower.contentDocument;
+}
 function getJSBrowserWindow() {
 
     var JSBrowserWindow;
@@ -95,16 +107,17 @@
     jslibPrint("appInfo.version=" + appInfo.version);
     if(versionChecker.compare(appInfo.version, "3") < 1) {
         jslibPrint("firefox < 3");
-        JSBrowserWindow=document.getElementById("content").contentDocument.defaultView;
+        JSBrowserWindow=getWindow().document.getElementById("content").contentDocument.defaultView;
     }
     else {
       jslibPrint("firefox 3+");
-      var w = getTopWin(); // get current active FF window
-      var browser = w.document.getElementById("content"); // get content
-      var activeBrower = browser.browsers[browser.mTabBox.selectedIndex]; // get active tab
-      JSBrowserWindow = activeBrower.contentDocument.defaultView.wrappedJSObject;
+      // var w = getTopWin(); // get current active FF window
+      // var browser = w.document.getElementById("content"); // get content
+      // var activeBrower = browser.browsers[browser.mTabBox.selectedIndex]; // get active tab
+      // JSBrowserWindow = activeBrower.contentDocument.defaultView.wrappedJSObject;
+		JSBrowserWindow = getDocument().defaultView.wrappedJSObject;
     }
-
+	//alert('JSBrowserWindow'+JSBrowserWindow);
   jslibPrint("exit getJSBrowser");
   return JSBrowserWindow;
 }
@@ -162,7 +175,7 @@
     return true;
   var locale = getUserLocale();
   jslibPrint(" displaying confirm dialog for language " + locale);
-  var message = "Are you sure you want to upload ?";
+  var message = "Are you sure you1 want to upload ?";
   var title = "Confirm upload?";
   var skipMessage = "Don't ask me again";
 
@@ -599,7 +612,7 @@
 
         jslibPrint("file stack ready : " + allfiles.length
             + " files to upload");
-
+			
         var w = 300;
         var h = 20;
         var x = (window.screen.width - w) / 2;
@@ -608,7 +621,7 @@
             + ",alwaysRaised,centerscreen,close=no";
         try {
           nx5firefoxhelperObserver.allfiles = allfiles;
-
+	
           for (var i = 0; i < nx5firefoxhelperObserver.allfiles.length; i++) {
             var nextfile = nx5firefoxhelperObserver.allfiles[i];
             if (nextfile.type == 0)
@@ -617,6 +630,8 @@
             else
               jslibPrint("ReadyToUpload File : "
                   + nextfile.file.leaf + "--" + nextfile.url);
+	//alert("ReadyToUpload  : "
+      //            + nextfile.file.leaf + "--" + nextfile.url);
           }
 
           // init transfert and display the wait screen
@@ -642,6 +657,7 @@
   },
 
   onDrop : function(evt, transferData, session) {
+
     if (typeof(transferData) == 'undefined' || transferData == null) {
       return;
     }
@@ -654,11 +670,21 @@
     // check that plugin is enabled
     var pluginEnabled = getBrowser().contentDocument
         .getElementById("Nx5PluginEnabled");
+
     if (pluginEnabled && pluginEnabled.value == "true") {
       pluginEnabled = true;
     } else {
-      pluginEnabled = false;
-      updateStatus("Plugin Disabled");
+	  if (pluginEnabled == null){
+			 var fs = getBrowser().contentDocument.getElementsByTagName("iframe");
+			  for (var i = 0; i < fs.length; i++){
+				pluginEnabled = fs[i].contentWindow.document.getElementById("Nx5PluginEnabled");
+				if (pluginEnabled)
+					break;
+			} 
+		}else{
+      		pluginEnabled = false;
+      		updateStatus("Plugin Disabled");
+		}
     }
 
     if (ForcePluginLoading) {
@@ -686,18 +712,20 @@
     if (dataobj.flavour.contentType == "application/x-moz-file") {
       correctFile = true;
     }
-
     // NXP-1057 : don't try to upload drag & dropped icons
     // if ((dataobj.data.indexOf) && (dataobj.data.indexOf("file://")!=0))
     // correctFile=false;
 
     if (pluginEnabled && correctFile) {
+
       jslibPrint("calling browser JS for transfer rights");
       ECMTransferData = transferData;
       var w = getTopWin(); // the active Firefox window
+
       var browser = w.document.getElementById("content");
       var activeBrower = browser.browsers[browser.mTabBox.selectedIndex];
       JSBrowserWindow = getJSBrowserWindow();
+
       // Call the JS on the browser to check the rights
       // the callback will trigger the real upload
       // not needed on recent Nuxeo versions since
@@ -718,12 +746,14 @@
       }
     }
 
+
     // Calling standard onDrop function since there is no upload to be done
     if (evt.target.getAttribute("id") != "nx5firefoxhelperStatus"
         && !pluginEnabled) {
       contentAreaDNDObserver.nx5firefoxhelperOldDrop(evt, transferData,
           session);
     }
+
   },
 
   updatePaths : function(old, newid) {
