function drawlines() {
  space = (window.innerWidth - 150);

  anzahl = Math.floor(space/200);
  space = 200 * anzahl;
  position = 0;

  css = 'width:'+(space)+'px;' + 'margin-left:-'+(space / 2)+'px;';

  $('slideshow').morph(css);
  $('line').morph(css);
  $('thumbs').appear({ duration: 3.0, queue: 'end' });
}

function background(name,background) {
  $(name).morph('background: '+background, { duration: '0.5' });
}

function colorswitch(color) {
  $('logo').morph('background: '+color, { duration: '3.0' });
  $('line').morph('border-color: '+color, { duration: '3.0' });
  $('content').morph('border-color: '+color, { duration: '3.0' });

  var listItems = $('content').select('a');
  Effect.multiple(listItems,Effect.Morph,{ style: 'color: '+color, duration: 3.0 });
}

function rainbow() {
  farben = new Array("#cc00ff","#9933ff","#3399ff","#7ef43d","#ffcc33","#ff0000");
  zahl = Math.ceil(Math.random() * 6);
  colorswitch(farben[zahl]);
}

function opacity(name,opacity) {
  $(name).morph('opacity: '+opacity, { duration: '0.5' });
}

function losgehts() {
  drawlines();
  window.setInterval("rainbow()",12000);
}

function showcontent(id) {
  /*
  for (i = 1; i <= anzahl; ++i) {
    $('content_'+i).fade({ duration: 0.5 });
  }
  */
  if ( typeof aktiv != 'undefined') $('content_'+aktiv).fade({ duration: 0.5 });
  else $('content_start').fade({ duration: 0.5 });
  $('rainbow').fade({ duration: 0.5 });

  window.setTimeout('content_appear('+id+')',600);
  
  aktiv = id;
}

function content_appear(id) {
  $('content_'+id).appear({ duration: 1.0 });
  $('rainbow').appear({ duration: 1.0 });
}

function slide_next() {
  if (Math.abs(position - anzahl * 200) < (max * 200)) {
    position = position - anzahl * 200;
    $('thumbs').morph('margin-left: '+position+'px', { duration: '0.5' });
  }
  else Effect.Shake('thumbs',{ distance: 10 });
}

function slide_previous() {
  if (position < 0) {
    position = position + anzahl * 200;
    $('thumbs').morph('margin-left: '+position+'px', { duration: '0.5' });
  }
  else Effect.Shake('thumbs',{ distance: 10 });
}

// TASTATURNAVIGATION

document.onkeydown = function(event) {
  if (event.keyCode == 37) slide_previous();
  if (event.keyCode == 39) slide_next();
}

