// =============================================================================
// FLASH DETECTION
// =============================================================================
// version: 1.3.7
// 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/
// =============================================================================

// System globals
var b_flash2Installed = false;
var b_flash3Installed = false;
var b_flash4Installed = false;
var b_flash5Installed = false;
var b_flash6Installed = false;
var b_flash7Installed = false;
var b_flash8Installed = false;
var b_flash9Installed = false;
var n_maxVersion = 9;
var b_hasRightFlashVersion = false;
var n_actualVersion = 0;
var n_jsVersion = 1.0;

// Check the browser...we're looking for ie/win, but not aol
var b_isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
var b_isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; // true if we're on windows


// This is a js1.1 code block, so make note that js1.1 is supported.
n_jsVersion = 1.1;

// Write vbscript detection on ie win. IE on Windows doesn't support regular
// JavaScript plugins array detection.
if(b_isIE && b_isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('b_flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('b_flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('b_flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('b_flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('b_flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('b_flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('b_flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
  document.write('b_flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
  document.write('<\/SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

function getFlashVersion() {  
  // If navigator.plugins exists...
  if (navigator.plugins) {
    // ...then check for flash 2 or flash 3+.
    if (navigator.plugins["Shockwave Flash 2.0"]
        || navigator.plugins["Shockwave Flash"]) {
      
      // Set convenient references to flash 2 and the plugin description.
      var s_isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var s_flashDescription = navigator.plugins["Shockwave Flash" + s_isVersion2].description;

      // DEBUGGING: uncomment next line to see the actual description.
      // alert("Flash plugin description: " + flashDescription);
      
      // A flash plugin-description looks like this: Shockwave Flash 4.0 r5
      // We can get the major version by grabbing the character before the period
      // note that we don't bother with minor version detection. 
      // Do that in your movie with $version or getVersion().
      var n_flashVersion = parseInt(s_flashDescription.substring(16));

      // We found the version, now set appropriate version flags. Make sure
      // to use >= on the highest version so we don't prevent future version
      // users from entering the site.
      b_flash2Installed = n_flashVersion == 2;    
      b_flash3Installed = n_flashVersion == 3;
      b_flash4Installed = n_flashVersion == 4;
      b_flash5Installed = n_flashVersion == 5;
      b_flash6Installed = n_flashVersion == 6;
      b_flash7Installed = n_flashVersion == 7;
      b_flash8Installed = n_flashVersion == 8;
      b_flash9Installed = n_flashVersion >= 9;
    }
  }
  
  // Loop through all versions we're checking, and
  // set actualVersion to highest detected version.
  for (var i = 2; i <= n_maxVersion; i++) {  
    if (eval("b_flash" + i + "Installed") == true) n_actualVersion = i;
  }
  
  // If we're on msntv (formerly webtv), the version supported is 4 (as of
  // January 1, 2004). Note that we don't bother sniffing varieties
  // of msntv. You could if you were sadistic...
  if(navigator.userAgent.indexOf("WebTV") != -1) n_actualVersion = 4;
  
  // DEBUGGING: uncomment next line to display flash version
  // alert("version detected: " + actualVersion);
  
  doFlashVersion();
   
}

function doFlashVersion(){
  // If the user has a new enough version...
  if (n_actualVersion >= n_requiredFlashVersion) {    
    // If we got here, we didn't redirect. So we make a note that we should
    // write out the object/embed tags later.
    b_hasRightFlashVersion = true;             
  } else {  
    // The user doesn't have a new enough version.
    // If the redirection option is on, load the appropriate alternate page.
    if (b_useRedirect) {
      // Do the same .replace() call only if js1.1+ is available.
      if(n_jsVersion > 1.0) {
        window.location.replace(s_redirectPage);
      } else {
        window.location = s_redirectPage;
      }
    }
  }
}

function writeFlashObj(s_flashTag){
	if(b_hasRightFlashVersion){
		document.write(s_flashTag);
	}else{
		document.write(s_altFlashContent);
	}
}

getFlashVersion();  // call our detector now that it's safely loaded.