// JavaScript Document

//replace the holder (div.miniPlayer) with flash movie to play audio 
//add flash settings
var flashvars = {};
var params = {};
params.play = "false";
params.loop = "false";
params.menu = "false";
params.quality = "medium";
params.wmode = "transparent";
var attributes = {};
attributes.name = "miniPlayer";
//replace using swfobject 2
swfobject.embedSWF("flash/audioSamplePlayer.swf", "miniPlayer", "10", "10", "8.0.0", false, flashvars, params, attributes);

//formats parameter depending if the browser is IE 
function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

//plays the specified sample and hides/displays the relevant play/stop links
function play(url,i){
	var queryId = $("mp3queryid_"+i).val();
	url=url+"&id="+queryId;
	//getFlashMovie("miniPlayer").sendToFlash("http://"+window.location.hostname+"/"+directory+"/"+track);
	getFlashMovie("miniPlayer").sendToFlash("http://"+url);
	$(".btnStop").hide();
	$(".btnPlay").show();
	$("#play_"+i).hide();
	//$("#stop_"+i).show();
	$("#stop_"+i).css("display","block");
}

//plays the specified MusicGlue sample and hides/displays the relevant play/stop links
function playMusicGlueSample(GUID){
	getFlashMovie("miniPlayer").sendToFlash("http://s3.amazonaws.com/MusicGlue/"+GUID);
	$(".btnStop").hide();
	$(".btnPlay").show();
	$("#play_"+GUID).hide();
	//$("#stop_"+GUID).show();
	$("#stop_"+GUID).css("display","block");
}

//stops all samples, and hides/displays the relevant play/stop links
function stop(i){
	getFlashMovie("miniPlayer").sendToFlash("stop");
	$("#stop_"+i).hide();
	$("#play_"+i).show();
}

//shows all play links, called by audioSamplePlayer.swf
function resetSampleControls(){
	$(".btnStop").hide();
	$(".btnPlay").show();
}