var FadeText = new Array
(
  "Nominated for \"Nobel Peace Prize\"",
  "Winner of \"Bovine of the year\" award",
  "Awarded \"First place\" @ Coma3",
  "Be ready to eXPerience...",
  "The first DHTML-only demo EVER!",
  "no plugins (except for sound)  Macromedia:  eat your heart out",
  "no applets [or apples]",
  "no code",
  "20% HTML",
  "90% JScript",
  "115% pure fun for the whole family",
  "MOV",
  "PUSH",
  "POP",
  "INT",
  "We are aliens,",
  "not plants or jellyfishes",
  "(shht, don't tell)",
  "no artists were injured in",
  "the making of this demo",
  "This crazy demo was so rushed",
  "we didn't even have time t",
  "everything is okay in the end",
  "if it's not okay, then it's not the end",
  "it's okay.",
  "the end"
);

function FadeInit ( source )
{
  if ( source == 0 )
  {
    var magic = window.document.documentElement.offsetWidth / 16;
    document.all.content.style.fontSize = magic;
    document.all.content.style.top = ( window.document.documentElement.offsetHeight / 2 ) - magic;
    document.all.content.style.height = window.document.documentElement.offsetHeight - parseInt ( document.all.content.style.top );
    document.all.content.style.color = "000000";
    document.body.style.backgroundColor = "000000";
  }
  else if ( source == 22 )
  {
    var magic = window.document.documentElement.offsetWidth / 19;
    document.all.content.style.fontSize = magic;
    document.all.content.style.top = ( window.document.documentElement.offsetHeight / 2 ) - magic;
    document.all.content.style.height = window.document.documentElement.offsetHeight - parseInt ( document.all.content.style.top );
    document.all.content.style.color = "000000";
    document.body.style.backgroundColor = "000000";
  }


  document.all.content.innerHTML = '<center>' + FadeText[source] + '</center>';
}

function CrossFadeSetup ( )
{
  var Style = 'style="font-size:' + Math.round ( window.document.documentElement.offsetWidth / 31 ) + '"';
  document.all.content.innerHTML += '<div id="top" ' + Style + '></div>';
  document.all.content.innerHTML += '<div id="bottom" ' + Style + '></div>';
}

function FinalCrossFadeSetup ( )
{
  var Style = 'style="font-size:' + Math.round ( window.document.documentElement.offsetWidth / 20 ) + '"';
  document.all.content.innerHTML += '<div id="top" ' + Style + '></div>';
  document.all.content.innerHTML += '<div id="bottom" ' + Style + '></div>';
  var magic = window.document.documentElement.offsetWidth / 20;
  document.all.content.style.top = ( window.document.documentElement.offsetHeight / 2 ) - magic * 2;
  document.all.content.style.height = window.document.documentElement.offsetHeight - parseInt ( document.all.content.style.top );
}

function MPPICrossFadeSetup ( )
{
  var docWidth = window.document.documentElement.offsetWidth;
  var Style = 'style="position:absolute;font-size:' + Math.round ( docWidth / 4 ) + '"';
  document.all.content.innerHTML += '<div id="top" ' + Style + '></div>';
  document.all.content.innerHTML += '<div id="bottom" ' + Style + '></div>';
  document.all.top.zOrder = "Front";
  document.all.top.style.top = 0;
  document.all.top.style.width = docWidth;
  document.all.bottom.zOrder = "Front";
  document.all.bottom.style.top = window.document.documentElement.offsetHeight / 2;
  document.all.bottom.style.width = docWidth;
}

function CrossFadeInit ( sourceTop, sourceBottom )
{
  if ( sourceTop != -1 )
  {
    document.all.top.innerHTML = '<center>' + FadeText[sourceTop] + '</center>';
  }
  else
  {
    document.all.top.innerText = '';
  }

  if ( sourceBottom != -1 )
  {
    document.all.bottom.innerHTML = '<center>' + FadeText[sourceBottom] + '</center>';
  }
  else
  {
    document.all.bottom.innerText = '';
  }
}

function Hexadecimal ( number )
{
  var Hex = new Array ( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' );
  var Retval = '';
  for ( e = 0; e < 6; e++ )
  {
    Retval = Hex[number & 0x00000F] + Retval;
    number = number / 16;
  }
  return Retval;
}

function FadeIn ( percentage )
{
  var c = percentage * 255 / 100;
  document.all.content.style.color = Hexadecimal ( ( c << 16 ) + ( c << 8 ) + c );
}

function FadeOut ( percentage )
{
  var c = (100 - percentage) * 255 / 100;
  document.all.content.style.color = Hexadecimal ( ( c << 16 ) + ( c << 8 ) + c );
}

function CrossFadeUp ( percentage )
{
  var c, d;
  c = percentage * 255 / 100;
  d = 255 - c;
  document.all.top.style.color = Hexadecimal ( ( c << 16 ) + ( c << 8 ) + c );
  document.all.bottom.style.color = Hexadecimal ( ( d << 16 ) + ( d << 8 ) + d );
}

function CrossFadeDown ( percentage )
{
  var c, d;
  c = (100 - percentage) * 255 / 100;
  d = 255 - c;
  document.all.top.style.color = Hexadecimal ( ( c << 16 ) + ( c << 8 ) + c );
  document.all.bottom.style.color = Hexadecimal ( ( d << 16 ) + ( d << 8 ) + d );
}

function FadeClose ( )
{
  document.all.content.style.top = 0;
  document.all.content.style.height = window.document.documentElement.offsetHeight;
}