/*
	
	Website: Fliesen-Zentrum
	BOB Design http://www.bob-design.de/
	Imagion AG http://www.imagion.de/
	Javascript Datei
	20.02.2008 Daan Meskers
	$last_change: 21.05.2008 Daan Meskers
*/

window.addEvent('domready', function(){
   myHome.init()
});

var myHome = {
   init: function() {
      if (window.ie) {
         var i=0;
         var len = $('TeaserBlock').getElements('div.TeaserBlockItem').length-1 
         $('TeaserBlock').getElements('div.TeaserBlockItem').each( function( elm ) {
              //if ( i < len )
              if ( i > 0 )
              	 var fx = new Fx.Style( elm, 'opacity').set(0);
              i++
         });

      }
      this.counter = 0; this.zIndexCounter = 1
      this.elmsCarousel = $('TeaserBlock').getElements('div.TeaserBlockItem')
      window.setInterval( "myHome.rotate()", 5000)
   },
   rotate: function() {
      this.previous = this.elmsCarousel[ this.counter ]
      this.counter++
      if ( this.counter >= this.elmsCarousel.length)
         this.counter = 0
      var fx = new Fx.Styles( this.elmsCarousel[this.counter], {duration:1500} );
      fx.start({'opacity': [0.01, 1]})
      var fx2 = new Fx.Styles( this.previous, {duration:1500} );
      fx2.start({'opacity': [1, 0.01]})
	if ( this.elmsCarousel[this.counter] ) {
		this.elmsCarousel[this.counter].style.zIndex = this.zIndexCounter ;
		this.zIndexCounter++
	}

   }
}