
Blinker = new Class({
    options: {
        wait: true,
        duration: 500,
        transition: 'quint:out',
        startColor: '#ffff00',
        endColor: '#ffffff',
        cycles: 3
    },
    initialize: function(el, options) {
        this.setOptions(options);
        this.element = $(el);
        var startColor = this.options.startColor;
        var endColor = this.options.endColor;
        var cycles = this.options.cycles;
        var duration = this.options.duration;
        var smooth = duration * 2 + 100;
        var periodical;

        var blinkFx = new Fx.Tween(this.element, this.options);

        var blinkIt = function() {
            blinkFx.start('background-color', endColor, startColor).chain(function(){ blinkFx.start('background-color', endColor); });
        }

        if(this.element) {
            this.element.addEvent('scrollendpoint', function() {
                periodical = blinkIt.periodical(smooth);
                (function(){ $clear(periodical); }).delay(smooth*(cycles+1));
            });
        }
    }
});
Blinker.implement(new Options);