/**
	Locks/fixes the position of the site's header and side menu
	(Uses the jQuery library)
	@author Tim Molderez
*/
$(function() {
	// Fix the header's x position
	var header = $("#header")
	var headerWidth = header.width()
	var win = $(window)
	win.scroll(function() {
		if (win.width() < headerWidth) {
			header.css("margin-left", -1 * win.scrollLeft())
		} else {
			header.css("margin-left", 0)
		}
	})
	
	// Lock the side menu's y position
	var sidemenu = $(".sidemenu")
	if (sidemenu.size()==0) {
		return
	}
	var menuOffset = sidemenu.offset().top - header.height()
	win.scroll(function() {
		if (win.scrollTop() > menuOffset) {
			sidemenu.stop().animate({marginTop: win.scrollTop() - menuOffset}, 250)
		} else {
			sidemenu.stop().animate({marginTop: 0}, 250)
		}
	})
})
