var bottomScrollSpeed = 81;
var bottomScrollPause = 15 * 1000;

var bottomScrollInc = 1;
var maxBottomScrollInc = 16;
var bottomScrollPos = 0;
var nBottomImgs = 10;
var bottomImgWidth = 384;
var bottomImgsWidth = nBottomImgs * bottomImgWidth;
var rampUp = true;

function bottomShow() {
  var el;
  var posPx;

  bottomScrollPos += bottomScrollInc;
  if (rampUp) {
    if (bottomScrollInc > -maxBottomScrollInc && bottomScrollInc < maxBottomScrollInc) {
      bottomScrollInc *= 2;
      if (bottomScrollInc == maxBottomScrollInc || bottomScrollInc == -maxBottomScrollInc)
	rampUp = false;
    }
  }
  else if (bottomScrollPos % bottomImgWidth <= 2 * maxBottomScrollInc + 1 ||
  	   bottomImgWidth - (bottomScrollPos % bottomImgWidth) < 2 * maxBottomScrollInc - 1)
    bottomScrollInc /= 2;
  if (bottomScrollInc >= 0) {
    if (bottomScrollInc < 1)
      bottomScrollInc = 1;
  }
  else {
    if (bottomScrollInc > -1)
      bottomScrollInc = -1;
  }

  if (bottomScrollPos < 0)
    bottomScrollPos = 0;
  posPx = '-' + bottomScrollPos + 'px';
  //alert(posPx);
  el = document.getElementById("bottomImg");
  el.style.left = posPx;
  if (bottomScrollPos <= 0 ||
    bottomScrollPos > bottomImgsWidth - 2 * bottomImgWidth - 1) {
    bottomScrollInc *= -1;
  }
  if (bottomScrollPos % bottomImgWidth <= 1 ||
      bottomScrollPos % bottomImgWidth >= bottomImgWidth - 2)
    rampUp = true;
  setTimeout(bottomShow, (((bottomScrollPos % bottomImgWidth) == 0) ||
			  ((bottomScrollPos % bottomImgWidth) == (bottomImgWidth - 1)))
  			 ? bottomScrollPause
			 : bottomScrollSpeed);
}

function bottomShowPreLoad() {
  setTimeout(bottomShow, bottomScrollPause);
}
bottomShowPreLoad();
