diff --git a/lib/OpenLayers/Control/Panel.js b/lib/OpenLayers/Control/Panel.js
index <HASH>..<HASH> 100644
--- a/lib/OpenLayers/Control/Panel.js
+++ b/lib/OpenLayers/Control/Panel.js
@@ -169,11 +169,11 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
      */    
     draw: function() {
         OpenLayers.Control.prototype.draw.apply(this, arguments);
-        if (this.div.parentNode === this.map.viewPortDiv) {
-            this.map.events.register("buttonclick", this, this.onButtonClick);
-        } else {
+        if (this.outsideViewport) {
             this.events.element = this.div;
             this.events.register("buttonclick", this, this.onButtonClick);
+        } else {
+            this.map.events.register("buttonclick", this, this.onButtonClick);
         }
         this.addControlsToMap(this.controls);
         return this.div;
Check for outsideViewport - we may not have a parentNode yet.