var tasti;
var contenuto;
/////////////////////////////////////////////////////
function initGioco(sender,args){
	contenuto = sender.findName("tasti");
	var control = sender.getHost();
	var xamlItem = sender.getResponseText("");	
	tasti = control.content.createFromXaml(xamlItem,true);	
	contenuto.children.add(tasti);	
}
function startAnimazioneTasti(sender, args){
	tml_sfondo = tasti.findName("tasti_in");
	tml_sfondo.begin();							
}
////////////////////////////////////////
//EVENTI
////////////////////////////////////////
function over_tasto(sender, args) {
	animaTasto(sender, args, "over");
}
function out_tasto(sender, args) {	
	animaTasto(sender, args, "out");
}
function release_tasto(sender, args){
	//area_sensibile_tasto_n
	var id=sender.name.slice(21)
	if(id==1){
		window.open("http://ricordidiscuola.spaces.live.com", '_blank');
 	}else if(id==2){
		window.open("/html/test.asp", '_self');
	}else if(id==3){
		window.open("/html/store.html", '_self');
	}else if(id==4){
		window.open("/html/messenger.html", '_self');
	}else if(id==5){
		window.open("/html/mobile.html", '_self');
	}else if(id==6){
		window.open("/html/lifecam.html", '_self');
	}else if(id==7){
		window.open("/html/office.html", '_self');
	}else if(id==8){
		window.open("/html/onecare.html", '_self');
	}else if(id==9){
		window.open("/html/vista.html", '_self');
	}else if(id==10){
		window.open("mailto:?subject=Oggi hai un nuovo modo di studiare!&body=Vai su <a href='http://ricordidiscuola.it.msn.com'>http://ricordidiscuola.it.msn.com</a> e scopri come rivoluzionare il modo di studiare! In pił per te tante emoticon GRATIS per Messenger e fantastici gadget!", '_self');		
	}else if(id==11){            		
		BlogIt();
	}else if(id==12){		
		toggleContacts();
	}	
}
function animaTasto(sender, args, tipo) {
		var id=sender.name.slice(21)
		if(tipo =="over"){		
			var tml_form = sender.findName("tasto_"+ id +"_over");		
			tml_form.begin();
			//AUDIO
			//audioStart(sender, args)
		}else if(tipo =="out"){
			var tml_form = sender.findName("tasto_"+ id + "_out");		
			tml_form.begin();
		}else if(tipo =="release"){	
		}
		
}
function fineAnimazionTasti(sender, args){
    sender.findName("maschera_no_click").visibility="collapsed"
}
function audioStart(sender, eventArgs){
	var id=sender.name.slice(21)
  	var mediaElement=null 
	if(id==1){
	
 	}else if(id==2){
	
	}else if(id==3){
	
	}else if(id==4){
	
	}else if(id==5){
		mediaElement = sender.findName("cellulare");
	}else if(id==6){
		
	}else if(id==7){
		
	}else if(id==8){
		
	}else if(id==9){
		
	}else if(id==10){
		
	}else if(id==11){
		
	}else if(id==12){
		
	}
	if(mediaElement!=null){
		var position = mediaElement.position;
   		position.seconds = 0;
	   	mediaElement.position = position;
	   	mediaElement.Play();
	}
}