function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

var cur_id = '';

function playFlash(bid) {
	if (cur_id != '') {
		stopFlash(cur_id);
	}
	cur_id = bid;
	var flashMovie = getFlashMovieObject('play');
	flashMovie.GotoFrame(0);
	flashMovie.SetVariable("_root.mp3file", document.getElementById(bid).name);
	flashMovie.GotoFrame(1);
	
	document.getElementById(bid + '_img').src = 'stop.png';
	document.getElementById(bid).onclick = function(){return stopFlash(bid)};
	document.getElementById(bid).onkeypress = function(){return stopFlash(bid)};

	return false;
}
function stopFlash(bid)
{
	var flashMovie = getFlashMovieObject('play');
	flashMovie.GotoFrame(0);
	flashMovie.StopPlay();

	if (document.getElementById(bid + '_img')) {
		document.getElementById(bid + '_img').src = 'play.png';
		document.getElementById(bid).onclick = function(){return playFlash(bid)};
		document.getElementById(bid).onkeypress = function(){return playFlash(bid)};
	}
	return false;
}

