/**
* UltimatePlayer Fade plugin (copyright 2011)
* @author zbigniew.labacz@gmail.com
* @package UltimatePlayer
*/
;(function($) {
    
    LIB.namespace('UltimatePlayer');
    
    UltimatePlayer.Fade = $.inherit(UltimatePlayer.Base, {
        
        /**
         * Konfiguracja animacji
         * @var {}
         */
        animationConfig: undefined,
        
        /**
         * Konstruktor
         */
        __constructor: function(dom, config)
        {
            this.__base(dom, config);
            this.animationConfig = this.config.animation;
        },
        
        /**
         * Dostosowanie elementów playera
         */
        customize: function()
        {
            this.getSlider().css({
                width:  this.config.width,
                height: this.config.height
            });
            
            var zIndex = 10;
            var disp = 'block';
            this.getElements().each(function() {
                $(this).css({
                    position: 'absolute',
                    left: 0,
                    right: 0,
                    zIndex: zIndex,
                    display: disp
                });
                zIndex = 9;
                disp = 'none';
            });
        },
        
        /**
         * Przeskok do klatki o indexie `index`
         * @param int index
         */
        animate: function()
        {
            var _this = this;
            this.getCurrentElement().css('z-index', 9);
            var targetElement = this.getElements().eq(this.getOffset());
            targetElement.css('z-index', 10);
            targetElement[this.animationConfig.type](this.animationConfig.duration, function() {
                _this.getCurrentElement().hide();
                _this.setCurrentElement(targetElement);
            });
        }
    });
    
})(jQuery);
