// check for Flash Plug-in in Mac or Win Navigator. Get plug-in version.


minPlayer = 4;
var mySwf;

function Flash_checkForPlugIn() {
  var plugin = (navigator.mimeTypes &&
  navigator.mimeTypes["application/x-shockwave-flash"]) ?
  navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
  if (plugin) {
    var pluginversion = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) 
    if(pluginversion >= minPlayer) {return true;}
  }
  return false;
}

// vbscript check for Flash ActiveX control in windows IE
if(supportedBrowser && winIEpass) {
  document.write(
    '<script language=VBScript>' + '\n' +
    'Function Flash_checkForActiveX()' + '\n' +
    'Dim hasPlayer, playerversion' + '\n' +
    'hasPlayer = false' + '\n' +
    'playerversion = 10' + '\n' +
    'Do While playerversion >= minPlayer' + '\n' +
    'On Error Resume Next' + '\n' +
    'hasPlayer = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & playerversion & \"\")))' + '\n' +
    'If hasPlayer = true Then Exit Do' + '\n' +
    'playerversion = playerversion - 1' + '\n' +
    'Loop' + '\n' +
    'Flash_checkForActiveX = hasPlayer' + '\n' +
    'End Function' + '\n' +
    '<\/script>'
  );
}



function Flash_checkForMinPlayer() {
  if(!supportedBrowser) return false;
  if(NNpass) return (Flash_checkForPlugIn());
  if(winIEpass) return (Flash_checkForActiveX());
}



function Flash_embedSWF(srcURL, id, swfbgColor, Width, Height, Style) {

  if (!Flash_checkForMinPlayer()) return;

  var defaultColor = (document.bgColor != null) ? document.bgColor : "#ffffff";
  var bgcolor = (swfbgColor != null) ? swfbgColor : defaultColor;
  document.writeln(
    '<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' +
    'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"' +
    'ID="' + id + '" WIDTH="' + Width + '" HEIGHT="' + Height + '" + style="' + Style + '">' +
    '<PARAM NAME="movie" VALUE="' + srcURL + '">' + 
    '<PARAM NAME="quality" VALUE="high">' +
    '<PARAM NAME="wmode" VALUE="transparent">'+
    '<PARAM NAME="autostart" VALUE="false">'+
    '<PARAM NAME="bgcolor" VALUE=' + bgcolor + '>' +
    '<embed src="' + srcURL + '" quality="high"' + 'bgcolor="' + bgcolor +
    '"' + 'width="' + Width + '" height="' + Height + '"' +
    'type="application/x-shockwave-flash" NAME="' + id + '"' +
 'pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></OBJECT>');

  eval('window.document.'+ id + '.Rewind()');
}

function sonified_flash(id, myFrame){
  if(!Flash_checkForMinPlayer()) {return;}
  mySwf = eval('window.document.' + id);
  if (mySwf.PercentLoaded()<100) return

  mySwf.GotoFrame(myFrame);
  mySwf.GotoFrame(0);
}

