
var logos = new Array;
var now = 0;
var the_width = 1200;
var the_height = 1200;
var cur_container = false;

function Startup()
 {
  var k = 0;

  while (true)
   {
    k++;

    if (wtf = $('l' + k))
     logos.push('l' + k);
    else
     break;
   }

logos.reverse();


  for (k = 0; k < logos.length; k++)
   {
    // IE sucks
    var i = $(logos[k]);

    i._deltax = 0;
    i._deltay = 0;

    i._targetx = k == 0 ? 5000 : -5000;
    i._targety = 0;

    i._nowx = i._targetx;
    i._nowy = i._targety;

    i.style.left = parseInt(i._targetx) + 'px';

    i._worker = setTimeout('ImageWorker("' + i.id + '");', 20);
   }


  Resize();
 }

function Resize()
 {
  the_width = document.body.clientWidth;
  the_height = document.body.clientHeight;

  $('sw1').style.top = ((the_height / 2) - 100) + 'px';
  $('sw2').style.top = ((the_height / 2) - 100) + 'px';

  $('sw1').style.display = 'block';
  $('sw2').style.display = 'block';

  Switch(0);
 }

function ImageWorker(i)
 {
  i = $(i);

  i._nowx += i._deltax;
  i._nowy += i._deltay;

  var newleft = Math.floor(i._nowx) + 'px';
  var newtop = Math.floor(i._nowy) + 'px';

  if (i.style.left != newleft) i.style.left = newleft;
  if (i.style.top != newtop) i.style.top = newtop;

  i._deltax = (i._targetx - i._nowx) / 5;
  i._deltay = (i._targety - i._nowy) / 5;

  i._worker = setTimeout('ImageWorker("' + i.id + '");', 20);
 }

function Switch(dir)
 {
  if ((now <= 0) && (dir == -1)) 
   {
    now = logos.length - 1;
    dir = 0;
   }
  else if ((now >= (logos.length - 1)) && (dir == 1)) 
   {
    now = 0;
    dir = 0;
   }

  now = now + dir;

  var cur = $(logos[now]);
  var prev = (now > 0) ? $(logos[now - 1]) : $(logos[logos.length - 1]);
  var next = (now < (logos.length - 1)) ? $(logos[now + 1]) : $(logos[0]);

  cur_container = cur;

  if (prev)
   {
    prev._targetx = -1000;
    prev._targety = 1000;
   }

  cur._targetx = the_width / 2 - 600 / 2;
  cur._targety = the_height / 2 - 450 / 2;

  if (next)
   {
    next._targetx = the_width + 1000;
    next._targety = 1000;
   }
      

  return false;
 }
