function doPlayAudio(num, src, frameName){
	var sbtn = document.getElementById('stop-'+num); unhide(sbtn);
	var pbtn = document.getElementById('play-'+num); hide(pbtn);
	audioFrameObj=toObj(frameName);
	res = '<embed height="16" width="400" src="'+src+'" ';
	res += 'pluginspage="http://www.apple.com/quicktime/download/" ';
	res += 'type="audio/mpeg" controller="true" autoplay="true">';
	audioFrameObj.src='javascript: document.write(\''+res+'\');document.close();';
}


function doStopAudio(num, frameName) {
	var sbtn = document.getElementById('stop-'+num); hide(sbtn);
	var pbtn = document.getElementById('play-'+num); unhide(pbtn);
	if (document.playingID) { // local scope obs only (not the iframe)
		var audioObj = toObj(document.playingID);
		if (audioObj && audioObj.pause)audioObj.pause();
		document.playingID = '';
	}
	else {
		// empty the audioFrame
		var audioFrame = toObj(frameName);
		if(audioFrame)audioFrame.src='javascript: document.write("");document.close();';
	}
}

function cmsAudioWidget(src,text){
	cmsAudioWidget.id=cmsAudioWidget.id||0;
	cmsAudioWidget.id++;
	var font={};
	font.family = 'inherit';
	font.size = 'inherit';
	font.weight = 'bold';
	var btnPlayImg={};
	btnPlayImg.src='/voice-overs/button-play.png';
	btnPlayImg.width='32px';
	btnPlayImg.height='31px';
	var btnStopImg={};
	btnStopImg.src='/voice-overs/button-stop.png';
	btnStopImg.width='32px'; 
	btnStopImg.height='31px';
	document.write('<button id="play-'+cmsAudioWidget.id+'" style="border:0px;background-color:transparent;" onclick="doPlayAudio('+cmsAudioWidget.id+', \''+src+'\', \'audioFrame'+cmsAudioWidget.id+'\')"><img src="'+btnPlayImg.src+'" border="0" style="width:'+btnPlayImg.width+';height:'+btnPlayImg.height+';"/></button>');
	document.write('<button id="stop-'+cmsAudioWidget.id+'" style="border:0px;background-color:transparent;" class="hidden" onclick="doStopAudio('+cmsAudioWidget.id+', \'audioFrame'+cmsAudioWidget.id+'\')"><img src="'+btnStopImg.src+'" border="0" style="width:'+btnStopImg.width+';height:'+btnStopImg.height+';"/></button>');
	document.writeln('<span style="font-family: '+font.family+'; font-size: '+font.size+'; font-weight: '+font.weight+'; position:relative; top:-10px;">'+text+'</span><br>');
	document.writeln('<iframe height="16" width="100" name="audioFrame'+cmsAudioWidget.id+'" id="audioFrame'+cmsAudioWidget.id+'" frameborder="0" marginheight="0" marginwidth="0" style="background-color:transparent;position:absolute;left:-3000px;"></iframe>');
}
