<!--

function positionBoxes() {
  positionBox(null, 'slide-show', 'c', 3.0);
  setTimeout("positionBox('slide-show', 'contactBox', 'br', 2.0)", 2500);
  setTimeout("positionBox('slide-show', 'imprintBox', 'bl', 2.0)", 2500);
  setTimeout("positionBox(null, 'validatorBox', 'br', 7.0)", 1500);
}

function positionBox(parentName, boxName, position, fadeTime) {
  var contentBoxDimensions = $(boxName).getDimensions();
  var contentBoxTop = 0;
  var contentBoxLeft = 0;

  if (parentName) {
    var parentPosition = $(parentName).positionedOffset();
    var parentDimensions = $(parentName).getDimensions();
    
    // position bottom right
    if (position == 'br') {
      contentBoxTop = parentPosition[1] + parentDimensions.height - contentBoxDimensions.height - 10;
      contentBoxLeft = parentPosition[0] + parentDimensions.width - contentBoxDimensions.width - 10;
    }

    // position bottom left
    if (position == 'bl') {
      contentBoxTop = parentPosition[1] + parentDimensions.height - contentBoxDimensions.height - 10;
      contentBoxLeft = parentPosition[0] + 10;
    }
  }
  else {
    var viewportOffset = document.viewport.getScrollOffsets();
    var viewportDimensions = document.viewport.getDimensions();

    // position center
    if (position == 'c') {
      contentBoxTop = viewportOffset.top + viewportDimensions.height / 2 - contentBoxDimensions.height / 2;
      contentBoxLeft = viewportOffset.left + viewportDimensions.width / 2 - contentBoxDimensions.width / 2;
    }

    // position bottom right
    if (position == 'br') {
      contentBoxTop = viewportDimensions.height - contentBoxDimensions.height - 10;
      contentBoxLeft = viewportDimensions.width - contentBoxDimensions.width - 10;
    }
    
    // position bottom left
    if (position == 'bl') {
      contentBoxTop = viewportDimensions.height - contentBoxDimensions.height - 10;
      contentBoxLeft = 10;
    }

  }

  if (contentBoxTop < 0)
    contentBoxTop = 10;
  
  if (contentBoxLeft < 0)
    contentBoxLeft = 10;
  
  $(boxName).absolutize();
  $(boxName).setStyle({
    top: contentBoxTop + 'px',
    left: contentBoxLeft + 'px',
    width: contentBoxDimensions.width + 'px',
    height: contentBoxDimensions.height + 'px'
  });
  
  if (fadeTime > 0) {
    $(boxName).appear({ duration: fadeTime });
  }
  else {
    $(boxName).show();
  }
  
}


var delay = 3500;
var start_frame = 0;

function init() {
  var lis = $('slide-images').getElementsByTagName('li');
  end_frame = lis.length - 1;
  start_slideshow(start_frame, end_frame, delay, lis);
}

function start_slideshow(start_frame, end_frame, delay, lis) {
  setTimeout(fadeInOut(start_frame,start_frame,end_frame, delay, lis), delay);
}

function fadeInOut(frame, start_frame, end_frame, delay, lis) {

  return (function() {
    lis = $('slide-images').getElementsByTagName('li');
    Effect.Fade(lis[frame], { duration: 5.0 });
    
    if (frame == end_frame) { 
      frame = start_frame; 
    } 
    else { 
      frame++; 
    }
    
    lisAppear = lis[frame];
    setTimeout("Effect.Appear(lisAppear, { duration: 5.0 });", 0);
    setTimeout(fadeInOut(frame, start_frame, end_frame, delay), delay + 1850);
  })
	
}


window.onload = positionBoxes;
setTimeout("init()", 2000);
//-->

