\r
     //function for normalizing paths (removes last n occurrences of the slash)\r
     var normalize = function(str){\r
-        return str.replace(/\/+$/,"");\r
+        return str.replace(/\/+#*$/,"");\r
     }\r
-    var pageOrigin = normalize(window.location.origin);\r
-    var pageHref = normalize(window.location.href);\r
+    \r
+    var host = window.location.host;\r
+    var protocol = window.location.protocol\r
+    var href = normalize(window.location.href);\r
+     \r
+    if(!(host) || !(protocol) || !(href)){\r
+        return;\r
+    }\r
+\r
+    //var pageOrigin = normalize(window.location.origin); //does not exist in FF, so:\r
+    var pageOrigin = normalize(protocol+"//"+host);\r
+    var pageHref = normalize(href);\r
+\r
     menus.each(function(){\r
         ///if we are at home, the window location href corresponds to window location origin,\r
         //so we select only links whose link points EXACTLY to the origin (home link)\r
         height:div.outerHeight(),\r
         left: (left + 5)+'px',\r
         top:(top+5)+"px"\r
-        });\r
+    });\r
     div.fadeIn('fast', function() {\r
         divShadow.insertAfter(div);\r
         divShadow.fadeTo(0,0.4);\r
         cancelB.focus();\r
     });\r
-}
\ No newline at end of file
+}\r
+popup={\r
+    id: '_popup_id__',\r
+    isFocused:false,\r
+    hide: function(){\r
+        var $J = jQuery;\r
+        $J(document).unbind('click');\r
+        $J(document).unbind('keydown');\r
+        var popupdiv = $J(this.id);\r
+        if(popupdiv){\r
+            popupdiv.remove();\r
+            this.isFocused = false;\r
+        }\r
+    },\r
+    show:function(invokerElement,divContent){\r
+        var popupId = this.id;\r
+        var createDiv = function(){\r
+            return jQuery("<div/>").append(jQuery("<div/>").css({\r
+                'backgroundColor':'#000',\r
+                position:'absolute',\r
+                bottom:0,\r
+                right:0,\r
+                top:'5px',\r
+                left:'5px'\r
+            }))\r
+            .append(\r
+                jQuery("<div/>").css({\r
+                    position: 'absolute',\r
+                    top:0,\r
+                    left:0,\r
+                    padding: '1ex',\r
+                    border: '1px solid #DDD',\r
+                    backgroundColor:'#eee'\r
+                })).attr('id',popupId).css({\r
+                display: 'none',\r
+                position: 'absolute',\r
+                zIndex:1000\r
+            });\r
+        }\r
+        var $J = jQuery;\r
+        var div = createDiv()\r
+\r
+        //adding\r
+        div.insertBefore(invokerElement);\r
+        \r
+        var mainDiv = $J(div.children()[1]).append(divContent);\r
+        var me = this;\r
+        var hide = this.hide;\r
+\r
+        var children = $J(divContent).find('*');\r
+        $(children).each(function(){\r
+            $J(this).focus(function(){\r
+                me.isFocused = true;\r
+            });\r
+            $J(this).blur(function(){\r
+                me.isFocused = false;\r
+            });\r
+        });\r
+        \r
+        //setting positions:\r
+        var pos = invokerElement.position();\r
+        var top = (invokerElement.outerHeight(true)+pos.top);\r
+        var left = pos.left;\r
+        div.css({\r
+            left: left + 'px',\r
+            top:top+"px"\r
+        });\r
+\r
+       \r
+        //showing\r
+        div.fadeIn('fast', function() {\r
+            //now that is displayed, set the parent div size (which affects the shadow, too)\r
+            var w = mainDiv.outerWidth();\r
+            var h = mainDiv.outerHeight();\r
+            div.css({\r
+                width:(w+5)+'px',\r
+                height:(h+5)+'px'\r
+            });\r
+            //show the shadow\r
+            $J(div.children()[0]).fadeTo(0,0.4);\r
+            var inputs = $J(divContent).find(':input');\r
+            me.isFocused=false;\r
+            if(inputs && inputs[0]){\r
+                inputs[0].focus();\r
+                //me.isFocused=true;\r
+            }\r
+            jQuery(document).bind('click', function(){\r
+                if(me.isFocused){\r
+                    return;\r
+                }\r
+                hide.apply(me);\r
+            });\r
+            jQuery(document).bind('keydown', function(){\r
+                if(me.isFocused){\r
+                    return;\r
+                }\r
+                hide.apply(me);\r
+            });\r
+        });\r
+    }\r
+\r
+}\r