function createSilverlight(sAppPath)
{
	var scene = new DemoBrowser.Page();
	Silverlight.createObjectEx(
	    {
		    source: sAppPath + "/DemoBrowser.xaml",
		    parentElement: document.getElementById("SilverlightControlHost"),
		    id: "SilverlightControl",
		    properties: {
			    width: "100%",
			    height: "100%",
			    version: "1.0"
		    },
		    events: {
			    onLoad: Silverlight.createDelegate(scene, scene.handleLoad),
				onError: handleError
		    },
            initParams: [
                "{ sAppPath: '", sAppPath, "'}"
            ].join("")
	    }
	);
	
	// Return the instance to the page
	return scene;
}


if (!window.Silverlight) 
	window.Silverlight = {};

Silverlight.createDelegate = function(instance, method) {
	return function() {
		return method.apply(instance, arguments);
	}
}

function handleError(sender, errorArgs)
{
    if (errorArgs.errorCode == 4001) {
        return;
    }
	
    Silverlight.default_error_handler(sender, errorArgs);
} 