/*
---
description: A little and simple mootools plugin for toggling between unlimited functions assigned to an event.

license: free to use for everyone

authors:
- Daniel Pisanec

*/

var EventToggle = new Class({
    Implements: [Options],
    
    toggle_cnt: {},
    options: {
        event_name: 'click'
    },
    
    initialize: function(els, funx, options)
    {
        this.func_cnt = funx.length;
        this.setOptions(options);
        this.toggle_cnt[this.options.event_name] = 0;

        els.addEvent(this.options.event_name, function(e) {
            
            if($type(funx[this.toggle_cnt[this.options.event_name]]) == 'function') {
                funx[this.toggle_cnt[this.options.event_name]](e);
                this.toggle_cnt[this.options.event_name]++;
            }
            else {
                funx[0](e);
                this.toggle_cnt[this.options.event_name] = 1;
            }
        }.bind(this));
    }
});

