Function toggling

Like that found in jQuery.

HTML

<button>click</button>

JavaScript

Element.implement({
    toggle: function(event, fn, fn2){
        var flag = true;
        return this.addEvent(event, function(){
            (flag ? fn : fn2).apply(this, arguments);
            flag = !flag;
        });
    }
});

$$('button')[0].toggle('click',
    function(event){ console.log(event, 'one') },
    function(event){ console.log(event, 'two') }
).toggle('mouseenter',
    function(){ console.log('mousenter one') },
    function(){ console.log('mousenter two') }
);