FlashDetector.prototype.GetVersion = pGetVersion;
FlashDetector.prototype.FlashDetect = pFlashDetect;

function pGetVersion() { return this.fVersion; }
function pFlashDetect() {
  //Du fait, qu'Opéra permet de choisir la signature du navigateur
  //Si aucune version n'est détectée, vérifier qu'Opéra signe bien "Opera" (et non "MSIE")
  if ( this.ua_IE && this.ua_WIN ) {
    document.write( '<SCR' + 'IPT LANGUAGE="VBScript">\r\n' );
    document.write( 'on error resume next\r\n' );
    document.write( 'TmpVBVersion = -1\r\n' );
  	document.write( 'For i='+this.fVer_min+' TO '+this.fVer_max+'\r\n' );
  	document.write( 'If NOT IsObject( CreateObject( "ShockwaveFlash.ShockwaveFlash." & i ) ) Then\r\n' );
  	document.write( 'Else\r\n' );
    document.write( ' TmpVBVersion = i\r\n' );
  	document.write( 'End If\r\n' );
  	document.write( 'Next\r\n' );
    document.write( '</SCR' + 'IPT>\r\n' ); // break up end tag so it doesn't end our script

    this.fVersion = TmpVBVersion;
  }

  if (navigator.plugins) { // If navigator.plugins exists...
    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { // ...then check for flash 2 or flash 3+.
      // Some version of Flash was found. Time to figure out which.
      // Set convenient references to flash 2 and the plugin description.
      isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? ' 2.0' : '';
      flashDescription = navigator.plugins["Shockwave Flash" + 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().
      TmpFlashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

      // 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.
      this.fVersion = TmpFlashVersion;
    }
  }
}

function FlashDetector() {
  this.fVersion = -1; //version du client
  this.fVer_min = 2; //numéro de la version mini
  this.fVer_max = 7; //numéro de la version maxi

  this.ua_IE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
  this.ua_WIN = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
  this.FlashDetect();
}
