How to get this jQuary script working?

Oh okay.. I think I solved it.

I put the script in the header.php (I think “into the loop” as they say?) just behind the opening <header>-tag:

<body>
<header>
<script type="text/javascript">
(function($) {          
    $(document).ready(function(){                    
        $(window).scroll(function(){                          
            if ($(this).scrollTop() > 200) {
                $('#menu').fadeIn(500);
            } else {
                $('#menu').fadeOut(500);
            }
        });
    });
})(jQuery);
</script>