$(function () { // run this code on page load (AKA DOM load)
 
	/* set variables locally for increased performance */
	var scroll_timer;
	var displayed = false;
	var $window = $(window);
	var top = $(document.body).children(0).position().top;
	$('#scroll_guide').html("<span>Scroll down for more details</span>");
	var $message = $('#scroll_guide');	
		if($window.scrollTop() == top) // hide if at the top of the page
				{
					displayed = true;
					$message.stop(true, true).show();
				}	
 
	/* react to scroll event on window */
	$window.scroll(function () {
		window.clearTimeout(scroll_timer);
		scroll_timer = window.setTimeout(function () { // use a timer for performance
			if($window.scrollTop() == top) // hide if at the top of the page
			{
				displayed = true;
				$message.stop(true, true).show();
			}
			else if(displayed == true) // show if scrolling down
			{ 
				displayed = false;
				$message.stop(true, true).fadeOut(500);
			}
		}, 100);
	});
});