var Carousel = Class.create(); Carousel.prototype = { initialize: function( carousel_container, carousel_content, slides ) { this.ccontainer = $(carousel_container); this.ccontent_id = carousel_content; this.ccontent = $(this.ccontent_id); this.slides_class = slides; //this.prev = $(prev); //this.next = $(next); this.auto = false; this.index = 0; this.step = 30; this.slides = new Array(); this.IE = ( navigator.userAgent.indexOf('MSIE') != -1 ) ? true : false; this.init(); //Event.observe( this.prev, 'click', this._prev.bind(this) ); //Event.observe( this.next, 'click', this._next.bind(this) ); }, init: function() { this.slides = $A( this.ccontainer.getElementsByClassName(this.slides_class) ); if( !this.slides.length ) return false; this.min = 0 - this.slides[0].getWidth(); Element.setStyle( this.ccontent, { left: 0 } ); this.timeout = setTimeout( this.move.bind(this, 0), 5000 ); }, move: function(ch) { c = false; ch -= this.step; if( ch < this.min ) ch = this.max; if( ch > this.min ) c = true; if(!this.IE) Element.setStyle( this.ccontent_id, { left: ch+'px' } ); if(!c) { this.change(); return true; } this.slide_timeout = setTimeout( this.move.bind(this,ch), 20 ); }, change: function() { if( this.slide_timeout ) clearTimeout(this.slide_timeout); new Insertion.Bottom( this.ccontent, '
'+this.slides[0].innerHTML+'
' ); this.slides[0].remove(); this.init(); } }