// Insert an audio preview SWF into the page. Requires flash.js.
function audioPreview(mp3URL) {
    if(Flash.detect() >= 9) {
        var swf = new Flash('/swf/preview.swf?audio=' + mp3URL, 77, 16);
        swf.write();
    }
}

function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
 }
 
function playPreview(trackName,buttonName) {
	if(this.prevTrack && this.prevButton) {
		stopPreview(this.prevTrack,this.prevButton);
	}
	this.prevTrack = trackName;
	this.prevButton = buttonName;
	getFlashMovie('PreviewPlayer').sendTrack(trackName,buttonName);
	document.getElementById(buttonName).innerHTML = '<img src="/img/stop.gif" border="0" onClick="stopPreview(\''+trackName+'\',\''+buttonName+'\');" />';
}

function stopPreview(trackName,buttonName) {
	getFlashMovie('PreviewPlayer').stopTrack();
	document.getElementById(buttonName).innerHTML = '<img src="/img/preview.gif" border="0" onClick="playPreview(\''+trackName+'\',\''+buttonName+'\');" />';
}

function getVimeoVideo(url) {
	document.write('<object type="application/x-shockwave-flash" width="425" height="320" data="'+url+'">');
	document.write('<param name="quality" value="best" />');
	document.write('<param name="allowfullscreen" value="true" />');
	document.write('<param name="scale" value="showAll" />');
	document.write('<param name="movie" value="'+url+'" />');
	document.write('</object>');
}

function getYouTubeVideo(url) {
	document.write('<object width="425" height="353" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0">');
	document.write('<param name="movie" value="'+url+'"></param>');
	document.write('<param name="wmode" value="transparent"></param>');
	document.write('<param name="allowScriptAccess" value="always"></param>');
	document.write('<embed src="'+url+'" type="application/x-shockwave-flash" wmode="transparent" allowScriptAccess="always" width="425" height="353"  pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');
	document.write('</object>');
}
