/**
 * Animates a cover.
 */
var CoverAnimator = Class.create
({
    initialize: function (box, anim, link, ajax)
    {
        this._box = $(box);
        this._anim = $(anim);
        this._link = link;
        this._ajax = ajax;
        
        this._box.observe('mouseover', this._slideOut.bind(this));
        this._box.observe('mouseout', this._slideIn.bind(this));
        this._box.observe('click', this._click.bind(this));
    },
    
    _click: function (evt)
    {
    	if (this._link)
    	{
	        if (this._ajax)
	        {
	            new Ajax.Updater();
	        }
	        else
	        {
	            document.location.href = this._link;
	        }
    	}
        
        evt.stop();
    },
    
    _slideOut: function (evt)
    {
        if (this._effect) this._effect.cancel();
        var params = { mode: 'absolute', x: this._right, duration: this._duration, transition: Effect.Transitions.sinoidal };
        this._effect = new Effect.Move(this._anim, params);
        
        evt.stop();    
    },
    
    _slideIn: function (evt)
    {
        if (this._effect) this._effect.cancel();
        var params = { mode: 'absolute', x: this._left, duration: this._duration, transition: Effect.Transitions.sinoidal };
        this._effect = new Effect.Move(this._anim, params);

        evt.stop();    
    },
    
    _left: 0,
    _right: 25,
    _duration: 0.3,
    _effect: 0
});
