swfobject.registerObject("swfStartseite", "9.0.115", "images/expressInstall.swf");

var images = ["1_Eingang.jpg", "2_Marker.jpg", "3_Buecher.jpg", "4_Kuenstler.jpg", "5_Mittag.jpg", "6_Katja.jpg", "7_Strech.jpg", "8_Sylvia.jpg", "9_Pause.jpg", "10_Parkhaus.jpg"];
var effects = ["top", "right", "bottom", "left"];
var current_image = 1;
var current_effect = 0;

function animateHomepage() {
  setTimeout(cycleImages,3500);
}

function aufraeumen() {
  $('#illustrationstart img:first').remove();
  setTimeout(cycleImages,4000);  
}

function slideIn(direction, src, title) {
  var img = new Image();
  
  $(img)
    .load( function() {
      $('#illustrationstart').append(this);
      var time = 350;
      
      if( direction == "top") {
        $(this).css("top", "-350px");
      } else if( direction == "right") {
        $(this).css("left", "940px");
        time = 700;
      } else if( direction == "bottom") {
        $(this).css("top", "350px");
      } else {
        $(this).css("left", "-940px");        
        time = 700;
      }
      
      $(this).animate( { top: "0px", left: "0px" }, { queue: false, duration: time, complete: aufraeumen } );
    })
    .error( function() {
      alert("Fehler beim Laden des Bildes " + src);
    })
    .attr('src', src)
    .attr('alt', title);
}

function cycleImages() {
  var image = images[current_image];
  var effect = effects[current_effect];
  slideIn(effect, "images/startseite_animation/" + image, image);
  current_image = (current_image+1) % images.length;
  current_effect = (current_effect+1) % effects.length;
}

$(document).ready(function() {
  $('#illustration').wrapInner('<div id="illustrationstart"></div>');
  animateHomepage();
});

