Thanks, Thomas. I'm new to JS and I've been looking crazy for a solution to my problem. Yours helped.
I've used jquery to make a Login-box that slides down. For best user experience I desided to make the box disappear when user clicks somewhere but the box. I'm a little bit embarrassed over using about four hours fixing this. But hey, I'm new to JS.
Maybe my code can help someone out:
<body>
<button class="login">Logg inn</button>
<script type="text/javascript">
    $("button.login").click(function () {
        if ($("div#box:first").is(":hidden")) {
                $("div#box").slideDown("slow");} 
            else {
                $("div#box").slideUp("slow");
                }
    });
    </script>
<div id="box">Lots of login content</div>
<script type="text/javascript">
    var box = $('#box');
    var login = $('.login');
    login.click(function() {
        box.show(); return false;
    });
    $(document).click(function() {
        box.hide();
    });
    box.click(function(e) {
        e.stopPropagation();
    });
</script>
</body>