/**
* @author saklak
*/


/**
* Liste des méthodes accessibles depuis JS dans AS (Exemple sous FF: document.getElementById("mainswf").clearCache();)
* Toutes les méthodes suivantes ne sont accessibles dans l'appli flash qu'une fois que
* la fonction JS ci-dessous ("onMp3PlayerInit()") a  appele par le swf !
* clearCache() : void
* setSection(sSectionID:String) : void
* setPatchCount(sSectionID : String, nNum : int) : void
* reloadPlaylist() : void
*/

function onMp3PlayerInit()
{
	//alert('Le player mp3 swf est initialis�. Ses m�thodes sont disponibles depuis JS');
}

function mp3PlayerAdminAddTrack(sSessionID)
{
	$('#modal_ajoutermusique').css("display","block");
	$("#modal_ajoutermusique").load('/blog/addmusique/');
	$("#modal_ajoutermusique").dialog('open');
	$('#anchor-focus-modal').focus();
	//$("#boutons_modal_presentation").append($("#annuler_modal"));
	//$('#flashcontent').height(190);
}

function mp3PlayerAddTrackToPlaylist(sTrackID, sSessionID)
{
	$('#modal_foncnondispo').dialog('open');
//	alert('ADD TO PLAYLIST! TRACK ID = "' + sTrackID + '"');
}
function mp3PlayerDownloadTrack(sTrackID, sSessionID)
{
	$('#modal_bientotdispo').dialog('open');
//	alert('DOWNLOAD! TRACK ID = "' + sTrackID + '"');
}
function mp3PlayerShareTrack(sTrackID, sSessionID)
{
//	$('#modal_bientotdispo').dialog('open');
//	alert('SHARE! TRACK ID = "' + sTrackID + '"');
}
function mp3PlayerEditTrack(sTrackID, sSessionID)
{
	$('#modal_editermusique').css("display","block");
	$("#modal_editermusique").load('/blog/editmusique?idtrack='+sTrackID);
	$("#modal_editermusique").dialog('open');
	
	//$('#flashcontent').height(190);

//	alert('EDIT! TRACK ID = "' + sTrackID + '"');
}

function mp3PlayerError(sErrorID)
{
	alert('ERROR FROM FLASH: ' + sErrorID);
}

/*
 * Attention ce code existe ailleur voir player.phtml
function mp3PlayerClickSection(sSectionID)
{
	// attention ce n est pas celui ci qui est used
	$('#modal_ajoutermusique').css("display","none");
	$('#modal_editermusique').css("display","none");
	
	switch (sSectionID){
	case 'pres':
//		alert($('#flashcontent').height());
//		loadSWF
		$('#flashcontent').height(80);
		$('#ongletpres').show(200);
		$('#ongletphoto').fadeOut(200);
		$('#ongletvideo').fadeOut(200);
		
		break;
	case 'music':
//		alert('music');
		$('#flashcontent').height(597);
		//document.getElementById("mainswf").setHeight(597);
		$('#ongletpres').hide(200);
		$('#ongletphoto').fadeOut(200);
		$('#ongletvideo').fadeOut(200);
		break;
	case 'photo':
		//alert('photo');
		$('#flashcontent').height(80);
		$('#ongletpres').hide(200);
		$('#ongletvideo').fadeOut(200);
		$('#ongletphoto').load("/blog/addphoto/uid/"+sSectionID);
		$('#ongletphoto').fadeIn(200);
		break;
	case 'video':
		$('#flashcontent').height(80);
		$('#ongletpres').hide(200);
		$('#ongletphoto').fadeOut(200);
		$('#ongletvideo').load("/blog/minivideos/uid"+sSectionID);
		$('#ongletvideo').fadeIn(200);
		break;
	}
	document.getElementById("mainswf").setSection(sSectionID);
}
*/

function reloadPlaylist(){
	document.getElementById("mainswf").reloadPlaylist();	
//	alert("ok recharger");
}
/**
* Une m�thode actionscript peut �tre appel�e depuis javascript: "clearCache()"
* Exemple sous FF: document.getElementById("mainswf").clearCache();
* Alors le "swf mp3 player" envoie toutes les stats de lecture encore en cache � AMFPHP.
* Puis, quand l'op�ration est termin�e, il appelle la fonction JS ci-dessous ("onCacheCleared()")
* Ca permet, lorsqu'on doit changer de page, fermer le player MP3 suite � une action user,
* de s'assurer que toutes les stats sont bien envoy�es.
*/

function onCacheCleared()
{
	alert('Toutes les stats ont �t� envoy�es !');
}








function tmpTest()
{
	var r;
	r = Math.floor(Math.random() * 999) + 1;
	document.getElementById("mainswf").setPatchCount('music', r);
	r = Math.floor(Math.random() * 999) + 1;
	document.getElementById("mainswf").setPatchCount('photo', r);
	r = Math.floor(Math.random() * 999) + 1;
	document.getElementById("mainswf").setPatchCount('video', r);
	r = Math.floor(Math.random() * 999) + 1;
	document.getElementById("mainswf").setPatchCount('tracks', r);
	r = Math.floor(Math.random() * 999) + 1;
	document.getElementById("mainswf").setPatchCount('albums', r);
}
