// JavaScript Document
// FlashDetect.installed = 2 : Flash is installed
// FlashDetect.installed = 1 : Flash is not installed
// FlashDetect.installed = 0 : uncertain if Flash is installed
// FlashDetect.version = 0: not installed, -1: unknown, n: version number

var FlashDetect = {
	init: function () {
		this.installed = 0;
		this.version = -1;
		this.versionString = "Je ne peux détecter si Flash Player est installé";

		if (navigator.plugins && navigator.plugins.length)
		{
			x = navigator.plugins["Shockwave Flash"];
			if (x)
			{
				this.installed = 2;
				if (x.description)
				{
					y = x.description;
					var descArray = x.description.split(" ");
					var tempArrayMajor = descArray[2].split(".");			
					this.version = tempArrayMajor[0];
					//this.version = y.charAt(y.indexOf('.')-1);
				}
			}
			else
				this.installed = 1;
			if (navigator.plugins["Shockwave Flash 2.0"])
			{
				this.installed = 2;
				this.version = 2;
			}
		}
		else if (navigator.mimeTypes && navigator.mimeTypes.length)
		{
			x = navigator.mimeTypes['application/x-shockwave-flash'];
			if (x && x.enabledPlugin)
				this.installed = 2;
			else
				this.installed = 1;
		}
		else
		{
			// IE flash detection.
			this.installed = 1;
			for (var i=100; i>0; i--)
			{
				try 
				{
					this.flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
					this.version = i;
					this.installed = 2;
					this.versionString = "Flash Player version " + this.version + " est installé";
					return;
				}
				catch(e)
				{
				}
			}
		}


		// Set versionString
		if (this.installed == 2)
		{
			if (this.version > 0 )
				this.versionString = "Flash Player version " + this.version + " est installé";
			else
				this.versionString = "Je ne peux détecté quelle version de Flash Player est insttallée";
		}
		else if (this.installed == 1) this.versionString = "Flash Player n'est pas installé";
		else this.versionString = "Je ne peux détecter si Flash Player est installé";

	}
};


/*
FlashDetect.init();
FlashDetect.installed;
FlashDetect.version;
FlashDetect.versionString;
*/

function MM_CheckFlashVersion(reqVerStr){
  with (navigator)
  	{
	var verArr = reqVerStr.split(",");
	var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
	if 	(FlashDetect.version == -1)
		{
		// unknown if installed or what version
		}
	else if (FlashDetect.version < reqVer)
		{
		// installed but version too low
		msg = "Le contenu vidéo de cette page requiert Flash Player version "
		+ reqVer + " et vous avez la version " + FlashDetect.version + ".\n"
		+ "Désirez-vous télécharger et installer la version requise maintenant ?\n"
		+ "(Vous devez avoir des droits d'administrateur pour faire cela.)";
		if 	(confirm(msg))
		window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
		}
    	
  	} 
}