// Flash plugin detector - Script run in header to check for flash version
//							Flash movie is run if a sufficient version is installed
//							otherwise defined alternative code is used.
// Usage: flashmovie ("flash.swf", version, "height", "width", alternative)
//		flash.swf is the flash movie file
//		version is the main version number required by the movie
//		height is the movie height in pixels
//		width is the movie width in pixels
//		alternative is an index to the alternative array containing html code to run in the absence of Flash
// File flash_detector_alternatives.js must be embedded (i.e. copied and pasted) before this
// script is included and the alternative array defined.
//
// moock fpi [f.lash p.layer i.nspector] modified from version: 1.3.5 written by colin moock
// code maintained at: http://www.moock.org/webdesign/flash/detection/moockfpi/
// terms of use posted at: http://www.moock.org/terms/
// *************
// Everything below this point is internal until after the BODY tag.
// Do not modify! Proceed to the BODY tag for further instructions.
// *************
// System globals
var mheight = "36" ;
var mwidth = "36" ;
var mfile = "flash.swf" ;
var flash2Installed = false; 
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var maxVersion = 6;
var actualVersion = 0;          // version the user really has
var hasRightVersion = false;
var jsVersion = 1.0;
// Check the browser...we're looking for ie/win
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if IE
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if Windows
// This is a js1.1 code block, so make note that js1.1 is supported.
jsVersion = 1.1;
// Write vbscript detection on ie win. IE on Windows doesn't support regular JavaScript plugins array detection.
if(isIE && isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}
// Standard javascript detection that uses the navigator.plugins array.
// Pack the detector into a function so it loads before we run it.
function detectFlash() {  
  if (navigator.plugins) {
    // This bit won't run in IE so relying on previous VB script.
    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) 
      {
      // Flash found - which version?
      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
      // DEBUGGING: uncomment next line to see the actual description.
      // alert("Flash plugin description: " + flashDescription);
      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
      // Version found - set appropriate version flags. 
      flash2Installed = flashVersion == 2;    
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion >= 6;
    }
  }
  // set actualVersion to highest detected version.
  for (var i = 2; i <= maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  // If we're on webtv, assume the version supported is 3 
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;  
  // DEBUGGING: uncomment next line to display flash version
  // alert("version detected: " + actualVersion);
}
detectFlash();  // call our detector now that it's safely loaded.
//
// This function is used in the Body section to load the Flash movie or alternative code as required
//
function flashmovie (moviefile, requiredversion, height, width, alt_code)
{
if (actualVersion >= requiredversion)
  { 
  var loadflash = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
  + 'WIDTH="' + width + '" HEIGHT="' + height + '" '
  + 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"> '
  + '<PARAM NAME="MOVIE" VALUE="' + moviefile + '"> '
  + '<PARAM NAME="PLAY" VALUE="true"> '
  + '<PARAM NAME="LOOP" VALUE="false"> '
  + '<PARAM NAME="QUALITY" VALUE="high"> '
  + '<PARAM NAME="MENU" VALUE="false"> '
  + '<EMBED SRC="' + moviefile + '" '
  + 'WIDTH="' + width + '" HEIGHT="' + height + '" '
  + 'ALT="' + alttext[alt_code] + '" '
  + 'PLAY="true" '
  + 'LOOP="false" '
  + 'QUALITY="high" '
  + 'MENU="false" '
  + 'TYPE="application/x-shockwave-flash" '
  + 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> '
  + '</EMBED>'
  + '</OBJECT>';
	document.write (loadflash) ;
  }
else
  {
	document.write(alternative[alt_code]) ;   // write out the alternative code
  }
}

