//written by kevin@hyperdisk.com
var MooAutoScroll = new Class({
    Implements: [Options, Events],
    options:
    {
        container: null,
        id: null,
        offset: 0,
        _start: 0,      //start point
        _end: 0         //end point
    },
    initialize: function(options)
    {
        this.setOptions(options);
        
        var ele = $(this.options.id); 
        var container = $(this.options.container);
        
        //check to make sure the content and container are there
        if(!$chk(ele) || !$chk(container))
            return;
            
        this.options._start = container.getHeight() - this.options.offset;
        this.options._end = -ele.getHeight() + this.options.offset;
        
        var duration = ele.getHeight() * 90      //90 is a magic number that I chose to create a good scrolling speed
        
        this._scroll = new Fx.Tween(ele, {
            duration: duration,
            transition: 'linear',
            onComplete: function()
            {
               this._start();
            }.bind(this)
        });     
        
        ele.addEvents({
            mouseenter: function()
            {
                this._scroll.pause();
            }.bind(this),
            mouseleave: function()
            {
                this._scroll.resume();
            }.bind(this)
        });
        
        //start scrolling
        this._start();
    },
    
    _start: function()
    {
         this._scroll.start('margin-top', this.options._start, this.options._end); 
    }
});