/* Plugin to make variable height divs equal heights */
$.fn.sameHeights = function() {
		$(this).each(function(){
				var tallest = 0;
				$(this).children().each(function(i){
						if (tallest < $(this).height()) { tallest = $(this).height(); }
				});
				$(this).children().css({'height': tallest});
		});
		return this;
};




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 bg02 = document.getElementById('bg2');
		var bg02parallax = calcParallax(1200, 10, posY);
		bg02.style.backgroundPosition = "center " + bg02parallax + "px"; 
		
		
		var bg01 = document.getElementById('bg');
		var bg01parallax = calcParallax(1309, 5, posY);
		bg01.style.backgroundPosition = "center " + bg01parallax + "px"; 	
	}
}

