function createFilmstripSilverlight(parentName, idName, imageSource, url, isPremium, rating ) {
	var scene = new FilmstripProject.Page();
	scene.set_imageSource(imageSource);
	scene.set_url(url);
	scene.set_isPremium(isPremium);
	scene.set_rating(rating);
	
	Silverlight.createObjectEx({
		source: "/belux/chopsticks/xaml/FilmstripControl.xaml",
		parentElement: document.getElementById(parentName),
		id: idName,
		properties: {
			width: "100%",
			height: "100%",
			version: "1.0",
			isWindowless: "true",
			background: "#00000000"
		},
		events: {
			onLoad: Silverlight.createDelegate(scene, scene.handleLoad)
			,onError: Silverlight.createDelegate(scene, scene.handleError)
		}
	});
	
}

if (!window.Silverlight) 
	window.Silverlight = {};

    Silverlight.createDelegate = function(instance, method) {
	return function() {
		return method.apply(instance, arguments);
	}
}

if (!window.FilmstripProject)
	window.FilmstripProject = {};

FilmstripProject.Page = function() {
    this._imageSource = null;
    this._url = null;
    this._isPremium = null;
    this._hasPremiumResources= null;
    this._rating = 0;
}

FilmstripProject.Page.prototype = {
    get_imageSource: function() { return this._imageSource;},
    set_imageSource: function(value) { this._imageSource = value; },    

    get_url: function() { return this._url;},
    set_url: function(value) { this._url = value; },    
    
    get_isPremium: function() { return this._isPremium; },
    set_isPremium: function(value) { this._isPremium = value; },
    
    get_hasPremiumResources: function() { return this._hasPremiumResources; },
    set_hasPremiumResources: function() { this._hasPremiumResources = value; },
    
    get_rating: function() { return this._rating; }, 
    set_rating: function(value) { this._rating = value; },

	handleLoad: function(control, userContext, rootElement) 
	{
		this.control = control;
		
		// Sample event hookup:	
		rootElement.findName("Image").source = this._imageSource;
		rootElement.findName("ImageFrame").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.imageFrameOnMouseEnter));
		rootElement.findName("ImageFrame").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.imageFrameOnMouseLeave));
		rootElement.findName("ImageFrame").addEventListener("MouseLeftButtonUp", Silverlight.createDelegate(this, this.imageFrameOnMouseLeftButtonUp));
		
		if (this._isPremium) {
		    rootElement.findName("Path").Visibility = "Visible";
		    rootElement.findName("Group").Visibility = "Visible";
		    
		} else {
		    rootElement.findName("Path").Visibility = "Collapsed";
		    rootElement.findName("Group").Visibility = "Collapsed";
		}
				
        this.assignStar(rootElement, "emptystar1", "halfstar1", "fullstar1", this._rating, 0);
        this.assignStar(rootElement, "emptystar2", "halfstar2", "fullstar2", this._rating, 1);
        this.assignStar(rootElement, "emptystar3", "halfstar3", "fullstar3", this._rating, 2);
        this.assignStar(rootElement, "emptystar4", "halfstar4", "fullstar4", this._rating, 3);
        this.assignStar(rootElement, "emptystar5", "halfstar5", "fullstar5", this._rating, 4);	    
		
	},
		
	handleError: function(sender, eventArgs)
	{
	    //do nothing...
	},
	
	assignStar: function(rootElement, imgEmpty, imgHalf, imgFull, val, offset) {
	    //alert(val);
	    //alert(rootElement.findName(imgFull));
	    
        if (val - offset >= 0.5) {
            if (val - offset >= 1.0) {
            
                rootElement.findName(imgFull).Visibility = "Visible";
            } else {
                rootElement.findName(imgHalf).Visibility = "Visible";
            }
        } else {
            if (val == 0) {
                rootElement.findName(imgEmpty).Visibility = "Collapsed";
            } else {
                rootElement.findName(imgEmpty).Visibility = "Visible";
            }            
        }
	},
		
	// Sample event handler
	handleMouseDown: function(sender, eventArgs) 
	{
	},

	imageFrameOnMouseEnter: function(sender, eventArgs) {
    		this.control.content.findName("ImageFrame_MouseEnter_Timeline").Begin();
	},

	imageFrameOnMouseLeave: function(sender, eventArgs) {
    		this.control.content.findName("ImageFrame_MouseLeave_Timeline").Begin();
	},
	
	imageFrameOnMouseLeftButtonUp: function(sender, eventArgs) {
    		window.location.href = this._url;
	}

}

