jQuery(function(){
	//resetPosition();
	
	$(".menu-box").find('a').hover(function(){
		jQuery(this).stop().animate({ marginLeft: '6px' }, 150);
	}, function(){
		jQuery(this).stop().animate({ marginLeft: '0px'}, 150);
	});
	
//	$("#up").click(function(){
//		$(document).scrollTop(0);
//		return false;
//	});
	
	/* set variables locally for increased performance */
	var scroll_timer;
	var displayed = false;
	var $message = $('#up');
	var $window = $(window);
	var top = $(document.body).children(0).position().top;
 
	/* react to scroll event on window */
	$window.scroll(function () {
		$message.css('bottom', 100);
		window.clearTimeout(scroll_timer);
		scroll_timer = window.setTimeout(function () { // use a timer for performance
			if($window.scrollTop() <= top+200) // hide if at the top of the page
			{
				displayed = false;
				$message.fadeOut(800);
			}
			else if(displayed == false) // show if scrolling down
			{
				displayed = true;
				$message.stop(true, true).show().click(function () {
					window.location.hash = "";
					$(document).scrollTop(0); 
					$message.fadeOut(800); 
					return false; 
				});
			}
		}, 100);
	});


});
