var WM_startTagFix = '</';
var i_am_vindows = 0;
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Windows') != -1)){
  i_am_vindows = 1;
  document.writeln('<script language="VBscript">');
  document.writeln('\'This will scan for plugins for all versions of Internet Explorer that has a VB script engine version 2 or greater.');
  document.writeln('\'This includes all versions of IE4 and beyond and some versions of IE 3.');
  document.writeln('Dim WM_detect_through_vb');
  document.writeln('WM_detect_through_vb = 0');
  document.writeln('If ScriptEngineMajorVersion >= 2 then');
  document.writeln('  WM_detect_through_vb = 1');
  document.writeln('End If');
  document.writeln('Function WM_activeXDetect(activeXname)');
  document.writeln('  on error resume next');
  document.writeln('  If ScriptEngineMajorVersion >= 2 then');
  document.writeln('     WM_activeXDetect = False');
  document.writeln('     WM_activeXDetect = IsObject(CreateObject(activeXname))');
  document.writeln('     If (err) then');
  document.writeln('        WM_activeXDetect = False');
  document.writeln('     End If');
  document.writeln('   Else');
  document.writeln('     WM_activeXDetect = False');
  document.writeln('   End If');
  document.writeln('End Function');
  document.writeln(WM_startTagFix+'script>');
}

function WM_pluginDetect(plugindescription, pluginxtension, pluginmime, activeXname){
  //This script block will test all user agents that have a real plug-in array
  //(i.e. Netscape) and set the variables, otherwise it directes the routine
  //WM_activeXDetect to detect the activeX control.
  
  // First define some variables
  var i,plugin_undetectable=0,detected=0;

  // First we define browsers that have problems with certain plugins.
    var detectable_activex = new Array('ShockwaveFlash.ShockwaveFlash', 'SWCtl.SWCtl.1');
  
  // Then we check to see if it's an MSIE browser, that you can actually
  // check for the plugin in question. 

  if (navigator.userAgent.indexOf('MSIE') != -1) {
    if (navigator.userAgent.indexOf('Win') != -1) {
      if (WM_detect_through_vb){
	for(i=0;i<detectable_activex.length;i++){
	  if(activeXname.indexOf(detectable_activex[i]) != -1){
	    plugin_undetectable = 0;	
	    break;
	  } else {
	    plugin_undetectable = 1;
	  }
	}
      } else {
	 plugin_undetectable = 1;
      }
    } else {
      plugin_undetectable = 1;
    }
  } 
  if(navigator.plugins){
    if(navigator.plugins.length > 1){
      for (i = 0; i < navigator.plugins.length; i++) {
	plugin = navigator.plugins[i];
	if ((plugin.description.indexOf(plugindescription) != -1)) {
	  numTypes = plugin.length;
	  for (j = 0; j < numTypes; j++) {
	    mimetype = plugin[j];
	    if (mimetype) {
	      if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf(pluginxtension) != -1)) {
		detected = 1;
	      }
	      // Mac wierdness
	      if (navigator.mimeTypes[pluginmime] == null) {
		detected = 0;
	      }
	    }
	  }
	}
      }
      return detected;
    } else if(plugin_undetectable){
      return 2;
    } else if (i_am_vindows == 1) {
      return WM_activeXDetect(activeXname);
    } else {
	return 0;
    }
  } else { 		
    return 0;
  }
}

var plugDetect = WM_pluginDetect('Flash', 'swf', 'application/x-shockwave-flash', 'ShockwaveFlash.ShockwaveFlash');