﻿
// 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 = 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"
        }
    );
}
