var liftTimer, liftTop=0, liftDir=1, liftInterval=100;

window.onload = function() {

  $("clientForm").onsubmit = function() {
    $("serverFrame").src =   "http://ajaxpatterns.org/crossframe/#"
                           + $("bgColor").value;
    return false;
  }

  setInterval(function() {
    if (window.location.hash=="#speedUp" && liftInterval>=60)   { liftInterval=Math.round(0.8*liftInterval); window.location.hash = "#"; launchLift(); }
    if (window.location.hash=="#slowDown" && liftInterval<500) { liftInterval=Math.round(1.2*liftInterval); window.location.hash = "#"; launchLift(); }
  }, 100);

  launchLift();

}

function launchLift() {
  clearTimeout(liftTimer);
  liftTimer = setInterval(function() {
    $("lift").style.top = liftTop + "px";
    liftTop+=liftDir*10;
    if (liftTop>=100) liftDir=-1;
    if (liftTop<=0) liftDir=1;
  }, liftInterval);
}
