$().ready(function() {
	// make the menu scroll up & down with the page
	// from: http://webdev-il.blogspot.com/2009/12/make-content-stay-on-screen-while-page.html
    var $shadow = $("#menu");
    $(window).scroll(function(){
    	//prevent the menu from scrolling over the copyright and out of the frame
 		if($shadow.height() + $(window).scrollTop() + $shadow.position().top > $('#copyright').position().top)
 			newVal = $('#copyright').position().top - $shadow.height() - $shadow.position().top;
		  else
			newVal = $(window).scrollTop();
        $shadow.stop().animate({"marginTop": newVal + "px"}, 1000, "swing");
    });

	// highlight the current page in the menu
	// from: http://docs.jquery.com/Tutorials:Auto-Selecting_Navigation
	var fileName = window.location.pathname.substr(window.location.pathname.lastIndexOf("/") + 1);
	if(fileName.length === 0)
		fileName = "index.php";
 	$('#menu a[href$="' + fileName + '"]').attr('class', 'selected');
});

