/**
 * Functions Radio for Pokémon Espace
 * @started_on: 11/03/2009 @ 13:33
 * @author: Kurashi - mail@pokemonespace.com
 * @version: 1.0
 */

/**
 * Function listenToThisOne : allow user to listen to music he chose
 * @param id : id of the music
 */
function listenToThisOne(id) {
	document.getElementById("radio_player").innerHTML = '<iframe scrolling="no" frameborder="0" width="230" height="100" src="frame.php?autoplay='+id+'" name="radio"><span class="b">Votre navigateur ne supporte pas la technologie IFRAME. Il est n&eacute;cessaire &agrave; l\'utilisation de Pok&eacute;mon Espace Radio.</span></iframe>';
	document.getElementById("currentlyPlayingAt").innerHTML = document.getElementById("m"+id).innerHTML;
	document.getElementById("currentlyPlayingAt").style.visibility = "visible";
	
	showSharing(id);
}

/**
 * Function showSharing : show to user links for share song he's listening to
 * @param id : id of the music he's listening
 */
function showSharing(id) {
	title = "Radio Pok\351mon - "+document.getElementById("m"+id).innerHTML;
	document.getElementById("radio_bbcode_link").value = "[url=http://www.pokemonespace.com/radio/?musique_id="+id+"]"+title+"[/url]";
	document.getElementById("radio_xhtml_link").value = "<a title=\"Radio Pokemon\" href=\"http://www.pokemonespace.com/radio/?musique_id="+id+"\">"+title+"</a>";
	document.getElementById("radio_direct_link").value = "http://www.pokemonespace.com/radio/?musique_id="+id;
	document.getElementById("radio_sharing").style.display = "block";
}

/**
 * Function playRandom : allow user to listen to a random music
 * @version: 1.0
 */
function playRandom() {
	max = document.getElementById("max_music").innerHTML;
	nb = Math.floor(Math.random() * max)+1;
	
	listenToThisOne(nb);
}
