
winIEpass = ((navigator.appName.indexOf("Microsoft") != -1) && 
  (navigator.appVersion.indexOf("Windows") != -1)) && 
  (parseFloat(navigator.appVersion) >= 4) ? true : false;

NNpass = ((navigator.appName == "Netscape") && 
  (navigator.userAgent.indexOf("Mozilla") != -1) && 
  (parseFloat(navigator.appVersion) >= 4) && 
  (navigator.javaEnabled())) ? true : false;

supportedBrowser = (winIEpass || NNpass) ? true : false;

// check for Flash Plug-in in Mac or Win Navigator. Get plug-in version.

minPlayer = 4;

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, w,h) {
  var btns = true; //Flash_checkForMinPlayer();
  var defaultColor = (document.bgColor != null) ? document.bgColor : "#ffffff";
  var bgcolor = (swfbgColor != null) ? swfbgColor : defaultColor;
  if (btns) document.writeln(
    '<table border="0" bgcolor="'+bgcolor+'"><tr><td colspan="3">');
  document.writeln(
    '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
    'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" '+
    'ID="'+id+'" WIDTH="'+w+'px" HEIGHT="'+h+'px">'+
    '<PARAM NAME="movie" VALUE="'+srcURL+'">'+ 
    '<PARAM NAME="quality" VALUE="high">'+
    '<PARAM NAME="wmode" VALUE="transparent">'+
    '<PARAM NAME="autostart" VALUE="false">'+
    '<PARAM NAME="loop" VALUE="false">'+
    '<PARAM NAME="bgcolor" VALUE='+bgcolor+'>'+
    '<embed NAME="'+id+'" src="'+srcURL+'" quality="high" loop="false" start="false" autostart="false" play="false" bgcolor="'+bgcolor+'" width="'+w+'px" height="'+h+'px" '+
    'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></OBJECT>');
  if (btns) document.writeln('</td></tr><tr>'+
    '<td><input type="button" name="rewind'+id+'" value="Begin" onclick="javascript:window.document.'+id+'.Rewind(); return false;"></td>'+
    '<td  align="middle"><input type="button" name="start'+id+'" value=" Start " onclick="javascript:window.document.'+id+'.Play(); return false;"></td>'+
    '<td  align="right"><input type="button" name="pause'+id+'" value="Pause" onclick="javascript:window.document.'+id+'.StopPlay(); return false;"></td></tr></table>');
  eval('window.document.'+id+'.Rewind()');
}

function flash_embed(spanid,id, srcURL, swfbgColor, w,h) {
  var btns = true; //Flash_checkForMinPlayer();
  var defaultColor = (document.bgColor != null) ? document.bgColor : "#ffffff";
  var bgcolor = (swfbgColor != null) ? swfbgColor : defaultColor;
  var t='';
  if (btns)
  t+='<table border="0" bgcolor="'+bgcolor+'">'+
     '<tr>'+
       '<td colspan="3">';
  t+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
       'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" '+
       'ID="'+id+'" WIDTH="'+w+'px" HEIGHT="'+h+'px">'+
       '<PARAM NAME="movie" VALUE="'+srcURL+'">'+
       '<PARAM NAME="quality" VALUE="high">'+
       '<PARAM NAME="wmode" VALUE="transparent">'+
       '<PARAM NAME="autostart" VALUE="false">'+
       '<PARAM NAME="loop" VALUE="false">'+
       '<PARAM NAME="bgcolor" VALUE='+bgcolor+'>'+
       '<embed NAME="'+id+'" id="embed'+id+'" src="'+srcURL+'" quality="high" loop="false" start="false" autostart="false" play="false" bgcolor="'+bgcolor+'" width="'+w+'px" height="'+h+'px" '+
         'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'+
       '</embed>'+
     '</object>';
  if (btns)
    t+='</td>'+
     '</tr>'+
     '<tr>'+
       '<td><input type="button" name="rewind'+id+'" value="Begin" onclick="javascript:flash_rewind(\''+ifstring(Microsoft,'','embed')+id+'\')"></td>'+
       '<td  align="middle"><input type="button" name="start'+id+'" value=" Start " onclick="javascript:flash_play(\''+ifstring(Microsoft,'','embed')+id+'\')"></td>'+
       '<td  align="right"><input type="button" name="pause'+id+'" value="Pause" onclick="javascript:flash_stop(\''+ifstring(Microsoft,'','embed')+id+'\')"></td>'+
     '</tr>'+
     '</table>';
  getid(spanid).innerHTML=t;
  flash_rewind(ifstring(Microsoft,'','embed')+id);
}

function flash_rewind(id) {
  if (getid(id)) getid(id).Rewind();
}

function flash_play(id) {
//getid('txt').innerHTML+='<br>play: id='+id;
  if (getid(id)) {
//getid('txt').innerHTML+='<br>play: getid=ok';
   getid(id).Play();
  }
}

function flash_stop(id) {
  if (getid(id)) getid(id).StopPlay();
}

