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) {
  document.getElementById(id).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')';
}

function animate() {
  logoPosition = parseInt(document.getElementById('logo').firstChild.style.right);
  var sa = 2500; // when the second animation starts
  // hide all banner items\\
  BannerSlogan.parentNode.style.display = 'none';
  VersionInBanner.parentNode.style.display = 'none';
  changeOpac(0, 'ApplicationName');
  changeOpac(0, 'LeftComputer');
  changeOpac(0, 'RightComputer');
  // changeOpac(0,'logo'); //conflicts with ApplicationName's change of opacity
  // changeOpac(0,'BannerSlogan'); //must have a fixed width to work
  // changeOpac(0,'VersionInBanner');
  // animations\\
  // opacity('logo', 0, 100, 500); //fade in the logo // conflicts as above
  document.getElementById('logo').firstChild.style.right = 0; // center the logo
  moveLogo(); // move the logo to its designated position
  setTimeout("opacity('ApplicationName',	0, 100, 500)", sa);
  setTimeout("BannerSlogan.parentNode.style.display = ''", sa + 200);
  setTimeout("VersionInBanner.parentNode.style.display = ''", sa + 300);
  setTimeout("opacity('LeftComputer',		0, 100, 500)", sa + 400);
  setTimeout("opacity('RightComputer',	0, 100, 500)", sa + 400);
}
var logoPosition;
var currentPosition = 0;
var frames = 50;
var currentFrame = 0;

function moveLogo() {
  currentPosition = (Math.sin((++currentFrame * (Math.PI / 2)) / frames - Math.PI / 2) + 1) * logoPosition / 2;
  document.getElementById('logo').firstChild.style.right = currentPosition + 'px';
  if (currentFrame < frames * 2) { setTimeout(moveLogo, 1); }
}
window.attachEvent('onload', animate);
