var dynamicStyles = Class.create(); dynamicStyles.prototype = { initialize: function( container, left_arrow, right_arrow, current_class_index, classes, any_element ) { this.container = $(container); if( !this.container ) return false; this.classes = classes; this.max = (this.classes.length-1); if( this.max < 1 ) return false; this.current_class_index = current_class_index; this.left_arrow = $(left_arrow); this.right_arrow = $(right_arrow); this.any_element = null; if( any_element && $(any_element) ) this.any_element = $(any_element); Event.observe( this.left_arrow, 'click', this.changeStyle.bind( this, 1 ) ); Event.observe( this.right_arrow, 'click', this.changeStyle.bind( this, 0 ) ); }, changeStyle: function( shift_left ) { if( shift_left ) { if( this.current_class_index == 0 ) this.current_class_index = this.max; else this.current_class_index--; } else { if( this.current_class_index == this.max ) this.current_class_index = 0; else this.current_class_index++; } if( this.any_element ) this.any_element.className = this.classes[this.current_class_index]; this.container.className = this.classes[this.current_class_index]; } }