/*
	
	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
*/
var mv ;
window.addEvent('domready', function(){
   mv = (MooTools.version=="1.11") ; // "1.2.1" || "1.11"
   myHome.init()
});

var myHome = {
   init: function() {
      if (window.ie || ( Browser.Engine && Browser.Engine.trident )) {
         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 = elm.setStyle( 'opacity', 0 )
              i++
         });

      }
      this.counter = 0; this.zIndexCounter = 1
      this.elmsCarousel = $('TeaserBlock').getElements('div.TeaserBlockItem')
      if ( this.elmsCarousel.length > 1 )
         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.Morph( $(this.previous), {duration:1500} );
      fx.start({'opacity': 0})
      
      var fx2 = new Fx.Morph( $(this.elmsCarousel[this.counter]), {duration:1500} );
      fx2.start({'opacity': 1})
      
      if ( this.elmsCarousel[this.counter] ) {
	 this.elmsCarousel[this.counter].style.zIndex = this.zIndexCounter ;
	 this.zIndexCounter++
      }

   }
}