function createSilverlight()
{
	var scene = new CelticConifers.Page();

	Silverlight.createObjectEx({
		source: "index.xaml",
		parentElement: document.getElementById("silverlightControlHost"),
		id: "SilverlightControl",
		properties: {
			width: "100%",
			height: "100%",
	        background:'transparent',
    	    isWindowless: 'true',
			version: "1.0"
		},
		events: {
			onLoad: Silverlight.createDelegate(scene, scene.handleLoad),
			onError: function(sender, args) {
				var errorDiv = document.getElementById("errorLocation");
				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;
					}
					errorDiv.innerHTML = errorText;
				}	
			}
		}
	});
}


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

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

function ajaxChangeText(page_name, div_id){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if((el1 = document.getElementById(div_id)) == null) return;
		if(ajaxRequest.readyState == 4){
			el1.innerHTML = ajaxRequest.responseText;
		}
		else {
			el1.innerHTML = "Loading";
		}			
	}
	ajaxRequest.open("GET", page_name, true);
	ajaxRequest.send(null); 
}

function ajaxChangeTextByArray(myArray)
{
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			el1 = document.getElementById(myArray[0][1]);
			el1.innerHTML = ajaxRequest.responseText;
			if(myArray.length > 1)
			{
				myArray.shift();
				ajaxChangeTextByArray(myArray);
			}
		}
	}
	ajaxRequest.open("GET", myArray[0][0], true);
	ajaxRequest.send(null); 
}

function gen_email(ename, junk, edomain)
{
	var address = 'mailto:' + ename + '@' + edomain;
	location.href = address;
}