

var playerPath = '/resources/swf';
var imagePath = '/resources/swf/pics';

var imagePlay = new Image; 
imagePlay.src = imagePath +'/maf_play.gif';
var imageStop = new Image; 
imageStop.src = imagePath +'/maf_stop.gif';

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

var nowPlaying = '';

function playSample(sampleElementId, 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) {
  		if((sampleElementId.indexOf("/opt/telecom/tomcat")) == 0) {
			sampleElementIdnew = sampleElementId.substring(19,sampleElementId.length);
			flashProxy.call("playClip", sampleElementIdnew);
 	   	document.getElementById(sampleElementId).src = imageStop.src;
 	   	nowPlaying = sampleElementId;   
			}
			else {
			
  	  
  	  if((sampleElementId.indexOf(".mp3")) == -1 && (sampleElementId.indexOf(".dm")) == -1) {
				
				
				flashProxy.call("playClip", sampleElementId+ ".mp3");
 	   		document.getElementById(sampleElementId).src = imageStop.src;
 	   		nowPlaying = sampleElementId;   
			
			}
			else {
	
			flashProxy.call("playClip", sampleElementId);
 	   	document.getElementById(sampleElementId).src = imageStop.src;
 	   	nowPlaying = sampleElementId;   
			}
			
  	  }
  	  
 	   	
  }
  else {
    flashProxy.call("stopClip");
    document.getElementById(sampleElementId).src = imagePlay.src;
    nowPlaying = '';
  }
}
