function createLayers() {
    var shim = document.body.appendChild( document.createElement('div'));   
    shim.id = "shim1";
    shim.style.position="absolute";
    shim.style.top = "0px";
    shim.style.left = "0px";
    shim.style.width = "99.9%";
    shim.style.height = "99.5%";
    shim.style.display = 'none';
    shim.style.overflow = "none";
    shim.style.border = "1px solid black";
    shim.style.backgroundColor = "black";
    shim.style.opacity = "0.5";
    shim.innerHTML = ".";

    var popup = document.body.appendChild( document.createElement('div'));   
    popup.id = "popup1";
    popup.style.position="absolute";
    popup.style.top = "50px";
    popup.style.left = "0";
    popup.style.right = "0";
    popup.style.margin = "0 auto";
    popup.style.width = "695px";
    popup.style.height = "400px";
    popup.style.display = 'none';
    popup.style.border = "1px solid black";
    popup.style.backgroundColor = "white";
    popup.innerHTML = "<div id=\"popup2\" style=\"border:1px solid black;background-color:white;text-align:center;\">"
            + '...'
            + "<"+"/div>";
            

}
function showshim() {
    $('shim1').style.display = 'block';
}
function hideshim() {
    $('shim1').style.display = 'none';
}

function showgame(type,flashurl, width, height) {
    showshim();
    if (type == 'swf') {
        $('popup2').innerHTML = getPopupButtons() + getSwfContainer(flashurl, width, height);
    }else if (type == 'htm') {
        $('popup2').innerHTML = getPopupButtons() + getIframeContainer(flashurl, width, height);
    }
    $('popup1').style.display = 'block';
}

function hidegame() {
    $('popup1').style.display = 'none';
    $('popup2').innerHTML = 'no game';
    hideshim();

}

function getPopupButtons() {
    h = '<br/><a href="#Close_game" onClick="hidegame();return false;">Close Game</a> | '
      + '<a href="../contact.html">Get in touch</a><br/><br/>';
    return h;
}
   
function getSwfContainer(flashUrl, width, height) {
    h = '<embed src="' + flashUrl + '" quality="high" '
      + 'pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" '
      + 'width="' + width +'" '
      + 'height="' + height + '"><' + '/embed>';
    return h;
}

function getIframeContainer(addr, width, height) {
    h = '<div style="text-align:center;"><iframe src="'+addr+'" '
      + 'name="game" frameborder="0" width="'+width+'" height="'+height+'">'
      + '<'+'/iframe><br/'+'><'+'/div>';
    return h;
}

Event.observe(window, 'load', function() {
    createLayers();
});
