// JavaScript Document


function calcParallax(tileheight, speedratio, scrollposition) {
	//    by Brett Taylor http://inner.geek.nz/
	//    originally published at http://inner.geek.nz/javascript/parallax/
	//    usable under terms of CC-BY 3.0 licence
	//    http://creativecommons.org/licenses/by/3.0/
	return (tileheight - (Math.floor(scrollposition / speedratio) % (tileheight+1)));
}
window.onload = function() {
	window.onscroll = function() {
		var posY = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : window.pageYOffset;
		
		var ground = document.getElementById('ground');
		var groundparallax = calcParallax(399, 7, posY);
		ground.style.backgroundPosition = "center " + groundparallax + "px"; 
		
		var fish = document.getElementById('fish');
		var fishparallax = calcParallax(1815, 2, posY);
		fish.style.backgroundPosition = "center " + fishparallax + "px"; 

		var ripple = document.getElementById('ripple');
		var rippleparallax = calcParallax(2000, 4, posY);
		ripple.style.backgroundPosition = "center " + rippleparallax + "px"; 
		
}
}



