// Create a Youtube style text indicator underneath the stars,
// using starbox custom events
function starboxChangedText(event) {
  var indicator = this.down('.indicator'),
  pick = (event.memo.rating || 0).round() - 1,
  indicator = this.down('.indicator');
  
  // for restoring, store the indicator text on the star if it was not set before.
  this.starboxResetText = this.starboxResetText || indicator.innerHTML;
  
  this.down('.indicator').update([
    'Inascoltabile',
	'Insignificante',
	'Ascoltabile',
	'Ascoltabile, ma c\'è di meglio!',
	'Carina',
	'Bella',
	'Stupenda',
	'Da brividi',
	'Capolavoro',
	'SUPER! La ascolterei sempre'
  ][pick]); 
}

// when the link is clicked update the restore value
function starboxRatedText() {
  var indicator = this.down('.indicator');
  this.starboxResetText = indicator.innerHTML;
}

// here we restore the indicator on mouseout, if needed
function starboxLeftText() {
  this.down('.indicator').update(this.starboxResetText || '');
}

document.observe('dom:loaded', function() {
  $('vote').observe('starbox:rated', saveStar);
  $('vote').observe('starbox:changed', starboxChangedText) // observe the mouseover
  $('vote').observe('starbox:left', starboxLeftText); // observe the mouseout
});
