if (!window.RssNotebook)
	window.RssNotebook = {};

RssNotebook.Page = function() 
{
}

RssNotebook.Page.prototype =
{
	handleLoad: function(control, userContext, rootElement) 
	{
		this.control = control;
		this.root = control.content.findName("Main");
		
		//this.header = control.content.findName("ItemHeader");
		//this.itemtext = control.content.findName("ItemContent");
		
		this.downloader = control.createObject("downloader");
		this.downloader.addEventListener("completed", Silverlight.createDelegate(this, this.handleFontDownloaded));
		this.downloader.open("GET", "RssNotebook.zip");
		this.downloader.send();
		
		//this.header.Text = rss[0].Channel.Items[1].Title;
		//this.itemtext.Text = rss[0].Channel.Items[1].Description;
	},
	
	handleFontDownloaded: function(sender, eventArgs)
	{
        var left = 0;
        
        for (var i=1; i<4; i++)
        {
            var postit = this.control.content.createFromXaml(sender.getResponseText("RssItem.xaml"), true);
            this.root.children.add(postit);
            
            new RssNotebook.RssItem(this.control, postit, rss[0].Channel.Items[i].Title, rss[0].Channel.Items[i].Description, left, 0, sender);
            left += 150;
        }
	}
}

RssNotebook.RssItem = function(control, target, header, desc, x, y, downloader)
{        
    this.header = target.findName("ItemHeader");
    this.itemtext = target.findName("ItemContent");
    
    this.header.setFontSource(downloader);
    this.itemtext.setFontSource(downloader);
    this.header.fontFamily = "Tim Heuer Normal";
    this.itemtext.fontFamily = "Tim Heuer Normal";
    
    this.header.Text = header;
    this.itemtext.Text = desc;
    
    target["Canvas.Top"] = y;
    target["Canvas.Left"] = x;
}

RssNotebook.RssItem.prototype = 
{
}
