var countage = 20;
var intC = "";
var intC = "";

function count() {
    countage = (countage - 1);
    document.getElementById('abpcnt').innerHTML = countage;
    if (countage == 0) {
        if (intC) {
            clearInterval(intC);
        }
        disba();
    }
}

function disba() {
    document.getElementById('abpmsg').style.display = "none";
    document.getElementById('abpmsgBG').style.display = "none";
}
adblockblock = function() {
    if (window.addEventListener) {
        window.addEventListener('load', this.bind(this.initialize), false);
    } else if (window.attachEvent) {
        window.attachEvent('onload', this.bind(this.initialize));
    }
};

adblockblock.prototype = {

    initialize: function() {
        this.interval = setInterval(this.bind(this.test), 5000);
        this.test();
    },

    test: function() {
        var element = document.getElementById('topAd');
        var bindin = this.getStyle(element, '-moz-binding');
        if (!window.helloworld && bindin != "none") {
            this.logger('AdBlock');
            return this.block();
        }
    },

    getStyle: function(element, key) {
        if (document.defaultView && document.defaultView.getComputedStyle) {
            return document.defaultView.getComputedStyle(element, '').getPropertyValue(key);
        } else {
            return element.currentStyle[key];
        }
    },


    block: function() {
        if (this.interval) clearInterval(this.interval);

        var lang = "";
        if (document.getElementById('lang')) {
            lang = document.getElementById('lang').className;
        }
        if (lang == "") {
            lang = 'en';
        }
            if (lang == "fr") {
                lgg = "fr";
            }
            else {
                lgg = "en";
            }
            var el = document.createElement('div');
            el.id = "abpmsg";
            el.style.position = "fixed";
            el.style.border = "2px #000 solid";
            el.style.top = "50px";
            el.style.left = "50%";
            el.style.marginLeft = "-348px";
            el.style.width = "696px";
            el.style.height = "500px";
            el.style.zIndex = "99999";
            el.style.backgroundColor = "#FFF";
            document.body.appendChild(el);

            var eld = document.createElement('div');
            eld.id = "abpmsgBG";
            eld.style.position = "fixed";
            eld.style.zIndex = "9999";
            eld.style.top = "0px";
            eld.style.bottom = "0px";
            eld.style.left = "0px";
            eld.addEventListener('click', disba, false);
            eld.style.right = "0px";
            eld.style.backgroundColor = "#000";
            eld.style.opacity = "0.6";
            document.body.appendChild(eld);
            if (document.getElementById('abpmsg')) {
                document.getElementById('abpmsg').innerHTML = "<img src='/images/abp_" + lgg + ".jpg' /><br><br><div align='center'><span id='abpcnt' style='font-size:36px'></h2><br><br></span>";
                intC = setInterval(count, 1000);
            }

    },

    bind: function(func) {
        var obj = this;
        return function() {
            return func.apply(obj, []);
        };
    },

    logger: function(str) {
        if (typeof console == 'undefined') return;
        if (typeof console.log == 'undefined') return;
        console.log(str);
    }
};

var adsb = new adblockblock();
