/////////////////////////////////////////////////
//Detection du plug-in Macromedia Flash
/////////////////////////////////////////////////


DetectVersion.IsFlash  = 0;
DetectVersion.IsFlash3 = 0;
DetectVersion.IsFlash4 = 0;
DetectVersion.IsFlash5 = 0;
DetectVersion.IsFlash6 = 0;
DetectVersion.IsFlash7 = 0;
DetectVersion.IsFlash8 = 0;
DetectVersion.IsFlash9 = 0;

if (!DetectVersion.IsMac)
  {
  document.writeln( '<' + 'SCRIPT LANGUAGE="VBScript">');
  document.writeln( 'Sub testFlash1()');
  document.writeln( 'on error resume next');
  document.writeln( 'DetectVersion.IsFlash3 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))');
  document.writeln( 'DetectVersion.IsFlash4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))');
  document.writeln( 'DetectVersion.IsFlash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))');
  document.writeln( 'DetectVersion.IsFlash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))');
  document.writeln( 'DetectVersion.IsFlash7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7")))');
  document.writeln( 'DetectVersion.IsFlash8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")))');
  document.writeln( 'DetectVersion.IsFlash9 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9")))');
  document.writeln( 'DetectVersion.IsFlash  = (DetectVersion.IsFlash3 or DetectVersion.IsFlash4 or DetectVersion.IsFlash5 or DetectVersion.IsFlash6 or DetectVersion.IsFlash7 or DetectVersion.IsFlash8 or DetectVersion.IsFlash9)');
  document.writeln( 'End Sub');
  document.writeln( '<' + '/SCRIPT>');
  }

if (DetectVersion.IsIEW&&!DetectVersion.IsOpera) {
    testFlash1();
}

DetectVersion.testFlash2 = function () {
    var numPlugins = navigator.plugins.length;
    if (numPlugins < 1) {
        return;
    }
    
    var plugin = null;
    var IsFlashPlug = null;
    var numTypes = null;
    var mimetype = null;
    
    var i = 0;
    var j = 0;
    
    for (i = 0; i < numPlugins; i++) {
        plugin = navigator.plugins[i];
        
        IsFlashPlug = plugin.description.indexOf("Flash")==-1?0:1;
        
        if (!IsFlashPlug) {
            continue;
        }
        
        DetectVersion.IsFlash3=plugin.description.indexOf("Flash 3")==-1?0:1;
        DetectVersion.IsFlash4=plugin.description.indexOf("Flash 4")==-1?0:1;
        DetectVersion.IsFlash5=plugin.description.indexOf("Flash 5")==-1?0:1;
        DetectVersion.IsFlash6=plugin.description.indexOf("Flash 6")==-1?0:1;
        DetectVersion.IsFlash7=plugin.description.indexOf("Flash 7")==-1?0:1;
        DetectVersion.IsFlash8=plugin.description.indexOf("Flash 8")==-1?0:1;
        DetectVersion.IsFlash9=plugin.description.indexOf("Flash 9")==-1?0:1;
         
        numTypes = plugin.length;
        for (j = 0; j < numTypes; j++) {
            mimetype = plugin[j];
            if (mimetype) {
                continue;
            }
            
            if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") != -1)) {
                DetectVersion.IsFlash = 1;
            }
            if (navigator.mimeTypes["application/x-shockwave-flash"] == null) {
                DetectVersion.IsFlash = 0;
            }
        }
   }

}


if ((DetectVersion.IsNS||DetectVersion.IsOpera||DetectVersion.IsIE5M||DetectVersion.IsSafM) && navigator.plugins) {
    DetectVersion.testFlash2();
}

// alert de test
DetectVersion.FlashVersion = 0;

if (DetectVersion.IsFlash3) {
    DetectVersion.FlashVersion = 3;
}
if (DetectVersion.IsFlash4) {
    DetectVersion.FlashVersion = 4;
}
if (DetectVersion.IsFlash5) {
    DetectVersion.FlashVersion = 5;
}
if (DetectVersion.IsFlash6) {
    DetectVersion.FlashVersion = 6;
}
if (DetectVersion.IsFlash7) {
    DetectVersion.FlashVersion = 7;
}
if (DetectVersion.IsFlash8) {
    DetectVersion.FlashVersion = 8;
}
if (DetectVersion.IsFlash9) {
    DetectVersion.FlashVersion = 9;
}


DetectVersion.getFlashTestResult = function () {
    var result = '';
    
    result  = "Resultat de la detection :\n\n"
    result += "IsFlash : "+IsFlash+"\n";
    result += "IsFlash3 : "+IsFlash3+"\n";
    result += "IsFlash4 : "+IsFlash4+"\n";
    result += "IsFlash5 : "+IsFlash5+"\n";
    result += "IsFlash6 : "+IsFlash6+"\n";
    result += "IsFlash7 : "+IsFlash7+"\n";
    result += "IsFlash8 : "+IsFlash8+"\n";
    result += "IsFlash9 : "+IsFlash9+"\n";
    result += "FlashVersion : "+FlashVersion;
    
    return result;
}

//alert (DetectVersion.getFlashTestResult);

DetectVersion.FlashShowOk=0;

DetectVersion.putFlash = function (swf, width, height) {
    DetectVersion.FlashShowOk=1;
    
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="total"  width="'+width+'" height="'+height+'">');
    document.write('<param name="movie" value="'+swf+'">');
    document.write('<param name="loop" value="true">');
    document.write('<param name="quality" value="high">');
    document.write('<param name="scale" value="showall">');
    document.write('<embed src="'+swf+'" scale="showall" loop="true" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="'+width+'" height="'+height+'">');
    document.write('</object>');
}

