var playerPath = '/sampleplayer';
var imagePath = '/pics';

var imagePlay = new Image; 
var imageStop = new Image; 

imagePlay.src = imagePath +'/play.gif';
imageStop.src = imagePath +'/stop.gif';

var flashProxyId = new Date() . getTime();
var flashProxy = new FlashProxy(flashProxyId, playerPath +'/JavaScriptFlashGateway.swf');

var nowPlaying = '';

function playSample(sampleElementId, sampleSource, imageId) {

  if (imageId) {
    imagePlay.src = imagePath +'/play'+ imageId +'.gif';
    imageStop.src = imagePath +'/stop'+ imageId +'.gif';
    alert(imageStop.src);
  }

  if (nowPlaying != "" && nowPlaying != sampleElementId) {
    flashProxy.call("stopClip");
    document.getElementById(nowPlaying).src = imagePlay.src;
  }

  if (document.getElementById(sampleElementId).src == imagePlay.src) {
    flashProxy.call("playClip", sampleSource);
    document.getElementById(sampleElementId).src = imageStop.src;
    nowPlaying = sampleElementId;
  }
  else {
    flashProxy.call("stopClip");
    document.getElementById(sampleElementId).src = imagePlay.src;
    nowPlaying = '';
  }

}
