function opacity(id, opacStart, opacEnd, millisec) {
  // speed for each frame
  var speed = Math.round(millisec / 100);
  var timer = 0;

  // determine the direction for the blending, if start and end are the same nothing happens
  if (opacStart > opacEnd) {
    for (i = opacStart; i >= opacEnd; i--) {
      setTimeout('changeOpac(' + i + ",'" + id + "')", (timer * speed));
      timer++;
    }
  } else if (opacStart < opacEnd) {
    for (i = opacStart; i <= opacEnd; i++) {
      setTimeout('changeOpac(' + i + ",'" + id + "')", (timer * speed));
      timer++;
    }
  }
}

// change the opacity for different browsers
function changeOpac(opacity, id) {
  var object = document.getElementById(id).style;
  object.opacity = (opacity / 100);
  object.MozOpacity = (opacity / 100);
  object.KhtmlOpacity = (opacity / 100);
  object.filter = 'alpha(opacity=' + opacity + ')';
}

function animate() {
  setTimeout("opacity('logo', 0, 100, 500)", 500);
  setTimeout('move0();', 2000);

  setTimeout("document.getElementById('ApplicationName').style.visibility = 'visible'", 2200);

  setTimeout('move1();', 5000);
  setTimeout("opacity('logo_right', 100, 0, 100)", 5000);
  setTimeout("opacity('logo_right', 0, 100, 400)", 5100);
  setTimeout("document.getElementById('BannerSlogan').style.display = ''", 6500);
  setTimeout("document.getElementById('VersionInBanner').style.display = ''", 6500);
}

distance0 = 195; // 195
speed0 = 19;
bounce0 = 0;

function move0() {
  document.getElementById('logo_left').style.left = distance0 + 'px'; // muove "logo_left" alla posizione i
  document.getElementById('logo_right').style.right = distance0 + 'px'; // muove "logo_right" alla posizione i
  speed0--;
  distance0 -= speed0;
  if ((distance0 > 40) || (bounce0 < 10)) // se non � arrivato a destinazione...
  { setTimeout(move0, 1); } // riesegui ogni 1ms
  if (distance0 <= 40) bounce0++;
}

distance1 = 214; // 195 285
speed1 = 20;
bounce1 = 0;

function move1() {
  document.getElementById('logo_right').style.right = distance1 + 'px'; // muove "logo_right" alla posizione i
  speed1--;
  distance1 += speed1;
  if ((distance1 < 285) || (bounce1 < 25)) // se non � arrivato a destinazione... //240 - 25
  { setTimeout(move1, 1); } // riesegui ogni 1ms
  if (distance1 >= 285) bounce1++;
}

window.attachEvent('onload', animate);
