/* Downloaded from http://www.fubiz.net/ - Packaged by answeb - http://www.answeb.net/ */
var clrzMachinegun = new Class({
    Implements: [Options, Events],
    options: {
        elt: "",
        fps: 24,
        length: 800
    },
    initialize: function (a) {
        this.setOptions(a);
        this.element = $(this.options.elt);
        this.width = this.element.getStyle("width").toInt();
        this.speed = (1000 / this.options.fps);
        this.pos = 0;
        this.frame = 1;
        this.lastFrame = (this.options.length / this.width);
        this.direction = 0
    },
    setDirection: function (a) {
        if (a) {
            this.direction = a
        }
        return this
    },
    play: function () {
        this.moove();
        this.timer = this.moove.periodical(this.speed, this);
        this.fireEvent("play");
        return this
    },
    stop: function () {
        $clear(this.timer);
        this.fireEvent("stop");
        return this
    },
    rewind: function () {
        this.pos = 0;
        this.element.setStyle("background-position", "0px 0");
        return this
    },
    end: function () {
        this.stop();
        this.fireEvent("end");
        return this
    },
    moove: function () {
        this.pos = this.pos + this.width;
        this.frame = (this.pos / this.width);
        if (this.frame == (this.lastFrame)) {
            this.end();
            return
        }
        var a = (this.direction == 0) ? "-" : "";
        this.element.setStyle("background-position", a + this.pos + "px 0")
    }
});
