(function( $ ) {
	'use strict';
    
    $(document).ready(function() {

        $('.olympus-video-lightbox').each(function(){
            $(this).on('click',function(){
                const lightboxWrap = $(this).next('.olympus-video-lightbox-wrap');
                const lightboxContent = lightboxWrap.find('.olympus-video-lightbox-content').first();
                lightboxContent.html(atob(lightboxContent.data('embed')));

                lightboxWrap.fadeIn(200);
            });
        });

        $('.olympus-video-lightbox-wrap').each(function(){
            $(this).on('click',function(){
                // close lightbox and make sure any video does not keep playing in the background
                const htmlTemp = $(this).html();
                $(this).fadeOut(200);
                $(this).html("");
                $(this).html(htmlTemp);
            });
        });

    });

})( jQuery );