function calcParallax(tileheight, speedratio, scrollposition) {
 
  return ((tileheight) - (Math.floor(scrollposition / speedratio) % (tileheight+1)));
}

window.onload = function() {

  window.onscroll = function() {
    var posX = (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : window.pageXOffset;
    var posY = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : window.pageYOffset;
    
	/*var background = document.getElementById('background');
    var backgroundparallax = calcParallax(0, 5, posY);
    background.style.backgroundPosition = "0 " + backgroundparallax + "px"; */
    
    var lowermidground = document.getElementById('lowermidground');
    var lowermidgroundparallax = calcParallax(500, 3, posY);
    lowermidground.style.backgroundPosition = "0 " + lowermidgroundparallax + "px"; 
	
	var midground = document.getElementById('midground');
    var midgroundparallax = calcParallax(500, 2, posY);
    midground.style.backgroundPosition = "0 " + midgroundparallax + "px"; 

    var foreground = document.getElementById('foreground');
    var foregroundparallax = calcParallax(500, 1, posY);
    foreground.style.backgroundPosition = "0 " + foregroundparallax + "px"; 
  }
/*
  document.getElementById('javascriptcode').onscroll = function() {
    var posX = (this.scrollLeft) ? this.scrollLeft : this.pageXOffset;
    var j = calcParallax(53, 16, posX);
    console.log('scroll js: '+ j);
    document.getElementById('javascriptcode').style.backbackgroundPosition = j + "px 0";
  }*/
}
