﻿var nosilverlight = false;

function createSilverlight(xamlFileName, hostDivName, controlID, baseClass, props) {
	var version = "0.95";
	var isInstalled = Silverlight.isInstalled(version);
	if (isInstalled || props.enableInstall) {
		Silverlight.createObjectEx({
			source: xamlFileName,
			parentElement: document.getElementById(hostDivName),
			id: controlID,
			properties: {
				width: props.width == undefined ? "100" : props.width,
				height: props.height == undefined ? "100" : props.height,
				background: props.background == undefined ? "#00ffffff" : props.background,
				isWindowless: props.isWindowless == undefined ? "false" : props.isWindowless,
				enableHtmlAccess: props.enableHtmlAccess == undefined ? true : props.enableHtmlAccess,
				version: props.version == undefined ? version : props.version
			},
			events: {
				onError: function(sender, args) { },
				onLoad: Silverlight.createDelegate(baseClass, baseClass.initialize)
			},		
			context: null 
		});	 
	}
	else {
		nosilverlight = true;
    }
}

if (!window.Silverlight) window.Silverlight = {};

Silverlight.createDelegate = function(instance, method) {
	return function() {
        return method.apply(instance, arguments);
    }
}