﻿

function AVSLiveBasicLoad() {
    //var arg = "width=" + width + ",height=" + height + ",isRegistred=" + isRegistred + ",videoID=" + videoID + ",userID=" + userID + ",numberLeft=" + numberLeft + ",conGuid=" + conGuid + ",m=" + m;
    var arg = "width=" + width + ",height=" + height + ",isRegistred=" + isRegistred + ",videoID=" + videoClef + ",userID=" + userID + ",conGuid=" + conGuid + ",m=" + m + ",cs=" + cs;
    var strg = '<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="' + width + 'px" height="' + height + 'px" id="silverlightControl" >';
    strg += '<param name="source" value="' + urToAVSLBasicFolder + 'CineLyceePlayer.xap"/>';
    strg += '<param name="minRuntimeVersion" value="4.0.50401.0" />';
    strg += '<param name="onerror" value="onSilverlightError" />';
    strg += '<param name="background" value="black" />';
    strg += '<param name="windowless" value="true" />';
    strg += '<param name="MaxFrameRate" value="30" />';
    strg += ' <param name="autoUpgrade" value="true" />';
    strg += '<param name="initparams" value="' + arg + '" />';
    strg += '<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">';
    strg += '<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>';
    strg += '</a>';
    strg += '</object>';

    document.getElementById('silverlightControlHost').innerHTML = strg;
}


function GetInstallStatus() {
    var control = document.getElementById("silverlightControl");
    return control.Content.CineLyceeSL.CheckInstallFromPage();
}

function InstallCLP() {
    var control = document.getElementById("silverlightControl");
    control.Content.CineLyceeSL.InstallClpFromPage();
}

function GetMovieForDownload() {
    var control = document.getElementById("silverlightControl");
    control.Content.CineLyceeSL.DownloadMovieFromPage();
}

function onSilverlightError(sender, args) {
    var appSource = "";
    if (sender != null && sender != 0) {
        appSource = sender.getHost().Source;
    }

    var errorType = args.ErrorType;
    var iErrorCode = args.ErrorCode;

    if (errorType == "ImageError" || errorType == "MediaError") {
        return;
    }

    var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";

    errMsg += "Code: " + iErrorCode + "    \n";
    errMsg += "Category: " + errorType + "       \n";
    errMsg += "Message: " + args.ErrorMessage + "     \n";

    if (errorType == "ParserError") {
        errMsg += "File: " + args.xamlFile + "     \n";
        errMsg += "Line: " + args.lineNumber + "     \n";
        errMsg += "Position: " + args.charPosition + "     \n";
    }
    else if (errorType == "RuntimeError") {
        if (args.lineNumber != 0) {
            errMsg += "Line: " + args.lineNumber + "     \n";
            errMsg += "Position: " + args.charPosition + "     \n";
        }
        errMsg += "MethodName: " + args.methodName + "     \n";
    }

    throw new Error(errMsg);
}

