﻿function OpenVideoPlayer(file, provider, statTag) {
    var statOTag;
    statOTag = (statTag) ? statTag : '';   // statTag contains the string to be added to o-parameter
    OpenDiTVPlayer(file, provider, statOTag);
}

function OpenVideoPlayer(url) {
    var w;
    w = window.open(url, 'DiTV', 'menubar=no,status=no,toolbar=no,resizable=no,width=980,height=660,titlebar=no,scrollbars=no,alwaysRaised=yes,alwaysontop=1');
    if (w != undefined)
        w.focus();
}

var videoWindow;
function OpenDiTVPlayer(file, provider, strOParam) {
    var link;
    //var oParam;
    var w;

    if (provider == 1) { //ToDo should uncomment after adding scenarios with other providers. 
        link = 'mms://wm1.c00564.cdn.qbrick.com/00564/ditv' + file;
    } else if (provider == 4) {
        link = "mms://wm0.c00564.cdn.qbrick.com/00563/Nyheter" + file
    } else if (provider == 5) {
        link = "mms://wm0.c00564.cdn.qbrick.com/00563/OnDemand" + file
    } else {
        link = file;
    }

    if (provider == 6) {
        w = window.open('http://ditv.se/tv/video/clip' + file.substring(0, file.length - 4), 'DiTV', 'width=910,height=700, left=200, top=200, toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=auto,resizable=1,copyhistory=no');

        // ToDo The oParam value is not used by TillDiTVSite control. Should research this functionality.
        //oParam = (strOParam != '') ? 'o=' + strOParam + '&' : 'o=ditv&';  // Do be able to provide different o-params depending on which page opening DiTV-clip
        // ToDo Sould implement cahing data like in TillDiTVSite control.
        //w = window.open('/Avdelningar/TillDiTVSite.aspx?' + oParam + 'MediaLink=' + file + '&Provider=' + provider, 'DiTV', 'width=910,height=700, left=200, top=200, toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=auto,resizable=1,copyhistory=no');
    } else if (provider == -1) {
        // To open DiTV with URL instead of filename
        w = window.open(file, 'DiTV', 'width=910,height=700, left=200, top=200, toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=auto,resizable=1,copyhistory=no');
    } else {
        w = window.open(link, 'DiTV', 'menubar=no,status=no,toolbar=no,resizable=no,width=0,height=0,titlebar=no,scrollbars=no,alwaysRaised=yes,alwaysontop=1');
        videoWindow = w; // Test code for video-audio. Should change it to real implementation.
        setTimeout("videoWindow.close();", 5000);
        return;
        // ToDo should implement functionality for dublication the MediaSpelare control
        //w = window.open('/Funktioner/MediaSpelare.aspx?MediaType=video&MediaLink=' + escape(link) + '&provider=' + provider + '&MediaTitle=&nbsp;', 'DiTV', 'width=844,height=661, left=20, top=20, toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=No,resizable=No,copyhistory=no');
    }

    // ToDo Should this functionality be deleted? It is under comment in old code version.
    /*aWin = window.open(link,'DiTV', 'menubar=no,status=no,toolbar=no,resizable=no,width=20,height=20,titlebar=no,scrollbars=no,alwaysRaised=yes,alwaysontop=1');
    setTimeout("aWin.close()",5000);*/
    if (w != undefined)
        w.focus();

}

