
/*
 * PlayerPopup
 * @author Gennadiy Ukhanov
 * @version 0.0.1
 */
(function(_global){
    /**
     * @namespace PlayerPopup
     * @name PlayerPopup
     */
    PlayerPopup = function() {
        this.module = $('.b-popup');
    };

    /**
     * @namespace PlayerPopup
     * @name PlayerPopup
     */
    PlayerPopup.prototype = {

        /**
         * @public
         */
        create : function(url) {
            this.wrap = this.module.find('.b-popup__wrapper')
            this.wrap.css("top", $(window).height()/2-this.wrap.height()/2)
            this.wrap.css("left", $(window).width()/2-this.wrap.width()/2)

            this.finalHeight = this.wrap.height();
            this.finalWidth = this.wrap.width();

            this.wrap.find('object').hide();
            this.wrap.find('.b-popup__inner').hide().fadeIn(1000, $.proxy(this, "onShowPlayer"))

            $(window).resize($.proxy(this, 'resize'))
            $('.b-popup__navigation__link').click($.proxy(this, "close"))
        },

        onShowPlayer : function() {
            this.wrap.find('object').show();
        },

        onHidePlayer : function() {
            $('.b-popup').fadeOut(400);
        },

        close : function() {
            this.wrap.find('object').hide();
            this.wrap.find('.b-popup__inner').fadeOut(700, $.proxy(this, "onHidePlayer"))
            return false;
        },

        /**
         * @public
         */
        resize : function(data) {
            this.wrap.css("top", $(window).height()/2-this.wrap.height()/2)
            this.wrap.css("left", $(window).width()/2-this.wrap.width()/2)
        }

    }


})(window || this);



