/******************************************************
 * Flash detection                                    *
 *                                                    * 
 * Written: 2004-02-13 Joelle Francois <jo@argon7.be> *
 * Revised: 2004-02-20 Joelle Francois <jo@argon7.be> *
 ******************************************************/

/*-----------------------*
 | NS specific detection |
 *-----------------------*/
function flash_detect_NS(FlashVersion) {

  detectFlash = false;

  FlashMime = 'application/x-shockwave-flash';
  FlashPlugin = 'Shockwave Flash';

  detectMimeList = '';
  for (var i=0; i < navigator.mimeTypes.length; i++) detectMimeList += navigator.mimeTypes[i].type.toLowerCase();

  if (detectMimeList.indexOf(FlashMime) != -1) if (navigator.mimeTypes[FlashMime].enabledPlugin != null) detectFlash = true;

  if (detectFlash) {
    var installedVersion = 0;
    var words = navigator.plugins[FlashPlugin].description.split(' ');
    for (var i=0; i < words.length; ++i) {
      if (isNaN(parseInt(words[i]))) continue;
      installedVersion = parseInt(words[i]); 
    }

    if (installedVersion < FlashVersion) detectFlash = false;
  }

  return detectFlash;
}

/*-----------------------*
 | IE specific detection |
 *-----------------------*/
function flash_detect_IE(FlashVersion) {

  hasFlashObj = false;
  checkVersion = parseInt(FlashVersion);

  while ((!hasFlashObj) && (checkVersion < 20)) {
    FlashObjClass = 'ShockwaveFlash.ShockwaveFlash.' + checkVersion;
    try {
      var flash = new ActiveXObject(FlashObjClass);
      hasFlashObj = true;
    }
    catch(e) {
    }
    checkVersion = checkVersion + 1;
  }
  return hasFlashObj;
}

/*-------------------*
 | Global detection |
 *-------------------*/
function flash_detect(FlashVersion, isIE) {

  var hasFlash = false;

  if (isIE) hasFlash = flash_detect_IE(FlashVersion);
  else hasFlash = flash_detect_NS(FlashVersion);

  return hasFlash;
}

