(function() {
    if (!window.console) {
        window.console = {}; 
    };
    if (!window.console.debug) {
        window.console.debug = function() {};
    };
    var blacklist = ["@","%2540","%40","user=","email=","emailaddress=","password=","pw=","un=","username="];
var url = (window.location.search || window.location.href).toLowerCase();
for (var i = 0; i < blacklist.length; i++) {
    var word = blacklist[i];
    if (url.indexOf(word) !== -1 || decodeURIComponent(url).indexOf(word) !== -1) {
        console.debug("[CAN] aborted load after finding "+word);
        aborted = true;
        return;
    };
};

var iframe = document.createElement('iframe');
iframe.src = 'https://ads.counciladvertising.net/frame/southamptonc/ibar/public';
iframe.width = '100%';
iframe.height = '0px';
iframe.frameborder = 'none';
iframe.style.display = 'block';
iframe.style.border = '0px';
iframe.style.position = 'fixed';
iframe.style.bottom = '0px';
var gdpr = null;
var addScript = function(url) {
    var script = document.createElement("script");

    script.type = "text/javascript";
    script.src = url;
    script.async = 'async';
    var head = document.head || document.getElementsByTagName('head')[0];
    head.appendChild(script);

    return script;
};

var load = function () {
    window.addEventListener('message', function(event) {
        if (event.origin === "https:\/\/ads.counciladvertising.net") {
            if (event.data && event.data.event && event.data.event == 'can_resizeIframe') {
                iframe.height = event.data.height+'px';
            }
        }
    });
    document.body.appendChild(iframe);
};

if (gdpr == null) {
    load();
} else {
    addScript(gdpr);
    window.addEventListener('canGdprConsent', function (e) {
        if (e.consent) {
            load();
        }
    });
}
})();
