// StartZEITe

  anzahl = 8; // Anzahl der Bilder (img/startX.jpg)
  img = 1;
  var nextimg;
  
  function StartBilder() {

    if(img == anzahl) {
      img = 0;
    };
  
    nextimg = (img+2);

    if(img == anzahl-1) {
      nextimg = 1;
    };
    
    var x = new Chain();
    var one = function(){
      //$('startbilder').fade(0);
      $('startbilder').set('tween', {duration: 1500});
      $('startbilder').tween('opacity',0); // instead of the fade method.
    };
    var two = function(){
      $('startbilder').src = 'site/img/start/start'+img+'.jpg';
      $('startbilder').setStyle('opacity', '1');
    };
    var three = function(){
      $('startbilder_bg').setStyle('background', 'url("site/img/start/start'+nextimg+'.jpg")');
    };
    x.chain(one);
    x.chain(two);
    x.chain(three);
    x.callChain(); 
    x.callChain.delay(1600, x);
    x.callChain.delay(1700, x);
       
    img = img + 1;
  };


window.addEvent("domready", function() {
  
  StartBilder.periodical(7000);
  // Frohes Neues Jahr is drin, trotzdem wechselnde Bilder
  
});
