//***************************
// A few variables to help figure out what platform we're on

var ie  = (navigator.appName.toLowerCase().indexOf("microsoft") != -1);
var ns  = (navigator.appName.toLowerCase().indexOf("netscape") != -1);
var win = (navigator.platform.toLowerCase().indexOf("win") != -1);
var mac = (navigator.platform.toLowerCase().indexOf("mac") != -1);
var browserVer = parseFloat(ie ? navigator.appVersion.substring(navigator.appVersion.toLowerCase().indexOf("msie") + 4) : navigator.appVersion);



//***************************
// check to see if the shockwave plugin is present

function IsShockwaveInstalled(sngRequiredVersion) {
  var boolResult = false;
  
  if( shockwaveDetectNsVer(sngRequiredVersion) == true ) {
    boolResult = true;
  }

  if( shockwaveDetectAxVer(sngRequiredVersion) == true ) {
    boolResult = true;
  }
  
  return( boolResult );
}



//***************************
function IsFlashInstalled(intRequiredVersion) {
  var boolResult = false;
  
  if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) {
    var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin
    if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= parseInt(intRequiredVersion)) { 
      boolResult = true;
    }
  }
  
  if( navigator.plugins && navigator.plugins["Shockwave Flash"] ) {
    var strDescription = navigator.plugins["Shockwave Flash"].description;
    var intVer = parseInt(strDescription .substring(strDescription .indexOf(".")-1))
    if( intVer > intRequiredVersion) {
      boolResult = true;
    }
  }
  
  if( flashDetectAxVer( intRequiredVersion ) == true ) {
    boolResult = true;
  }

  return( boolResult );
}



//***************************
// For detecting the ActiveX for ie win.
// Requires vbscript function below to be included on
// the page to do the actual checking.
// Returns version found or 0.0.

function flashDetectAxVer(reqVer) {
  var boolResult = false;

  if (ie && win) {
    if( VBConfirmFlashVer( reqVer ) == true ) {
      boolResult = true;
    }
  }
  return( boolResult );
}



//***************************
// Simple browser checking, returns true if using a recommended browser
// REQUIRED browser is actually lower in most cases.

function IsDetectPossible() {
  // Recommended minimum browser versions for shockwave content
  // this can be skipped by setting the swDetect cookie to "ignore"
  // this will make the code react like you are using a supported browser 
  // no matter what the truth may be.
  
  if (ie && win) return (browserVer >= 4.0) // Works in lower versions, but detection difficult.
  if (ie && mac) return (browserVer >= 5.0) // Works in lower versions, but can't do detection.
  if (ns && win) return (browserVer >= 3.0)
  if (ns && mac) return (browserVer >= 3.0)
  
  return false;
}




//***************************
// For detecting the shockwave plugin for Netscape.
// This function can return a boolean or a floating point value.
// If you supply a reqVer value (number) it will return true or false
// depending on if that version or higher was found.
// If you don't supply a parameter it will return the found version number.

function shockwaveDetectNsVer(reqVer) {
  // This function returns a floating point value which should be the version of the Shockwave plugin or 0.0
  // This function only returns useful information if called from Netscape or IE Mac 5.0+

  if (!navigator.plugins) return (reqVer ? false : 0.0); // IE Mac 4.5 and lower don't have a plugins array.

  // Set these local variables to avoid the Netscape 4 crashing bug.
  thearray = navigator.plugins
  arraylen = thearray.length

  // Step through each plugin in the array.
  for (i=0; i < arraylen; i++) {
    // Set these local variables to avoid the Netscape 4 crashing bug.
    theplugin = thearray[i]
    thename   = theplugin.name
    thedesc   = theplugin.description

    // If the plugin is Shockwave...
    if (thename.indexOf("Shockwave") != -1 && thename.indexOf("Director") != -1) {
      // ...extract the version information
      versionString = thedesc.substring(thedesc.indexOf("version ") + 8);
      if (versionString.indexOf(".") > 0) {
        versionMajor = versionString.substring(0,versionString.indexOf("."));
        versionMinor = versionString.substring(versionString.indexOf(".") + 1);
        if (versionMinor.indexOf(".") > 0)
          versionMinor = versionMinor.substring(0,versionString.indexOf("."))
                         + versionMinor.substring(versionMinor.indexOf(".") + 1);   
        versionString = parseInt(versionMajor) + "." + versionMinor;
      }
      return (reqVer ? (parseFloat(versionString) >= reqVer) : parseFloat(versionString));
    } 
  }
  return (reqVer ? false : 0.0);
}



//***************************
// For detecting the ActiveX for ie win.
// Requires vbscript function below to be included on
// the page to do the actual checking.
// Returns version found or 0.0.

function shockwaveDetectAxVer(reqVer) {
  var boolResult = false;

  if (ie && win) {
    if( VBConfirmShockwaveVer( reqVer ) == true ) {
      boolResult = true;
    }
  }
  return( boolResult );
}
