﻿function start() {    
    window.onbeforeunload = SLS.onPlayerPageBeforeUnload;
    SLS.logEntryFlow();
    SLS.showSilverlightApplication();
}

function showSilverlightApp() {
    //Do actions when silverlight installed
     
}

function showInstallX() {
    //Do actions when silverlight not installed
    $("a.zoom").fancybox({
        'hideOnContentClick': false,
        'overlayOpacity': 0.7,
        'overlayColor': '#000',
        'frameWidth': 600,
        'frameHeight': 361,
        'callbackOnClose': closed
    }).trigger('click');
}

function OpenNewWindow(url) {
    window.location = url;
}

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);
}

function closed() {
    //Hiding the Silverlight Contents
    var divSLHostHomeGallery = document.getElementById('divSLHostHomeGallery');
    if (divSLHostHomeGallery != null) {
        divSLHostHomeGallery.style.display = 'none';
    }

    var divSLHomeMiniGallery = document.getElementById('divSLHomeMiniGallery');
    if (divSLHomeMiniGallery != null) {
        divSLHomeMiniGallery.style.display = 'none';
    } 

    //Showing the Flash Contents
    var divFlashHostHomeGallery = document.getElementById('divFlashHostHomeGallery');
    if (divFlashHostHomeGallery != null) {
        divFlashHostHomeGallery.style.display = 'block';
    }

    var divFlashHomeMiniGallery = document.getElementById('divFlashHomeMiniGallery');
    if (divFlashHomeMiniGallery != null) {
        divFlashHomeMiniGallery.style.display = 'block';
    } 
}
