var infoBlock = Class.create(); infoBlock.prototype = { initialize: function( left_pointer_id, right_pointer_id, container_id, tag_name ) { this.blocks = new Array(); this.blocks = $(container_id).getElementsByTagName( tag_name ); this.blocks_count = this.blocks.length-1; this.left_pointer = $(left_pointer_id); this.right_pointer = $(right_pointer_id); this.current_index = 0; for( var i=1; i<=this.blocks_count; i++ ) { this.blocks[i].addClassName( 'hide' ); } Event.observe( this.left_pointer, 'click', this.switchBlock.bind( this, 'left' ) ) Event.observe( this.right_pointer, 'click', this.switchBlock.bind( this, 'right' ) ) }, switchBlock: function( direction ) { this.blocks[ this.current_index ].addClassName( 'hide' ); if( direction == 'right' ) { this.current_index = ( this.current_index == this.blocks_count )? 0 : this.current_index+1 ; } else if( direction == 'left' ) { this.current_index = ( this.current_index == 0 )? this.blocks_count : this.current_index-1 ; } this.blocks[ this.current_index ].removeClassName( 'hide' ); } };