var clrzMachinegun = new Class({
    Implements: [Options,Events],	
    options:{
        elt:'',		
        fps:24,		
        length:600
    },			
    initialize: function(options)	{
        this.setOptions(options);
        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(direction)	{
        if(direction)			this.direction = direction;
        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.rewind();
        this.element.setStyle('background-position','0px 0');
        this.fireEvent('end');                /*new Fx.Morph($('loader'), {duration:1000, wait:false,transition:Fx.Transitions.Expo.easeOut}).start({'opacity': 0});                $(document.body).setStyle('overflow', 'auto');*/
        return this;
    },		
    moove:function()	{
        this.pos = this.pos+this.width;
        this.frame = (this.pos/this.width);
        if(this.frame==(this.lastFrame))		{
            this.element.setStyle('background-position','0px 0');
            this.end();
            return;
        }
        var operator = (this.direction==0) ? '-' : '';
        this.element.setStyle('background-position',operator+this.pos+'px 0');
    }
});
