﻿
// Utility per la creazione dell'oggetto di silverlight
function createSL(source, id, div, width, height, background, version, param) 
{
    var getSilverlightMethodCall = "javascript:Silverlight.getSilverlight(\"" + version + "\");"
    var installImageUrl = "http://go.microsoft.com/fwlink/?LinkId=108181";
    var imageAltText = "Installa Microsoft Silverlight";
    //
    var altHtml = "<a href='{1}' style='text-decoration: none;'>";
    altHtml += "<img src='{2}' alt='{3}' ";
    altHtml += "style='border-style: none'/></a>";
    altHtml += "<br /><br />";
    altHtml += "<p style='font-family: Arial,Verdana,Helvetica,sans-serif; font-size:10px;'>";
    altHtml += "Per visualizzare correttamente l'applicazione<br />";
    altHtml += "&egrave; necessario aggiornare il browser con l'ultima<br />";
    altHtml += "versione di <b>Microsoft Silverlight</b> plug-in.<br />";
    altHtml += "<i>Potrebbe essere necessario riavviare il browser</i>.</p>";
    altHtml = altHtml.replace('{1}', getSilverlightMethodCall);
    altHtml = altHtml.replace('{2}', installImageUrl);
    altHtml = altHtml.replace('{3}', imageAltText);
    //
    _createSL(source, id, div, width, height, background, altHtml, version, param);
}

function _createSL(source, id, div, width, height, background, alt, version, param)
{ 
    Silverlight.createObjectEx
    (
        {
            source: source,
            parentElement: document.getElementById(div),
            id: id,
            properties:
            {
                width: width,
                height: height,
                background: background,
                alt: alt,
                version: version
            },
            events:
            {
                // onError: onSLError,
                // onLoad: onSLLoad
            },
            initParams: param
            // ,context: "row4"
        }
    );
}
