function toggleExpandCollapse(n) {
    var elm = document.getElementById('expandee' + n);
    if (elm) {
        if (elm.style.display == 'block') {
            collapse(n);
        }
        else {
            expand(n);
        }
    }
}

function expand(n) {
    showElm("expandee" + n);
    hideElm("expander" + n);


}

function collapse(n) {
    showElm("expander" + n);
    hideElm("expandee" + n);


}

function showElm(name) {
  var elm = document.getElementById(name);
  if (elm) { elm.style.display = "block"; }
}

function hideElm(name) {
  var elm = document.getElementById(name);
  if (elm) { elm.style.display = "none"; }
}


function showVideo(n, videoId, seconds)
{
    expand(n);
    var elm = document.getElementById("expandee" + n);
    var startParam = seconds != 0 ? '&amp;start=' + Math.floor(seconds) : '';
    var startParamUrl = '';
    if (seconds != 0) {
        if (seconds > 60) {
            startParamUrl = '#t=' + Math.floor(seconds / 60) + 'm' + Math.floor(seconds % 60) + 's';
        }
        else {
            startParamUrl = '#t=' + Math.floor(seconds) + 's';
        }
    }

    if (elm) {
        elm.innerHTML = "<p align=\"right\"><a href=\"javascript:hideVideo(" + n + ")\">Zamknij</a>&nbsp;&nbsp;&nbsp;&nbsp;</p>" +
                "<center><object style=\"width: 425px; height: 344px\"><param name=\"movie\" " +
                "value=\"http://www.youtube.com/v/" + videoId + "&amp;autoplay=1" + startParam + "\"></param>" +
                "<embed src=\"http://www.youtube.com/v/" + videoId + "&amp;autoplay=1" + startParam + "\" type=\"application/x-shockwave-flash\" " +
                "style=\"width: 425px; height: 344px\"></object></center>";
    }
}

function showVideo2(n, videoId, seconds)
{
    expand(n);
    var elm = document.getElementById("expandee" + n);
    var startParam = seconds != 0 ? '&amp;start=' + Math.floor(seconds) : '';
    var startParamUrl = '';
    if (seconds != 0) {
        if (seconds > 60) {
            startParamUrl = '#t=' + Math.floor(seconds / 60) + 'm' + Math.floor(seconds % 60) + 's';
        }
        else {
            startParamUrl = '#t=' + Math.floor(seconds) + 's';
        }
    }

    if (elm) {
		elm.innerHTML = "<p align=\"right\"><a href=\"javascript:hideVideo(" + n + ")\">Zamknij</a>&nbsp;&nbsp;&nbsp;&nbsp;</p>" +
				"<center><object id=\"flashObj\" width=\"620\" height=\"399\"/>" +
                "<param name=\"bgcolor\" value=\"#FFFFFF\" />" +
                "<param name=\"flashVars\" value=\"videoId=814269736001&linkBaseURL=http%3A%2F%2Fwww.stern.de%2Fkultur%2Fmusik%2Fvideopremiere-oh-what-a-night-guano-apes-feiern-comeback-1660297.html&playerID=51295388001&playerKey=AQ~~,AAAAAEe1U_0~,_DtVTkYTiH6nTc_Qt9vYAHeDhsRNW5-r&domain=embed&dynamicStreaming=true\" />" +
                "<param name=\"base\" value=\"http://admin.brightcove.com\" /><param name=\"seamlesstabbing\" value=\"false\" />" +
                "<param name=\"allowFullScreen\" value=\"true\" />" +
                "<embed src=\"http://c.brightcove.com/services/viewer/federated_f9?isVid=1&isUI=1\" bgcolor=\"#FFFFFF\" flashVars=\"videoId=814269736001&linkBaseURL=http%3A%2F%2Fwww.stern.de%2Fkultur%2Fmusik%2Fvideopremiere-oh-what-a-night-guano-apes-feiern-comeback-1660297.html&playerID=51295388001&playerKey=AQ~~,AAAAAEe1U_0~,_DtVTkYTiH6nTc_Qt9vYAHeDhsRNW5-r&domain=embed&dynamicStreaming=true\" base=\"http://admin.brightcove.com\" name=\"flashObj\" width=\"620\" height=\"399\" seamlesstabbing=\"false\" type=\"application/x-shockwave-flash\" allowFullScreen=\"true\"></embed>" +
                "</object></center>";
    }
}

function hideVideo(n)
{
    var elm = document.getElementById("expandee" + n);
    if (elm) {
        elm.innerHTML = "&nbsp;";
    }
    collapse(n);
}
