if (!window.Silverlight)
{
window.Silverlight = { };
}
// Silverlight control instance counter for memory mgt
Silverlight._silverlightCount = 0;
Silverlight.fwlinkRoot='http://go2.microsoft.com/fwlink/?LinkID=';
Silverlight.onGetSilverlight = null;
Silverlight.onSilverlightInstalled = function () {window.location.reload(false);};
//////////////////////////////////////////////////////////////////
// isInstalled, checks to see if the correct version is installed
//////////////////////////////////////////////////////////////////
Silverlight.isInstalled = function(version)
{
var isVersionSupported=false;
var container = null;
try
{
var control = null;
try
{
control = new ActiveXObject('AgControl.AgControl');
if ( version == null )
{
isVersionSupported = true;
}
else if ( control.IsVersionSupported(version) )
{
isVersionSupported = true;
}
control = null;
}
catch (e)
{
var plugin = navigator.plugins["Silverlight Plug-In"] ;
if ( plugin )
{
if ( version === null )
{
isVersionSupported = true;
}
else
{
var actualVer = plugin.description;
if ( actualVer === "1.0.30226.2")
actualVer = "2.0.30226.2";
var actualVerArray =actualVer.split(".");
while ( actualVerArray.length > 3)
{
actualVerArray.pop();
}
while ( actualVerArray.length < 4)
{
actualVerArray.push(0);
}
var reqVerArray = version.split(".");
while ( reqVerArray.length > 4)
{
reqVerArray.pop();
}
var requiredVersionPart ;
var actualVersionPart
var index = 0;
do
{
requiredVersionPart = parseInt(reqVerArray[index]);
actualVersionPart = parseInt(actualVerArray[index]);
index++;
}
while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);
if ( requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart) )
{
isVersionSupported = true;
}
}
}
}
}
catch (e)
{
isVersionSupported = false;
}
if (container)
{
document.body.removeChild(container);
}
return isVersionSupported;
}
Silverlight.WaitForInstallCompletion = function()
{
if ( ! Silverlight.isBrowserRestartRequired && Silverlight.onSilverlightInstalled )
{
try
{
navigator.plugins.refresh();
}
catch(e)
{
}
if ( Silverlight.isInstalled(null) )
{
Silverlight.onSilverlightInstalled();
}
else
{
setTimeout(Silverlight.WaitForInstallCompletion, 3000);
}
}
}
Silverlight.__startup = function()
{
Silverlight.isBrowserRestartRequired = Silverlight.isInstalled(null);//(!window.ActiveXObject || Silverlight.isInstalled(null));
if ( !Silverlight.isBrowserRestartRequired)
{
Silverlight.WaitForInstallCompletion();
}
if (window.removeEventListener) {
window.removeEventListener('load', Silverlight.__startup , false);
}
else {
window.detachEvent('onload', Silverlight.__startup );
}
}
if (window.addEventListener)
{
window.addEventListener('load', Silverlight.__startup , false);
}
else
{
window.attachEvent('onload', Silverlight.__startup );
}
///////////////////////////////////////////////////////////////////////////////
// createObject(); Params:
// parentElement of type Element, the parent element of the Silverlight Control
// source of type String
// id of type string
// properties of type String, object literal notation { name:value, name:value, name:value},
// current properties are: width, height, background, framerate, isWindowless, enableHtmlAccess, inplaceInstallPrompt: all are of type string
// events of type String, object literal notation { name:value, name:value, name:value},
// current events are onLoad onError, both are type string
// initParams of type Object or object literal notation { name:value, name:value, name:value}
// userContext of type Object
/////////////////////////////////////////////////////////////////////////////////
Silverlight.createObject = function(source, parentElement, id, properties, events, initParams, userContext)
{
var slPluginHelper = new Object();
var slProperties = properties;
var slEvents = events;
slPluginHelper.version = slProperties.version;
slProperties.source = source;
slPluginHelper.alt = slProperties.alt;
//rename properties to their tag property names
if ( initParams )
slProperties.initParams = initParams;
if ( slProperties.isWindowless && !slProperties.windowless)
slProperties.windowless = slProperties.isWindowless;
if ( slProperties.framerate && !slProperties.maxFramerate)
slProperties.maxFramerate = slProperties.framerate;
if ( id && !slProperties.id)
slProperties.id = id;
// remove elements which are not to be added to the instantiation tag
delete slProperties.ignoreBrowserVer;
delete slProperties.inplaceInstallPrompt;
delete slProperties.version;
delete slProperties.isWindowless;
delete slProperties.framerate;
delete slProperties.data;
delete slProperties.src;
delete slProperties.alt;
// detect that the correct version of Silverlight is installed, else display install
if (Silverlight.isInstalled(slPluginHelper.version))
{
//move unknown events to the slProperties array
for (var name in slEvents)
{
if ( slEvents[name])
{
if ( name == "onLoad" && typeof slEvents[name] == "function" && slEvents[name].length != 1 )
{
var onLoadHandler = slEvents[name];
slEvents[name]=function (sender){ return onLoadHandler(document.getElementById(id), userContext, sender)};
}
var handlerName = Silverlight.__getHandlerName(slEvents[name]);
if ( handlerName != null )
{
slProperties[name] = handlerName;
slEvents[name] = null;
}
else
{
throw "typeof events."+name+" must be 'function' or 'string'";
}
}
}
slPluginHTML = Silverlight.buildHTML(slProperties);
}
//The control could not be instantiated. Show the installation prompt
else
{
slPluginHTML = Silverlight.buildPromptHTML(slPluginHelper);
}
// insert or return the HTML
if(parentElement)
{
parentElement.innerHTML = slPluginHTML;
}
else
{
return slPluginHTML;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// create HTML that instantiates the control
//
////////