//_admob.fetchAd(document.getElementById('admob'));

if (typeof cy$aframe != "undefined")
    ++cy$aframe;
else {
    cy$aframe = 1;

    this.addEventListener("load", function() {
        for (var aframe = 0; aframe != cy$aframe; ++aframe)
            cy$fixad('aframe' + aframe);
    });
}

cy$fixad = function (id) {
    var ifrm = document.getElementById(id);
    var iwin = ifrm.contentWindow;

    var ifix = function() {
        var idoc = iwin.document;
        if (idoc.styleSheets.length == 0)
            return false;

        var icss = idoc.styleSheets[0];
        var rule = icss.cssRules.length;

        var isad = function() {
            var gradient = idoc.getElementsByClassName("gradient");
            if (gradient.length == 0) {
                setTimeout(isad, 500);
                return;
            }

            gradient[0].style.cssText = '';

            var style = idoc.getElementsByClassName("cav")[0].style;
            style.left = '265px';
            style.top = '5px';

            var labels = idoc.getElementsByClassName("label");

            var style = labels[0].style;
            style.left = '45px'; style.top = '5px';
            style.width = '212px';

            var style = labels[1].style;
            style.left = '192px'; style.top = '23px';

            icss.insertRule('body { margin: 0 9px; }', rule++);
            //alert(idoc.getElementsByTagName("div")[0].innerHTML);
        };

        setTimeout(isad, 500);

        ifrm.height = 40;

        icss.insertRule('.adText { line-height: 15px; }', rule++);
        icss.insertRule('.branding { left: 204px; top: 22px; }', rule++);
        icss.insertRule('.tile { padding: 4px; }', rule++);

        /*icss.insertRule('.label { \
            border: 1px solid red; \
        }', rule++);*/

        icss.insertRule('.gradient { \
            border: 1px solid #999999; \
        }', rule++);

        icss.insertRule('.front { \
        }', rule++);

        icss.insertRule('.front, .gradient { \
            -webkit-border-radius: 9px; \
            height: 38px; \
            padding: 0px; \
            width: 300px; \
        }', rule++);

        icss.insertRule('.adMiddle { \
            padding: 4px 6px; \
            width: 212px; \
            border: 1px solid red; \
        }', rule++);

        icss.insertRule('.beveled:not(.cav) { \
            background-position: center center; \
            background-repeat: no-repeat; \
            -webkit-border-bottom-left-radius: 9px; \
            -webkit-border-bottom-right-radius: 0; \
            -webkit-border-top-left-radius: 9px; \
            -webkit-border-top-right-radius: 0; \
            border: 1px solid #999999; \
            border-right: none; \
            height: 38px; \
            line-height: 38px; \
            margin: -5px; \
            width: 39px; \
        }', rule++);

        return true;
    };

    if (!ifix())
        iwin.addEventListener("load", ifix);
};
