function setBounce(i) {
  iter = 0;
  setId = 0;
  down = true;
  up = false;

  bouncingBall = (is.VER5) ? document.getElementById(i).style
  : (is.NS) ? document.layers[i]
  : document.all[i].style;

  winH = (is.NS) ? window.innerHeight - 55 : document.body.offsetHeight - 55;

  document.onmouseup = buttonUp;
  if (is.NS4)
    document.captureEvents(Event.MOUSEUP);
}

function buttonUp(e) {
  if ( ((is.NS) ? e.which : event.button) != 1) return true;
  if (setId != 0) clearInterval(setId);
  bouncingBall.visibility="visible";
  bouncingBall.left = (is.NS) ? e.pageX - 15 : event.offsetX - 15;
  bouncingBall.top = (is.NS) ? e.pageY - 15 : event.offsetY - 15;
  target = parseInt(bouncingBall.top) + 200;
  iter = 0;
  num = 6;
  setId = setInterval("generateGravity()", 20);
  return true;
}

function ballHover() {
  if (setId != 0) clearInterval(setId);
//  target = (is.NS) ? e.pageY + 5 : event.offsetY + 5;
  target = 300;
  bouncingBall.left = 0;
  bouncingBall.top = parseInt(target) - 200;
  iter = 0;
  num = 6;
  setId = setInterval("generateGravity()", 20);
  return true;
}

function generateGravity() {
  bouncingBall.left = parseInt(bouncingBall.left) + parseInt(num / 2);
  if ((parseInt(bouncingBall.top)+iter < target) && down) {
    bouncingBall.top = parseInt(bouncingBall.top) + iter;
    iter++;
    return;
  }
  else {
    if ((parseInt(bouncingBall.top)< target) && down) {
    bouncingBall.top = target + 5;
    num--;
    if (num < 0) num = 0;
    return;
  }
  down = false;
  up = true;
  if (iter < 0 && parseInt(bouncingBall.top) > target) {
    clearInterval(setId);
    setId = 0;
  }
  if (parseInt(bouncingBall.top) > 0 && up && iter >= 0) {
    bouncingBall.top = parseInt(bouncingBall.top) - iter;
    iter--;
    if (iter%3 == 0) iter--;
      return;
    }
    down = true;
    up = false;
  }
}