
var liveservice    = 'http://beheer.surfnet-tv.nl/daemon/rediraptor.php'
                   + '?account=SARA'
                   + '&ref=WhizzGrandDad'
                   + '&type=live'
                   + '&service=wowza'
                   + '&protocol=rtmp'
                   + '&output=smil'
                   + '&port='
                   ;
var liveflashvars  = { linkfromdisplay: 'true'
                     , autostart      : 'true'
                     , repeat         : 'false'
                     , type           : 'vdox'
                     , provider       : 'vdox'
                     } ;

var liveparams     = { menu             : 'true'
                     , allowscriptaccess: 'always'
                     , allowfullscreen  : 'true'
                     } ;

var liveattributes = { id  : 'FlashPlayer'
                     , name: 'FlashPlayer'
                     } ;

function livebandselector(streamnr)
{
    var html = '';

    var options = [ { streamnr: 1, text: 'goed'   , enabled: 1 }
                  , { streamnr: 2, text: 'normaal', enabled: 0 }
                  , { streamnr: 3, text: 'matig'  , enabled: 0 }
                  ] ;
    var sep = '';
    for (var n = 0; n < options.length; n++) {
        var option = options[n];
        var action = (option.streamnr == streamnr)
                   ? 'Javascript:return;'
                   : 'Javascript:liveBandBreedte(' + option.streamnr + ');'
                   ;

        var style = 'width:75px;';
        if (option.streamnr == streamnr) {
            style += 'font-weight:bold;';
        }
        if (option.enabled === 0) {
            style += 'color:#AAA;';
            action = 'Javascript:return;';
        }
        html += sep + "<button style='" + style + "' onClick=" + action + ">" + option.text + "</button>";
        sep = "&nbsp;";
    }

    html += "<p style='margin-top:8px;font-size:0.8em;'>\n";
    html += "(selecteer de kwaliteit van uw netwerkverbinding om de uitzending te starten)\n";
    html += "</p>\n";

    return html;
}

function liveBandBreedte(streamnummer)
{
    document.getElementById("live-body").innerHTML = '<div id="FlashPlayer"></div>'
                                                   + '<p>'
                                                   + '<div id="selectiediv"></div>'
                                                   ;
  
    switch (streamnummer) {
        case 1:
        liveflashvars.width         = "540";
        liveflashvars.height        = "420";
        liveflashvars.displaywidth  = "540";
        liveflashvars.displayheight = "400";
        liveflashvars.file          = escape(liveservice + "&file=IMO11CLOSING1");
        break;

        case 2:
        liveflashvars.width         = "360";
        liveflashvars.height        = "328";
        liveflashvars.displaywidth  = "360";
        liveflashvars.displayheight = "288";
        liveflashvars.file          = escape(liveservice + "&file=IMO11CLOSING2");
        break;

        case 3:
        liveflashvars.width         = "180";
        liveflashvars.height        = "164";
        liveflashvars.displaywidth  = "180";
        liveflashvars.displayheight = "144";
        liveflashvars.file          = escape(liveservice + "&file=IMO11CLOSING2");
        break;
    }

    swfobject.embedSWF( "http://www.surfmedia.nl/embed/mediaplayer.swf"
                      , "FlashPlayer"
                      , liveflashvars.width
                      , liveflashvars.height
                      , "8"
                      , "expressInstall.swf"
                      , liveflashvars
                      , liveparams
                      , liveattributes
                      ) ;
    document.getElementById("selectiediv").innerHTML = livebandselector(streamnummer);
}


function emitLiveWidget()
{
    var html = '';

    html += "<center>\n";
    html += "<div id='live-header'></div>\n";
    html += "<div id='live-body'  ></div>\n";
    html += "<div id='live-footer'></div>\n";
    html += "</center>\n";

    Element.update('content', html);

    setTimeout( "contentLoadExec( { target  : 'live-header'"
              + "                 , filename: 'media/live-header.phtml'"
              + "                 } )"
              , 250
              ) ;
    setTimeout( "contentLoadExec( { target  : 'live-footer'"
              + "                 , filename: 'media/live-footer.phtml'"
              + "                 } )"
              , 250
              ) ;
    setTimeout( "liveBandBreedte(1)", 500 );
}



