(function () {
    // temp vars, needed for loading only. use window[wj][hash][embedConfig] when needed
    var wjEmbedConfig = {"formTemplate":null,"formColor":null,"buttonText":"JETZT REGISTRIEREN","buttonBgColor":null,"buttonBgOpacity":null,"buttonPadding":null,"buttonFontSize":null,"buttonTextColor":null,"hash":"ky9r1s2","memberId":265954,"webinarId":1,"embedType":"button","dependencies":{"js":"https:\/\/event.webinarjam.com\/js\/registration_embed.js?v=","css":"https:\/\/event.webinarjam.com\/css\/styles_bottombar.css?v="},"routes":{"convertDates":"https:\/\/event.webinarjam.com\/register\/ky9r1s2\/convert-dates","trackVisitor":"https:\/\/event.webinarjam.com\/register\/ky9r1s2\/visitor","registrationForm":"https:\/\/event.webinarjam.com\/register\/1\/ky9r1s2\/form?ts=1763188514\u0026buttonText=JETZT%20REGISTRIEREN"},"translations":{"Text_days":"Tagen","Text_hours":"STUNDEN","Txt_instant_replay":"Aufzeichnung von gestern ansehen","MSG_minutes":"Minuten","MSG_seconds":"Sekunden","Txt_connecting_to_server":"Verf\u00fcgbarkeit wird gepr\u00fcft...","Txt_join_event_in_progress":"An laufendem Event teilnehmen"},"iframeOverlayHtml":"\u003Cdiv class=\u0022wj_registration-overlay\u0022 style=\u0022top: 0px; display: none;\u0022\u003E\n    \u003Cdiv id=\u0022wj_registration_frame_holder\u0022 style=\u0022margin: 0 auto; max-width: 700px;\u0022\u003E\n        \u003Cdiv style=\u0022height: 270px;\u0022\u003E\n            \u003Cdiv class=\u0022wj_overlay-loading-screen\u0022 style=\u0022display:;\u0022\u003E\n                \u003Cdiv class=\u0022wj_overlay_inner\u0022\u003E\n    \u003Cdiv class=\u0022wj_css_spinner_coghweel n_s wj_mb-4\u0022\u003E\n        \u003Cdiv\u003E\n            \u003Ci\u003E\u003C\/i\u003E\n            \u003Ci\u003E\u003C\/i\u003E\n        \u003C\/div\u003E\n    \u003C\/div\u003E\n    \u003Cspan\u003E\u003Clang data-tag=\u0022Txt_connecting_to_server\u0022\u003E{{Txt_connecting_to_server}}\u003C\/lang\u003E\u003C\/span\u003E\n\u003C\/div\u003E\n            \u003C\/div\u003E\n            \u003Ciframe src=\u0022\u0022 id=\u0022wj_registration_frame\u0022 frameborder=\u00220\u0022 name=\u0022wj_registration_frame\u0022 scrolling=\u0022no\u0022 style=\u0022display:none; height: 270px; max-width: 700px; width: 100vw; z-index: 1000000; -webkit-overflow-scrolling: touch\u0022\u003E\u003C\/iframe\u003E\n        \u003C\/div\u003E\n    \u003C\/div\u003E\n\u003C\/div\u003E\n"},
        webinarHash = wjEmbedConfig['hash'],
        embedType = wjEmbedConfig['embedType'];
    var utmParameters = getUtmQueryParameters(window.location.href);
    var allowRedirect = document.location.origin.match(/webinarjam(dev)?\.com/g);

    wjEmbedConfig['timezoneOffset'] = -(new Date()).getTimezoneOffset();

    if (
        typeof window['wj'] !== 'undefined' &&
        typeof window['wj'][webinarHash] !== 'undefined' &&
        'undefined' !== typeof window['wj'][webinarHash][embedType]
    ) {
        return;
    }

    window['wj'] = 'undefined' === typeof window['wj'] ? [] : window['wj'];
    window['wj'][webinarHash] = 'undefined' === typeof window['wj'][webinarHash] ? {} : window['wj'][webinarHash];
    window['wj'][webinarHash][embedType] = 'undefined' === typeof window['wj'][webinarHash][embedType] ? wjEmbedConfig : window['wj'][webinarHash][embedType];

    var jsJquery    = document.createElement("script");
    jsJquery.type   = "text/javascript";
    jsJquery.onload = init;
    jsJquery.src    = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js";
    document.body.appendChild(jsJquery);

    var ua     = window.navigator.userAgent,
        iOS    = !!ua.match(/iP(ad|od|hone)/i),
        webkit = !!ua.match(/WebKit/i),
        isiOS  = iOS && webkit;

    function init() {
        if (embedType === 'bar' || embedType === 'bubble') {
            document.body.insertAdjacentHTML('beforeend', wjEmbedConfig.barHtml);
        }

        loadDependencies();
    }

    function loadDependencies() {
        var head  = document.getElementsByTagName('head')[0];
        var wjCssId = 'wjCss-' + webinarHash + '-' + Date.now();
        if (!document.getElementById(wjCssId)) {
            var link  = document.createElement('link');
            link.id   = wjCssId;
            link.rel  = 'stylesheet';
            link.type = 'text/css';
            link.href = wjEmbedConfig.dependencies.css;
            link.media = 'all';
            head.appendChild(link);
        }

        var wjJsId = 'wjJs-' + webinarHash + '-' + Date.now();
        if (!document.getElementById(wjJsId)) {
            var script  = document.createElement('script');
            script.id   = wjJsId;
            script.type = 'text/javascript';
            script.onload = realInit;
            script.src = wjEmbedConfig.dependencies.js;
            document.body.appendChild(script);
        }

        var jsToastr    = document.createElement("script");
        jsToastr.type   = 'text/javascript';
        jsToastr.src    = 'https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.4/toastr.min.js';
        document.body.appendChild(jsToastr);

        var linkToastr  = document.createElement('link');
        linkToastr.rel  = 'stylesheet';
        linkToastr.type = 'text/css';
        linkToastr.href = 'https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.4/toastr.min.css';
        linkToastr.media = 'all';
        head.appendChild(link);

        var styleToastr = document.createElement('style');
        styleToastr.innerHTML = '#toast-container > .toast-error {\n' +
            '        background-image: none!important;\n' +
            '        padding-left: 15px!important;\n' +
            '        background-color: #e13352!important;\n' +
            '        border-left: 5px solid #ae1a34!important;\n' +
            '        opacity: 1!important;\n' +
            '        -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100)!important;\n' +
            '        filter: alpha(opacity=100)!important;\n' +
            '    }';
        head.appendChild(styleToastr);
    }

    function realInit() {
        if (embedType === 'bar') {
            return initBottomBar();
        }

        if (embedType === 'button') {
            return initButton();
        }

        if (embedType === 'bubble') {
            return initBubble();
        }
    }

    function initBubble() {
        window['wj'][webinarHash]['jQuery'] = jQuery.noConflict(true);
        window['wj'][webinarHash]['jQuery'].ajaxSetup({
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true
        });
        var jQ = window['wj'][webinarHash]['jQuery'];

        jQ(document).ready(function() {
            var barBgColor = tinycolor(wjEmbedConfig.barBgColor);
            var buttonBgColor = tinycolor(wjEmbedConfig.buttonBgColor);
            var data = {
                offset: wjEmbedConfig.timezoneOffset,
                limit: 3,
                source: "bar",
            };

            barBgColor.setAlpha(wjEmbedConfig.barBgOpacity);
            buttonBgColor.setAlpha(wjEmbedConfig.buttonBgOpacity);

            var datesXhr = jQ.post(wjEmbedConfig.routes.convertDates, data);

            datesXhr.done(function (response) {
                if (response.registrationDates.length === 0) {
                    if (typeof response.pendingChanges !== 'undefined' && response.pendingChanges === true) {
                        jQ('.wj_embed_bubble_detail_box_title').text(wjEmbedConfig.translations.Txt_webinar_not_ready_yet);
                        jQ('.wj_embed_bubble_detail_box_text').text(wjEmbedConfig.translations.Txt_preparing_webinar);
                    } else {
                        if (response.replayUrl && allowRedirect) {
                            return window.location = response.replayUrl;
                        }
                        jQ('.wj_embed_bubble_detail_box_title').text(wjEmbedConfig.translations.Txt_this_webinar_expired);
                        jQ('.wj_embed_bubble_detail_box_text').text(wjEmbedConfig.translations.Txt_webinar_already_taken_place);
                        jQ('.wj_embed_bubble_detail_box').addClass('wj_red_overlay_content');
                        jQ('.js_wj_bubble_registration_in_progress').css('display', 'none');
                        jQ('.js_wj_bubble_registration_expired').css('display', 'block');
                    }

                    jQ('.wj_red_overlay_content').removeClass('wj_hide');
                } else {
                    var filteredEvents = [];

                    jQ.each(response.registrationDates, function (index, date) {
                        if (
                            ('undefined' === typeof date.is_date || true === date.is_date) &&
                            ('undefined' === typeof date.instant_replay || false === date.instant_replay)
                        ) {
                            filteredEvents.push(date);
                        }
                    });

                    var filteredEventsLength = filteredEvents.length;

                    if (!filteredEventsLength) {
                        jQ('.wj_embed_bubble_detail_box_date').text(response.registrationDates[0].text);
                        jQ('.wj_embed_bubble_detail_box_countdown').text(response.registrationDates[0].relative_text);
                    } else {
                        jQ('.wj_embed_bubble_detail_box_date').text(filteredEvents[0].text);
                        jQ('.wj_embed_bubble_detail_box_countdown').text(filteredEvents[0].relative_text);

                        if (filteredEventsLength > 1) {
                            jQ('.wj_embed_bubble_detail_box_link').css('display', '');
                        }
                    }
                }

                // replacements for colors, text, countdown
                jQ('.wj_embed_bubble_detail_box_button').text(wjEmbedConfig.buttonText);
                jQ('.wj_embed_bubble_detail_box').css("background-color", barBgColor);
                jQ('.js_bubble_webinar_cta').css("background-color", buttonBgColor);
                <!-- jQ('.js_bubble_toggle').css("background-color", barBgColor); -->
                jQ('.wj_embed_bubble_detail_box_button').css("background-color", buttonBgColor).attr('data-webinarHash', webinarHash);
                jQ('.wj_embed_bubble_detail_box_link').css('color', buttonBgColor).attr('data-webinarHash', webinarHash);
                jQ('.wj_embed_bubble_detail_box_title').text(wjEmbedConfig.webinarTitle);

                var initTime = Date.now();

                // start countdown
                var countdownOptions = {
                    fontFamily: '"Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
                    displayDays: false,
                    displayCaptions: true,
                    fontSize: 12,
                    countdown: true,
                }

                if (response.countdownSeconds > 0) {
                    countdownOptions.seconds = response.countdownSeconds;
                    if (countdownOptions.seconds / 3600 < 24) {
                        jQ('.wj_embed_bubble_detail_box_countdown').css('display', 'none');
                        jQ('.js_countdown').css('display', 'block');
                    }
                    var countdownDays = Math.floor(countdownOptions.seconds/86400);
                    if (countdownDays >= 100) {
                        countdownOptions.displayDays = 3;
                    }
                } else {
                    countdownOptions.timeTo = new Date();
                    countdownOptions.start = false;
                }

                jQ('.js_countdown').timeTo(countdownOptions);

                jQ('.js_countdown figcaption:eq(0)').html('<lang data-tag="Text_hours">{{Text_hours}}</lang>');
                jQ('.js_countdown figcaption:eq(1)').html('<lang data-tag="MSG_minutes">{{MSG_minutes}}</lang>');
                jQ('.js_countdown figcaption:eq(2)').html('<lang data-tag="MSG_seconds">{{MSG_seconds}}</lang>');

                document.addEventListener('visibilitychange', function logData() {
                    if (document.visibilityState === 'hidden') {
                        jQ('.js_countdown').timeTo('stop');
                    }
                    if (document.visibilityState === 'visible') {
                        if (countdownOptions.seconds > 0) {
                            var timeNow = Date.now();
                            var timeDiff = Math.round((timeNow - initTime) / 1000);
                            countdownOptions.seconds = response.countdownSeconds - timeDiff;
                        }
                        if (countdownOptions.seconds <= 0) {
                            countdownOptions.timeTo = new Date();
                            countdownOptions.start = false;
                        }
                        jQ('.js_countdown').timeTo(countdownOptions);
                    }
                });

                // show bar
                jQ('.wj_embed_circle_wrapper').fadeIn();

                // init registration modal
                replaceLang();
                initRegistrationModal();
                trackVisitor();
            });
            datesXhr.fail(function () {
                console.error('Could not get dates from WJ server');
            })
        });
    }

    function initBottomBar() {
        window['wj'][webinarHash]['jQuery'] = jQuery.noConflict(true);
        window['wj'][webinarHash]['jQuery'].ajaxSetup({
            xhrFields: {
               withCredentials: true
            },
            crossDomain: true
        });
        var jQ = window['wj'][webinarHash]['jQuery'];

        jQ(document).ready(function() {
            var $html = jQ('html'),
                $body = jQ('body');

            var barBgColor = tinycolor(wjEmbedConfig.barBgColor);
            barBgColor.setAlpha(wjEmbedConfig.barBgOpacity);

            var buttonBgColor = tinycolor(wjEmbedConfig.buttonBgColor);
            buttonBgColor.setAlpha(wjEmbedConfig.buttonBgOpacity);

            var data = {
                offset: wjEmbedConfig.timezoneOffset,
                limit: 3,
                source: "bar",
            };

            var datesXhr = jQ.post(wjEmbedConfig.routes.convertDates, data);

            datesXhr.done(function (response) {
                if (response.registrationDates.length === 0) {
                    if (typeof response.pendingChanges !== 'undefined' && response.pendingChanges === true)  {
                        jQ('.wj_red_overlay_title').text(wjEmbedConfig.translations.Txt_webinar_not_ready_yet);
                        jQ('.wj_red_overlay_desc').text(wjEmbedConfig.translations.Txt_preparing_webinar);
                    } else {
                        if (response.replayUrl && allowRedirect) {
                            return window.location = response.replayUrl;
                        }
                        jQ('.wj_red_overlay_title').text(wjEmbedConfig.translations.Txt_this_webinar_expired);
                        jQ('.wj_red_overlay_desc').text(wjEmbedConfig.translations.Txt_webinar_already_taken_place);
                    }

                    jQ('.wj_red_overlay_content').removeClass('wj_hide');
                } else {
                    var filteredEvents = [];

                    jQ.each(response.registrationDates, function (index, date) {
                        if (
                            ('undefined' === typeof date.is_date || true === date.is_date) &&
                            ('undefined' === typeof date.instant_replay || false === date.instant_replay)
                        ) {
                            filteredEvents.push(date);
                        }
                    });

                    var filteredEventsLength = filteredEvents.length,
                        $template = jQ('#wj-templates #wj-template-date-new').clone();

                    if (!filteredEventsLength) {
                        $template.find('li.js_date_container').text(response.registrationDates[0].text);
                    } else {
                        $template.find('li.js_date_container').text(filteredEvents[0].text);

                        if (filteredEventsLength > 1) {
                            jQ('.wj_embed_bubble_detail_box_link').css('display', '');
                        }
                    }

                    jQ('ul.js_all_schedules').html($template.html());
                }

                var timezoneCities = response.timezone.cities;

                // replacements for dates, colors, text, countdown
                jQ('.js_register_text').text(wjEmbedConfig.buttonText);
                jQ('.js_bottom_bar_bg').css("background-color", barBgColor);
                jQ('.js_wj_register_button').css("background-color", buttonBgColor);
                jQ('.js_wj_register_button').attr('data-webinarHash', webinarHash);
                jQ('.wj_embed_bubble_detail_box_link').css('color', buttonBgColor).attr('data-webinarHash', webinarHash);
                jQ('.js_wj_timezone_text').text(timezoneCities);

                var initTime = Date.now();

                // start countdown
                var countdownOptions = {
                    fontFamily: '"Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
                    displayDays: 2,
                    displayCaptions: true,
                    fontSize: 26,
                    captionSize: 10,
                    countdown: true,
                }
                if (response.countdownSeconds > 0) {
                    countdownOptions.seconds = response.countdownSeconds;
                    var countdownDays = Math.floor(countdownOptions.seconds/86400);
                    if (countdownDays >= 100) {
                        countdownOptions.displayDays = 3;
                    }
                } else {
                    countdownOptions.timeTo = new Date();
                    countdownOptions.start = false;
                }
                jQ('.js_countdown').timeTo(countdownOptions);

                jQ('.js_countdown figcaption:eq(0)').html('<lang data-tag="Text_days">{{Text_days}}</lang>');
                jQ('.js_countdown figcaption:eq(1)').html('<lang data-tag="Text_hours">{{Text_hours}}</lang>');
                jQ('.js_countdown figcaption:eq(2)').html('<lang data-tag="MSG_minutes">{{MSG_minutes}}</lang>');
                jQ('.js_countdown figcaption:eq(3)').html('<lang data-tag="MSG_seconds">{{MSG_seconds}}</lang>');

                document.addEventListener('visibilitychange', function logData() {
                    if (document.visibilityState === 'hidden') {
                        jQ('.js_countdown').timeTo('stop');
                    }
                    if (document.visibilityState === 'visible') {
                        if (countdownOptions.seconds > 0) {
                            var timeNow = Date.now();
                            var timeDiff = Math.round((timeNow - initTime) / 1000);
                            countdownOptions.seconds = response.countdownSeconds - timeDiff;
                        }
                        if (countdownOptions.seconds <= 0) {
                            countdownOptions.timeTo = new Date();
                            countdownOptions.start = false;
                        }
                        jQ('.js_countdown').timeTo(countdownOptions);
                    }
                });

                // show bar
                jQ('.wj_embed_wrapper').fadeIn();

                // init registration modal
                replaceLang();
                initRegistrationModal();
                trackVisitor();
            });
            datesXhr.fail(function () {
                console.error('Could not get dates from WJ server');
            })
        });
    }

    function initButton() {
        window['wj'][webinarHash]['jQuery'] = jQuery.noConflict(true);
        window['wj'][webinarHash]['jQuery'].ajaxSetup({
            xhrFields: {
               withCredentials: true
            },
            crossDomain: true
        });
        var jQ = window['wj'][webinarHash]['jQuery'];

        jQ(document).ready(function() {
            var $html = jQ('html'),
                $body = jQ('body');
            var $button = jQ('.js-embed-button');

            if ($button) {
                var buttonBgColor = tinycolor(wjEmbedConfig.buttonBgColor);
                buttonBgColor.setAlpha(wjEmbedConfig.buttonBgOpacity);

                $button.text(wjEmbedConfig.buttonText);
                $button.css("padding", wjEmbedConfig.buttonPadding);
                $button.css("font-size", wjEmbedConfig.buttonFontSize);
                $button.css("color", wjEmbedConfig.buttonTextColor);
                $button.css("background-color", buttonBgColor);

                $button.parent().fadeIn();
            }

            initRegistrationIframeOverlay();

            // init registration modal
            replaceLang();
            initRegistrationModal();
            trackVisitor();
        });
    }

    function replaceLang() {
        var jQ = window['wj'][webinarHash]['jQuery'];

        // replace any translations
        jQ('lang').each(function (key, item) {
            var $item = jQ(item);
            var tag = $item.attr('data-tag');
            $item.text(wjEmbedConfig.translations[tag]);
        });
    }

    function initRegistrationIframeOverlay() {
        var jQ = window['wj'][webinarHash]['jQuery'];

        if (jQ('.wj_registration-overlay').length) {
            return ;
        }

        if (typeof wjEmbedConfig.iframeOverlayHtml === 'undefined') {
            return ;
        }

        document.body.insertAdjacentHTML('beforeend', wjEmbedConfig.iframeOverlayHtml);
    }

    function initRegistrationModal() {
        var jQ = window['wj'][webinarHash]['jQuery'];

        jQ(document).ready(function() {
            var $html = jQ('html');
            var $body = jQ('body');
            var $iframe = jQ('#wj_registration_frame');

            window['wj'][webinarHash]['real_loaded'] = false;
            window['wj'][webinarHash]['fake_loaded'] = false;


            window.removeEventListener('message', window['wj']['wjOnIframeMessage'], true);
            window.addEventListener('message', window['wj']['wjOnIframeMessage'], false);

            // registration button click
            jQ('[data-webinarHash='+webinarHash+']').off().on('click', function () {

                $body.addClass("wj_body_reset");
                $html.css('overflow', 'hidden');

                var $self  = jQ(this),
                    webinarHash = $self.attr('data-webinarHash');

                jQ('.wj_registration-overlay').show();
                var iframeSrc = wjEmbedConfig.routes.registrationForm + '&offset=' + wjEmbedConfig.timezoneOffset;
                Object.keys(utmParameters).map(function(utmKey){
                    if(iframeSrc.indexOf(utmKey) === -1) {
                        iframeSrc += '&' + utmKey + '=' + utmParameters[utmKey];
                    }
                });

                if (allowRedirect) {
                    iframeSrc += '&allowRedirect=true';
                }

                $iframe.attr('src', iframeSrc);

                setTimeout(function() {
                    hideLoader(webinarHash, 'fake');
                }, 3000);
            });
        });
    }

    function trackVisitor() {
        var jQ = window['wj'][webinarHash]['jQuery'];

        jQ(document).ready(function() {
            var $html = jQ('html'),
                $body = jQ('body'),
                hasVisitorCookie = window.wjHasCookie(wjEmbedConfig.memberId, webinarHash),
                visitorCookie = window.wjTrackingCookie(wjEmbedConfig.memberId, webinarHash);

            if (!hasVisitorCookie) {
                jQ.post(wjEmbedConfig.routes.trackVisitor, {});
                window.wjSetVisitorCookie(wjEmbedConfig.memberId, webinarHash);
            }
        });
    }

    window['wj']['wjOnIframeMessage'] = function (message) {
        if ('undefined' === typeof message.data) {
            return;
        }

        if (message.data['func'] === 'error') {
            if (message.data['errorCode'] === '429') {
                toastr.options = {
                    closeButton: true,
                    positionClass: 'toast-bottom-right',
                    timeOut: 0,
                    extendedTimeOut: 0
                };
                toastr.error("Something went wrong, please try again!", "Error")
                closeModal();
                return;
            }
        }

        var webinarHash = message.data.hash;

        if (
            'undefined' === typeof webinarHash ||
            'undefined' === typeof window['wj'][webinarHash] ||
            'undefined' === typeof window['wj'][webinarHash]['jQuery']
        ) {
            return;
        }

        var jQ = window['wj'][webinarHash]['jQuery'];

        switch (message.data['func']) {
            case 'loaded':
                hideLoader(webinarHash, 'real');
                break;
            case 'resize':
                adjustFrameSize(webinarHash, message.data['height'] + 'px');
                break;
            case 'resizeWidth':
                adjustFrameWidth(webinarHash, message.data['width'] + 'px');
                break;
            case 'toTop':
                jQ(window).scrollTop(0);
                break;
            case 'redirect':
                recursiveRedirect(window.parent, message.data['url']);
                break;
            case 'close':
                closeModal();
                break;
        }
    }

    function closeModal() {
        var jQ = window['wj'][webinarHash]['jQuery'];
        var $html = jQ('html');
        var $body = jQ('body');

        window['wj'][webinarHash]['real_loaded'] = false;
        window['wj'][webinarHash]['fake_loaded'] = false;

        // hide the whole popup
        // show the loader inside the hidden popup
        // hide the iframe inside the hidden popup
        jQ('.wj_registration-overlay').hide();
        jQ('.wj_overlay-loading-screen').show();
        jQ('#wj_registration_frame').hide();

        $html.css('overflow','auto');
        $body.css('height','').removeClass('wj_body_reset');

        adjustFrameSize(webinarHash, '270px');
    }

    function recursiveRedirect(parent, url) {
        try {
            parent.location = url;
        } catch(err) {
            parent = parent.parent;
            recursiveRedirect(parent, url);
        }
    }

    function hideLoader(webinarHash, version) {
        var jQ = window['wj'][webinarHash]['jQuery'];

        window['wj'][webinarHash][version + '_loaded'] = true;

        if (window['wj'][webinarHash]['real_loaded'] && window['wj'][webinarHash]['fake_loaded']) {
            jQ('.wj_overlay-loading-screen').hide();
            jQ('#wj_registration_frame').show();

            // @todo
            var theFrame = document.getElementById('wj_registration_frame').contentWindow;
            theFrame.postMessage({
                'func': 'childResize',
            }, '*')
        }
    }

    function adjustFrameSize(webinarHash, height) {
        var jQ = window['wj'][webinarHash]['jQuery'],
            $theFrame = jQ('#wj_registration_frame');

        $theFrame.css('height', height);
        $theFrame.parent().css('height', height);

    }

    function adjustFrameWidth(webinarHash, width) {
        var jQ = window['wj'][webinarHash]['jQuery'];
        jQ('#wj_registration_frame_holder').css('max-width', width)
        jQ('#wj_registration_frame').css('max-width', width)
    }

    function rePosition(webinarHash) {
        if (!window['wj'][webinarHash]['wj_lock_scroll']) {
            return false;
        }

        var jQ            = window['wj'][webinarHash]['jQuery'],
            $htmlBody     = jQ('html,body'),
            scrollTop     = jQ(window).scrollTop(),
            screenY       = Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
            scrollBottom  = jQ(window).scrollTop() + screenY,
            marginTop     = screenY * 0.2, // 20% of screen size
            marginBot     = screenY * 0.5, // 50% of screen size
            modalOverlay  = jQ('.wj_registration-overlay'),
            modalPadding  = parseInt(modalOverlay.css('paddingTop')),
            iframeHeight  = jQ('#wj_registration_frame').outerHeight(),
            height        = screenY > iframeHeight ? screenY : iframeHeight,
            frameBot      = modalPadding + height;

        if (scrollTop < modalPadding - marginTop) {
            $htmlBody.stop().animate({scrollTop: modalPadding}, 50, 'swing');
            return true;
        } else if (scrollBottom > frameBot + marginBot) {
            $htmlBody.stop().animate({scrollTop: frameBot - screenY}, 50, 'swing');
            return true;
        }

        return false;
    }

    function getUtmQueryParameters(url) {
        var queryStart = url.indexOf('?');
        if (queryStart === -1) {
            return {};
        }

        var queryString = url.substring(queryStart + 1);
        var parameterPairs = queryString.split('&');
        var parameters = {};

        parameterPairs.map(function(pair) {
            var pairSplit = pair.split('=');
            const decodedKey = decodeURIComponent(pairSplit[0]);

            if (decodedKey.indexOf('utm_') === 0) {
                parameters[decodedKey] = decodeURIComponent(pairSplit[1]).trim();
            }
        });

        return parameters;
    }
})();
