/*
function insertVideo(win, id, movie, width, height) {
    win.document.getElementById(id).innerHTML = '' +
        '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
        'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"' +
        'width="' + width + '" height="' + height + '" id="movie">' +
        '<param name="flashvars" value="movie=' + movie + '&domain=video.gfx.no&provider=/videoplayer_streamprovider.php">' +
        '<param name="movie" value="http://video.gfx.no/videoplayer_stream.swf">' +
        '<param name="quality" value="high">' +
        '<param name="bgcolor" value="#ffffff">' +
        '<embed src="http://video.gfx.no/videoplayer_stream.swf" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '"' +
        'flashvars="movie=' + movie + '&domain=video.gfx.no&provider=/videoplayer_streamprovider.php"' +
        'name="videoplayer" type="application/x-shockwave-flash"' +
        'pluginspage="http://www.macromedia.com/go/getflashplayer">' +
        '</embed>' +
        '</object>';
}
*/

function showVideo(ev) {
    elem = ev.target;

    for (var i=0; i<oldEmbedData.length; i++) {
        d = oldEmbedData[i];
        if (d.id == elem.getAttribute("id")) {
            elem.innerHTML = d.data;
            break;
        }
    }
}

oldVideoData = [];

function insertVideo(win, id, movie, width, height) {
    var h2 = height + 28;
    win.document.getElementById(id).innerHTML = '' +
        '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
        'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"' +
        'width="' + width + '" height="' + h2 + '" id="movie_' + id + '">' +
        '<param name="flashvars" value="movie=' + movie + '&domain=video.gfx.no&provider=/videoplayer_streamprovider.php&type=internal&width='+width+'&height='+h2+'">' +
        '<param name="movie" value="http://video.gfx.no/videoplayer.swf">' +
        '<param name="quality" value="high">' +
        '<param name="bgcolor" value="#ffffff">' +
        '<embed src="http://video.gfx.no/videoplayer.swf" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + h2 + '"' +
        'flashvars="movie=' + movie + '&domain=video.gfx.no&provider=/videoplayer_streamprovider.php&type=internal&width='+width+'&height='+h2+'"' +
        'name="videoplayer" type="application/x-shockwave-flash" align="middle" allowScriptAccess="sameDomain"' +
        'pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
        '</object>';
}

function popupVideo(movie, width, height) {
    var win = window.open('', '_blank', 'width=' + width + ',height=' + height);
    win.document.title = "Videoavspiller";
    win.document.write('<html><body><div id="videoPlayerPopup">Denne funksjonen krever javascript</div></body></html>');
    win.document.body.style.backgroundColor = "#000";
    win.document.body.style.margin = 0;
    insertVideo(win, 'videoPlayerPopup', movie, width, height-28);
}

/*
 * win - window to put video in
 * movie - url to movie
 * aspect - (width/height) of the original video
 */
function fullscreenVideo(movie, aspect) {
    var dw = document.body.clientWidth;
    var dh = Math.round(dw / aspect);

    win = window.open('', '_blank', 'fullscreen = yes');
    win.document.title = "Fullskjermvisning av video";
    win.document.write('<html><body><a href="#" style="color: white;" onClick="window.close();">Lukk</a><div id="fullscreen">Denne funksjonen krever javascript</div></body></html>');
    win.document.body.style.backgroundColor = "#000";
    insertVideo(win, 'fullscreen', movie, dw, dh);
}
