﻿if (!window.Silverlight) 
	window.Silverlight = {};

Silverlight.createDelegate = function(instance, method) {
	return function() {
		return method.apply(instance, arguments);
	}
}

if (!window.Chopsticks)
	window.Chopsticks = {};

Chopsticks.Test = function() {
    this._dummy = null;
}

Chopsticks.Test.prototype = {

	handleLoad: function(control, userContext, rootElement) 
	{
		this.control = control;		
        rootElement.findName("Timer").addEventListener("Completed", Silverlight.createDelegate(this, this.handleTimerCompleted));
        rootElement.findName("Timer").Begin();                      
        
	},
	handleTimerCompleted: function(sender, eventArgs) {
	    document.location = "default.aspx";
	}	
}
	

function InstallSl2(parentName, idName) {
    var x = new Chopsticks.Test();
    
    var controlHost = $get(parentName);
    Silverlight.createObjectEx( {   
        source: 'InstallSl.xaml', 
        parentElement: controlHost, 
        id:idName, 
        properties:{ 
            width:'100%', 
            height:'100%', 
            version:'1.0', 
            background:'transparent', 
            isWindowless:'true' }, 
        events:{ onLoad:Silverlight.createDelegate(x, x.handleLoad) } 
    } );           

}


function createSlSilverlight(parentName, idName) {    
    return function() {
        return new InstallSl2(parentName, idName);
    }
    
}
