// Choose Flash or Static Image code
var agt = navigator.userAgent.toLowerCase();
var is_ie   = (agt.indexOf("msie ") != -1 && agt.indexOf('opera')==-1); 

// Plugin Detection
var WM_startTagFix = '</';
var msie_windows = 0;
if (is_ie && (agt.indexOf('win') != -1)){
  msie_windows = 1;
  document.writeln('<script language="VBscript">');
  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){
  var i,plugin_undetectable=0,detected=0, daPlugin=new Object();
  if (msie_windows && WM_detect_through_vb){
      plugin_undetectable = 0;
  } else {
      plugin_undetectable = 1;
  }
  if(navigator.plugins) {
      numPlugins = navigator.plugins.length;
      if (numPlugins > 1) {
     if (navigator.mimeTypes && navigator.mimeTypes[pluginmime] && navigator.mimeTypes[pluginmime].enabledPlugin && (navigator.mimeTypes[pluginmime].suffixes.indexOf(pluginxtension) != -1)) { 
         if ((navigator.appName == 'Netscape') && (navigator.appVersion.indexOf('4.0') != -1)) { 
        for(i in navigator.plugins) {
            if ((navigator.plugins[i].description.indexOf(plugindescription) != -1) || (i.indexOf(plugindescription) != -1)) { 
           detected=1;
           break;
            }
        }
         } else {
        for (i = 0; i < numPlugins; i++) {
            daPlugin = navigator.plugins[i];
            if ((daPlugin.description.indexOf(plugindescription) != -1) || (daPlugin.name.indexOf(plugindescription) != -1)) {
           detected=1;
           break;
            }
        }
         }
      if (navigator.mimeTypes[pluginmime] == null) {
        detected = 0;
         }
     }
     return detected;
      } else if((msie_windows == 1) && !plugin_undetectable){
     return WM_activeXDetect(activeXname);
      } else {       
     return 0;
      }
  } else {
      return 0;
  }
}

// Check for Flash (uses WM_pluginDetect)
function flashCheck() {
if(WM_pluginDetect('Flash 9','swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.9')) { 
      return 9;
   }
   else if(WM_pluginDetect('Flash 10','swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.10')) { 
      return 10;
   }
   else if(WM_pluginDetect('Flash 8','swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.8')) { 
      return 8;
   }
   else if(WM_pluginDetect('Flash 7','swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.7')) { 
      return 7;
   }
   else if(WM_pluginDetect('Flash 6','swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.6')) { 
      return 6;
   }
   else if(WM_pluginDetect('Flash','swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash')) {
      return "Unknown"; 
   } 
   else {
      return "Not Detected";  
   }
}


function chooseFlashOrStatic(requiredFlashVersion, flashPath, staticImagePath, width, height, altText,bgcolor, mapName, flashVars) {
    var result;
    var detectedFlashVersion = flashCheck();

   // If the user has Flash of a sufficient version, use the SWF
   if (detectedFlashVersion >= requiredFlashVersion && detectedFlashVersion != "Not Detected") {
      result = '<object';
      result += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
      result += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"';
      result += ' width="' + width + '"';
      result += ' height="' + height + '"';
      result += '>';
      result += ' <param name=movie value="' + flashPath + '">';
      result += ' <param name=bgcolor value="' + bgcolor + '">';
      result += ' <param name=loop value="false">';
      result += ' <param name=quality value="high">';
      result += ' <param name=menu value="0">';
      result += ' <param name=allowScriptAccess value="sameDomain">';
      if (flashVars != undefined && flashVars.length > 0) {
         result += ' <param name=FlashVars value="' + flashVars + '">';
       }
      result += ' <embed src="' + flashPath + '"';
      result += ' quality="high"';
      result += ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"';
      result += ' type="application/x-shockwave-flash"';
        result += ' allowScriptAccess="sameDomain"';
      result += ' width="' + width + '"';
      result += ' height="' + height + '"';
      result += ' bgcolor="' + bgcolor + '"';
      result += ' loop="false"';
      result += ' quality="high"';
      result += ' menu="0"';
      result += ' name="' + name + '"';
      if (flashVars != undefined && flashVars.length > 0) {
         result += ' FlashVars="' + flashVars + '"';
       }
      result += '>';

      result += '</embed></object>';
   }  
   // If Flash is not detected or is too low a version, use an image with an image map
   else {
       if (staticImagePath == undefined || staticImagePath.length == 0) {
            result = "<p>Please download Flash, it's free. <a href='http://www.adobe.com/go/getflashplayer' target='_blank'></p>";
       } else {
          result = '<img src="' + staticImagePath + '"';
          result += ' width="' + width + '"';
          result += ' height="' + height + '"';
          result += ' alt="' + altText + '"';
          result += ' border="0"';
          if (mapName) {
             result += ' usemap="#' + mapName + '"';
          }
          result += '>';
       }
   }
document.write (result);
}