function setupParallax(layers) {
  var w = $(window);
  /* Scroll the background layers */
  function parallaxScroll() {
    var scrolled = - w.scrollTop();
    for (var layer in layers) {
      $(layer).css('top', scrolled * layers[layer]);  
    }
  }

  /* Scroll event handlers */
  var didScroll = false;
  w.bind('scroll',function(e){
    didScroll = true;
  });

  setInterval(function() {
    if (didScroll) {
      didScroll = false;
      parallaxScroll();
    }
  }, 5);
    

}

/**
 * @param widthWithBackground the effective width of the page content including background images
 * @param contentOffset the horizontal offset of the whole page. Ideally 0.
 * @param contentWidth the width of the content area, which the centering will keep on screen as long
 *   as the window is wide enough to display it
 */
function setupCentering(widthWithBackground, contentOffset, contentWidth) {
  centerPage();

  function centerPage() {
    var width = $(document.body).width();
    var left;

    if (contentWidth < width) {
      left = (width - widthWithBackground) / 2 - contentOffset;
      $('.parallax-container').css('left', left);
      $('#wrapper').css('left', left);
    } 
  }

  var documentWidth = $(document.body).width();
  $(window).resize(function() {
    var newWidth = $(document.body).width();
    if (Math.abs(documentWidth - newWidth) > 5) {
      centerPage();
      documentWidth = newWidth;
    }
  });
};


/* Set navigation dots to an active state as the user scrolls */
/*
function redrawDotNav(){
	var section1Top =  0;
	// The top of each section is offset by half the distance to the previous section.
	var section2Top =  $('#frameless-parachute').offset().top - (($('#english-channel').offset().top - $('#frameless-parachute').offset().top) / 2);
	var section3Top =  $('#english-channel').offset().top - (($('#about').offset().top - $('#english-channel').offset().top) / 2);
	var section4Top =  $('#about').offset().top - (($(document).height() - $('#about').offset().top) / 2);;
	$('nav#primary a').removeClass('active');
	if($(document).scrollTop() >= section1Top && $(document).scrollTop() < section2Top){
		$('nav#primary a.manned-flight').addClass('active');
	} else if ($(document).scrollTop() >= section2Top && $(document).scrollTop() < section3Top){
		$('nav#primary a.frameless-parachute').addClass('active');
	} else if ($(document).scrollTop() >= section3Top && $(document).scrollTop() < section4Top){
		$('nav#primary a.english-channel').addClass('active');
	} else if ($(document).scrollTop() >= section4Top){
		$('nav#primary a.about').addClass('active');
	}
	
}
*/
