function onError(message) {
    $('#indicator').hide();
    alert("Error: " + message);
}

function onEmpty() {
    $('#indicator').hide();
    alert("Nie znaleziono strumieni!");
}

function onStream(name, type, width, height, url) {
    var title = name + ' / ';

    if (width > 0 && height > 0)
        title = title + width + 'x' + height + ' ';

    title = title + '(' + type + ')';

    $('#indicator').hide();
    $('#streams').show();
    $('#streams ul').append('<li>' + title + ' <a href="' + url + '">Pobierz!</a> ' + '<a href="javascript:preview(\'' + url + '\', \'' + type + '\');">Podgląd!</a>' + '</li>');
}

function preview(url, mime) {
    var height = '600';
    var provider = 'video';

    if (mime.indexOf('audio') >= 0) {
        height = '24';
        provider = 'sound';
    }

    var so = new SWFObject('resources/player.swf', 'player', '100%', height, '9');
    so.addParam('allowfullscreen', 'true');
    so.addParam('allowscriptaccess', 'always');
    so.addParam('wmode', 'opaque');
    so.addVariable('file', encodeURIComponent(url));
    so.addVariable('provider', provider);
    so.addVariable('autostart', 'true');
    so.addVariable('stretching', 'fill');
    so.addVariable('repeat', 'always');
    so.write("player-container");
}
