﻿
function createSilverlight()
{
	Silverlight.createObjectEx
	(
		{
			source: 'Page.xaml',
			parentElement:silverlighthost,
			id:'slgen_id_1',
			properties:
			{
				width:'500',
				height:'480',
				inplaceInstallPrompt:true,
				background:'#FFFFFF',
				isWindowless:'false',
				framerate:'30',
				version:'1.0'
			},
			events:
			{
				onError:null,
				onLoad:null
			}
		}
	);
}

if (!window.Silverlight)
{
	window.Silverlight = {};
}

Silverlight.createDelegate = function(instance, method) 
{
	return function() 
	{
		return method.apply(instance, arguments);
	}
}

Silverlight.InstallAndCreateSilverlight = function(version, installPromptDiv, createSilverlightDelegate)
{
	var RetryTimeout=3000;	              //The interval at which Silverlight instantiation is attempted(ms)
	if ( Silverlight.isInstalled(version) )
	{
		document.getElementById('collapsethis').innerHTML = "";
		createSilverlightDelegate();
	}
	else
	{
		if ( installPromptDiv )
		{
			installPromptDiv.innerHTML = Silverlight.createObject(null, null, null, {version: version, inplaceInstallPrompt:true},{}, null);
		}
		TimeoutDelegate = function()
		{
			Silverlight.InstallAndCreateSilverlight(version, null, createSilverlightDelegate);
		}
		setTimeout (TimeoutDelegate, RetryTimeout);
	}
}