var lvl1_visible=true;
var lvl2_visible=true;
var lvl3_visible=true;


if (!window.NextEvents1)
	NextEvents1 = {};

NextEvents1.Page = function() 
{
}

NextEvents1.Page.prototype =
{
	handleLoad: function(control, userContext, rootElement) 
	{
		this.control = control;	
		
		if (array_locandine.length>0)
			this.control.content.findName("image1")["Source"] = array_locandine[0];
		if (array_locandine.length>1)
			this.control.content.findName("image2")["Source"] = array_locandine[1];
		if (array_locandine.length>2)
			this.control.content.findName("image3")["Source"] = array_locandine[2];
			

		if (smallTitles.length>0)
			this.control.content.findName("lbl_titolo1")["Text"] = smallTitles[0];
		if (smallTitles.length>1)
			this.control.content.findName("lbl_titolo2")["Text"] = smallTitles[1];
		if (smallTitles.length>2)
			this.control.content.findName("lbl_titolo3")["Text"] = smallTitles[2];
			
			
		if (titles.length>0)
			this.control.content.findName("lbl_titologrande1")["Text"] = titles[0];
		if (titles.length>1)
			this.control.content.findName("lbl_titologrande2")["Text"] = titles[1];
		if (titles.length>2)
			this.control.content.findName("lbl_titologrande3")["Text"] = titles[2];
			
			
		if (scheduledAsFlatText.length>0)
			this.control.content.findName("lbl_date1")["Text"] = scheduledAsFlatText[0];
		if (titles.length>1)
			this.control.content.findName("lbl_date2")["Text"] = scheduledAsFlatText[1];
		if (titles.length>2)
			this.control.content.findName("lbl_date3")["Text"] = scheduledAsFlatText[2];			
		
		this.control.content.findName("lbl_titolo1").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleLblData1_Click));
		this.control.content.findName("lbl_titolo2").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleLblData2_Click));
		
	},
	
	// Gestore evento di esempio
	handleMouseDown: function(sender, eventArgs) 
	{
		// La riga di codice seguente illustra come trovare un elemento in base al nome e chiamare un metodo su tale elemento.
		// this.control.content.findName("Storyboard1").Begin();
	},
	
	// Accartoccia il livello 1
	handleLblData1_Click: function(sender, eventArgs) 
	{
		if (lvl2_visible==true && lvl3_visible==true){
			if (lvl1_visible==true){
				this.control.content.findName("fold_L1").Begin();
				lvl1_visible = !lvl1_visible;
				
				showFilmTable(1);
			}else{
				this.control.content.findName("unfold_L1").Begin();
				lvl1_visible = !lvl1_visible;
				
				showFilmTable(0);
			}
		}
		
	},
	
	// Accartoccia il livello 2
	handleLblData2_Click: function(sender, eventArgs) 
	{
		if (lvl1_visible==false && lvl3_visible==true){
			if (lvl2_visible==true){
				this.control.content.findName("fold_L2").Begin();
				lvl2_visible = !lvl2_visible;
				
				showFilmTable(2);
			}else{
				this.control.content.findName("unfold_L2").Begin();
				lvl2_visible = !lvl2_visible;
				
				showFilmTable(1);
				
			}
		}
		
	}
	
	
}
