var Carrousel = function( properties ) { if( properties ) this.carrouselProperties = properties; else { this.carrouselProperties = { startColor: '#FFFFFF', endColor: '#FF0000', duration: 4000, transition: 1000, startPos: 0, endPos: -80, opacity: 0.8 }; } this.stageObjectsArray = []; this.currentStageObject = 1; this.totalStageObjects = $('StageCarrouselInfo').getElementsByTagName('li').length; this.previousStageObject = 0; this.intervalTimer = null; for( var i = 0; i < this.totalStageObjects; i++ ) { this.stageObjectsArray.push( $('CarrouselInfo-' + ( i + 1 ) ) ); this.stageObjectsArray[i].set('tween', {duration: this.carrouselProperties.transition, link:'chain'}); } this.RefreshObjects = function() { for( var i = 1; i < this.totalStageObjects; i++ ) { this.stageObjectsArray[i].setStyles({opacity: 0}); } } this.RefreshObjects(); this.MoveForward = function() { this.stageObjectsArray[this.currentStageObject].style.display = 'block'; this.stageObjectsArray[this.currentStageObject].tween('opacity', 0, 1); this.stageObjectsArray[this.previousStageObject].tween('opacity', 1, 0);//.tween('display', 'none');; ( this.previousStageObject == (this.totalStageObjects - 1) ) ? this.previousStageObject = 0 : this.previousStageObject++; ( this.currentStageObject < (this.totalStageObjects - 1) ) ? this.currentStageObject++ : this.currentStageObject = 0; } this.Start = function() { clearInterval(this.intervalTimer); this.intervalTimer = setInterval( 'myCarrousel.MoveForward()', this.carrouselProperties.duration); } } var myCarrousel = null; window.addEvent('domready', function(){ myCarrousel = new Carrousel(); myCarrousel.Start(); });