(function ($) {
    
    $('#Panels').entwine({
        FadeDuration: 400,
        FadeMultiplier: 1.5,
        FadeTimeout: 400,
        Timer: null,
        
        onmouseenter: function (e) {
            if (this.getTimer()) {
                window.clearTimeout(this.getTimer());
                this.setTimer(null);
            } else {
                if ($(e.target).is('#OverlayR')) {
                    $('#OverlayR').fadeOut(this.getFadeDuration());
                    $('#OverlayTM').fadeOut(this.getFadeDuration() * this.getFadeMultiplier());
                    
                    $('#PanelR').fadeIn(this.getFadeDuration());
                } else {
                    $('#OverlayR').fadeOut(this.getFadeDuration() * this.getFadeMultiplier());
                    $('#OverlayTM').fadeOut(this.getFadeDuration());
                
                    $('#PanelTM').fadeIn(this.getFadeDuration());
                }
            }
        },
        
        onmouseleave: function (e) {
            var that = this;
            this.setTimer(window.setTimeout(function () {
                $('.panel').fadeOut(that.getFadeDuration());
                $('#OverlayPanels img').fadeIn(that.getFadeDuration());
                that.setTimer(null);
            }, this.getFadeTimeout()));
        }
    });
    
})(jQuery);
