var navigatorTabs = Class.create(); navigatorTabs.prototype = { initialize: function( toggler_container_id, toggler_class, toggler_over_class, block_container_id, block_container_class, block_class, hidden_class ) { this.toggler_container = $(toggler_container_id); this.togglers = this.toggler_container.getElementsByClassName(toggler_class); this.container = $(block_container_id); this.blocks = this.container.getElementsByClassName(block_class); if( this.togglers.length != this.blocks.length ) { return false; } this.toggler_over_class = toggler_over_class; this.hidden_class = hidden_class; this.container.addClassName( block_container_class); this.container.addClassName( this.hidden_class ); this.blocks[0].addClassName( this.hidden_class ); this.blocks[1].addClassName( this.hidden_class ); this.observeToggler(this.togglers[0], this.blocks[1], this.blocks[0] ); this.observeToggler(this.togglers[1], this.blocks[0], this.blocks[1]); return true; }, observeToggler: function(toggler_obj, block_to_hide, block_to_show ) { Event.observe ( toggler_obj, 'click', this.switchBlocks.bind(this, block_to_hide, block_to_show ) ); Event.observe ( toggler_obj, 'mouseover', this.toggleClass.bind( this, toggler_obj ) ); Event.observe ( toggler_obj, 'mouseout', this.toggleClass.bind( this, toggler_obj ) ); return true; }, toggleClass: function( toggler_obj ) { if( toggler_obj.hasClassName(this.toggler_over_class) ) { toggler_obj.removeClassName(this.toggler_over_class); } else { toggler_obj.addClassName(this.toggler_over_class); } return true; }, switchBlocks: function( block_to_hide, block_to_show ) { if( !block_to_hide.hasClassName(this.hidden_class) ) { block_to_hide.addClassName(this.hidden_class); } if( block_to_show.hasClassName(this.hidden_class) ) { block_to_show.removeClassName(this.hidden_class); this.container.removeClassName(this.hidden_class); } else { this.container.addClassName(this.hidden_class); block_to_show.addClassName(this.hidden_class); } return true; } };