var height = 256;
var angle = 0;

function drawStretch() {
  var a = angle;
  for (var i = 0; i < height; i++) {
    var e = document.getElementById("stretch-" + i);
    var y = 52 + (255 - i) + 51 * Math.sin(a);
    e.style.backgroundPosition = "0px " + y + "px";
    a += 0.0175;
  }
  angle += 0.2;
}

function initializeStretch() {
  document.write('<style type="text/css">');
  document.write('div.stretch {');
  document.write('position: absolute;');
  document.write('left: 1px;');
  document.write('top: 1px;');
  document.write('width: 256px;');
  document.write('height: 1px;');
  document.write('background-image: url("img/vesuri6.jpg");');
  document.write('z-index: 3;');
  document.write('}');
  document.write('</style>');
  for (var y = 0; y < height; y++) {
    document.write("<div id=\"stretch-" + y +"\" class=\"stretch\"></div>");
    var e = document.getElementById("stretch-" + y);
    e.style.top = (1 + y) + "px";
  }
}

randomInitializeFunctions.push(initializeStretch);
randomDrawFunctions.push(drawStretch);
