﻿var SeasonCards = null;
var xmlDoc = null;

function createSeasonCard()
{   
	SeasonCards = new SeasonCardsBuilder.App();
	
	Silverlight.createObjectEx({
		source: "UI.xaml",
		parentElement: document.getElementById("div_Content"),
		id: "SilverlightControl",
		properties: {
			width: "800px",
			height: "600px",
			version: "1.0",
			isWindowless:'true',
			background:'transparent'
		},
		events: {
			onLoad: Silverlight.createDelegate(SeasonCards, SeasonCards.handleLoad),
			onError: function(sender, args) {
				var errorDiv = document.getElementById("Display");
				if (errorDiv != null) {
					var errorText = args.errorType + "- " + args.errorMessage;
							
					if (args.ErrorType == "ParserError") {
						errorText += "<br>File: " + args.xamlFile;
						errorText += ", line " + args.lineNumber;
						errorText += " character " + args.charPosition;
					}
					else if (args.ErrorType == "RuntimeError") {
						errorText += "<br>line " + args.lineNumber;
						errorText += " character " +  args.charPosition;
					}
					alert(errorText);//errorDiv.innerHTML = errorText;
				}	
			}
		}
	});
}


if (!window.Silverlight) 
	window.Silverlight = {};

Silverlight.createDelegate = function(instance, method) {
	return function() {
		return method.apply(instance, arguments);
	}
}