if (typeof window.syncRoadBlock == 'undefined') {
    function syncRoadBlock(adTag)
    {
        adTag = adTag.replace("tile=2", "tile=1");
        rb = document.getElementById("roadblock");
        if (rb && rb.id) {
            rb.innerHTML = '<iframe src="' + adTag + '" id="ifr_companion" width=300 height=250 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no>' + '</iframe>';
            rb.style.visibility = "visible";
        }
    }
    function showPlayerMask(adTag)
    {
        adTag = adTag.replace("tile=2", "tile=1");
        pm = document.getElementById("playermask");
        if (pm && pm.id) {
            var xmlHttp = null;
            try {
                // Mozilla, Opera, Safari, Internet Explorer 7
                xmlHttp = new XMLHttpRequest();
            } catch(e) {
                try {
                    // Internet Explorer 6
                    xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
                } catch(e) {
                    try {
                        // Internet Explorer 5
                        xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
                    } catch(e) {
                        xmlHttp  = null;
                    }
                }
            }
            if (xmlHttp) {
                xmlHttp.open('GET', '/adproxy.php?' + adTag, true);
                xmlHttp.onreadystatechange = function () {
                    if (xmlHttp.readyState == 4) {
                        if (xmlHttp.responseText.length > 10) {
                            // dimensions must match template
                            var pmad = new SWFObject(xmlHttp.responseText,"NVBPlayerMask","800","600","7","#000000");
                            pmad.addParam("allowfullscreen","false");
                            pmad.addParam("quality","high");
                            pmad.addParam("scale","noScale");
                            pmad.addParam("wmode","transparent");
                            pmad.addParam("allowScriptAccess","always");
                            pmad.write("playermask");

                            pm.style.visibility = "visible";
                        }
                    }
                };
                xmlHttp.send(null);
            }
        }
    }
    function hideRoadBlock()
    {
        rb = document.getElementById("roadblock");
        if (rb && rb.id) {
            rb.style.visibility = "hidden";
        }
        pm = document.getElementById("playermask");
        if (pm && pm.id) {
            pm.style.visibility = "hidden";
        }
    }

    function HTML5Video(swf, player, width, height, x, background) {
        this.width = width;
        this.height = height;
    }

    HTML5Video.prototype.addParam = function(key, value) { }

    HTML5Video.prototype.addVariable = function(key, value) { this[key] = value; }

    HTML5Video.prototype.write = function(holder) {
        var source = checkDevice();
        $("#"+holder).html('<video src="http://video.golem.de/download/' + this.id + '?q=medium&rd=' + source + '" poster="' + this.image_src + '" width="' + this.width+ '" height="' + this.height+ '" controls>');
    }

    function checkDevice() {
        var ua = navigator.userAgent;
        if  ((ua.search(/AppleWebKit/i) > 0) && (ua.search(/Macintosh/i) < 0)) {
            if (ua.search(/iPad/i) > 0) {
                return "iPad";
            } else if (ua.search(/iPhone/i) > 0) {
                return "iPhone";
            } else if (ua.search(/iPod/i) > 0) {
                return "iPod";
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
}

