/******************************************************************************************
*  Class flash_player
*  
*  // Constructeur : flash_player(movie, width, height);
*  				  @param	movie	: chemin_du_swf
*  				  @param	width	: largeur_du_swf
*  				  @param	movie	: hauteur_du_swf
*  
*  // function :
	flash_player->affiche();
*  	detect la présence de flash puis écrit le flash s'il flash est présent ou le message d'erreur dans le cas inverse
*  
*   flash_player->set_attribut(nom_attribut,valeur_attribut)
*  				@param	nom_attribut	: nom de l'attribut à modifier
*  				@param	valeur_attribut	: valeur de l'attribut à modifier
*  				nb : la liste des attributs modifiables ce trouve plus bas
*  
*  
*  // Exemple type : 
*  
*  		var un_flash_player = new flash_player(movie, width, height);
*  		un_flash_player.affiche();
*  
*  // Liste des attributs mofiable de la class :
*  
*  	//variable de la balise object ou embed
*  	movie, width, height, quality, loop, play, menu
*  	transparent // mettre a true pour rendre transparent le flash
*  
*  	requiredVersion // defini la version du player flash requit pour lire le swf (par defaut 7 )
*  	requiredRelease // defini la release du player flash requit pour lire le swf (par defaut 0 )
*  
*  	imageGetFlash // defini le chemin d'acces au picto getFlash (par defaut ../img/commun/get_flash_player.gif );
*  	
*  	class_css_erreur // class css du div qui entoure le message d'erreur (par defaut div-detection-flash)
*  	
*  	langue_erreur // langue du message d'erreur (par defaut fra)
*  	type_erreur // type du message d'erreur trois possibilité :
*  					aucun   : n'affiche pas le message d'erreur
*  					complet : affiche le message d'erreur de la langue defini par langue_erreur
*  					perso   : affiche le message d'erreur défini dans message_erreur
*  					picto_seul : affiche uniquement le picto avec le lien vers macromedia
*  
*  
*  	message_erreur // message d'erreur personnalisé
*  	moviename // id de la balise enmbed ou object par defaut le nom de swf
*  
*
*  //Ajout ou modification d'un message d'erreur d'une langue :
*  	//Ex pour changer le message rus:
*  	flash_player.prototype.affiche_erreur_rus = function (){
*  		//On met ce qu'on veux
*  	}
*  	//les langues fra et eng sont déjà defini mais peuvent être redéfini
*  
*  
*  Autre fonction utilie :
*  
*   force_flash_version(numero de version) // force la version du player installé
*   affiche_flash('nom_du_swf', 'sa taille' , 'sa hauteur'); // affiche simplement un swf
*   insert_flash_1(movie, width, height); // identique au précedent pour préserver la compatibilité avec l'ancien script.
*   affiche_flash_transparent(movie, width, height); // affiche simplement un swf avec fond transaprent
*  
****************************************************************************************/


// Function gardé pour rester compatible avec l'ancienne version du script
function insert_flash_1(movie, width, height){
	affiche_flash(movie, width, height)
}
//Appel rapide de la classe flash player
function affiche_flash(movie, width, height){
	var un_flash_player = new flash_player(movie, width, height);
	un_flash_player.affiche();
}
function affiche_flash_transparent(movie, width, height){
	var un_flash_player = new flash_player(movie, width, height);
	un_flash_player.set_attribut("transparent",true);
	un_flash_player.affiche();
}
var version_flash_force=false;
function force_flash_version(version){
	version_flash_force=version;	
}
function flash_player(movie, width, height){

	//variable balise object
	this.movie=movie;
	this.width=width;
	this.height=height;
	this.quality='high';
	this.loop='false';
	this.play='true';
	this.menu='false';
	this.transparent=false;

	//variable detecteur
	this.flashDescription='';
	this.actualVersion = 0;			// version the user really has  
	this.actualRelease = 0;

	this.requiredVersion=(version_flash_force ? version_flash_force : 7);
	this.requiredRelease=0;

	this.maxVersion = 9; 
	this.flashVersion = 0;

	this.imageGetFlash = '../img/commun/get_flash_player.gif';
	this.message_erreur='';
	this.class_css_erreur='div-detection-flash';
	this.type_erreur='complet';
	this.langue_erreur='fra';

	this.moviename=this.movie.substring(this.movie.lastIndexOf("/"),this.movie.length-4);
}
/*flash_player.prototype.get_version = function (){
	this.detect_flash(0, 0);
	return new Array(this.actualVersion,this.actualRelease);
}*/
flash_player.prototype.affiche_version = function(){
	alert("Flash Version Required : "+this.requiredVersion+"\nFlash Release Required : "+this.requiredRelease+"\nFlash Version : "+this.actualVersion+"\nFlash Release : "+this.actualRelease);
}
flash_player.prototype.set_attribut = function (nom_attribut,valeur_attribut){
	//alert(eval(this[un_attribut]));
	if ( this[nom_attribut] != "undefined" )
		this[nom_attribut]=valeur_attribut;
	else
		alert('L\'attribut "'+nom_attribut+'" n\'existe pas');
}
flash_player.prototype.affiche = function (){
	if (this.detect_flash())
		this.affiche_flash();
	else
		this.affiche_erreur();
}
flash_player.prototype.affiche_in_div = function (id){
	if (this.detect_flash())
		this.affiche_flash_in_div(id);
	else
		this.affiche_erreur();
}
flash_player.prototype.detect_flash = function (){

  var isVersion2='';
  var releaseTmp;

  // If navigator.plugins exists...
  if (navigator.plugins) {
    // ...then check for flash 2 or flash 3+.
    if (navigator.plugins["Shockwave Flash 2.0"]
        || navigator.plugins["Shockwave Flash"]) {
      // 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" : "";
      this.flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;

      this.flashVersion = parseInt(this.flashDescription.substring(16));
	  releaseTmp = this.flashDescription.split("r");
	  
	  this.actualRelease = parseInt(releaseTmp[releaseTmp.length-1]);

	  //alert("Flash plugin description: " + flashDescription );
      // 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.
	  flash1Installed = this.flashVersion == 1;  
      flash2Installed = this.flashVersion == 2;    
      flash3Installed = this.flashVersion == 3;
      flash4Installed = this.flashVersion == 4;
      flash5Installed = this.flashVersion == 5;
      flash6Installed = this.flashVersion == 6;
      flash7Installed = this.flashVersion == 7;
      flash8Installed = this.flashVersion == 8;
      flash9Installed = this.flashVersion >= 9;
    }
  }
  
  // Loop through all versions we're checking, and
  // set actualVersion to highest detected version.
  for (var i = 2; i <= this.maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) this.actualVersion = i;
  }
   
 // DEBUG
 // alert("Version detected: " + this.actualVersion + "\nRelease detected: " + this.actualRelease );

  if (this.actualVersion > this.requiredVersion || (this.actualVersion == this.requiredVersion && this.actualRelease >= this.requiredRelease) )
	return true;
  else
	return false;
}

flash_player.prototype.affiche_flash = function (){

	document.write( '<OBJECT ID="'+this.moviename+'" CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
	+ 'WIDTH="'+this.width+'" HEIGHT="'+this.height+'"'
	+ 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
	+ '<PARAM NAME="MOVIE" VALUE="'+this.movie+'" >'
	+ '<PARAM NAME="PLAY" VALUE="'+this.play+'" >'
	+ '<PARAM NAME="LOOP" VALUE="'+this.loop+'" >'
	+ '<PARAM NAME="QUALITY" VALUE="'+this.quality+'" >'
	+ '<PARAM NAME="MENU" VALUE="'+this.menu+'" >'
	+ (this.transparent?'<PARAM NAME="wmode" VALUE="transparent" >':'')
	+ '<EMBED NAME="'+this.moviename+'" ID="'+this.moviename+'" SRC="'+this.movie+'"'
	+ 'WIDTH="'+this.width+'" HEIGHT="'+this.height+'" '
	+ 'PLAY="'+this.play+'" '
	+ 'LOOP="'+this.loop+'" '
	+ (this.transparent?'WMODE="transparent" ':'')
	+ 'QUALITY="'+this.quality+'" '
	+ 'MENU="'+this.menu+'" '
	+ 'TYPE="application/x-shockwave-flash" '
	+ 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
	+ '<\/EMBED>'
	+ '<\/OBJECT>' );

}
flash_player.prototype.affiche_flash_in_div = function (id){
	document.getElementById(id).innerHTML = '<OBJECT ID="'+this.moviename+'" CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
	+ 'WIDTH="'+this.width+'" HEIGHT="'+this.height+'"'
	+ 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
	+ '<PARAM NAME="MOVIE" VALUE="'+this.movie+'" >'
	+ '<PARAM NAME="PLAY" VALUE="'+this.play+'" >'
	+ '<PARAM NAME="LOOP" VALUE="'+this.loop+'" >'
	+ '<PARAM NAME="QUALITY" VALUE="'+this.quality+'" >'
	+ '<PARAM NAME="MENU" VALUE="'+this.menu+'" >'
	+ (this.transparent?'<PARAM NAME="wmode" VALUE="transparent" >':'')
	+ '<EMBED NAME="'+this.moviename+'" ID="'+this.moviename+'" SRC="'+this.movie+'"'
	+ 'WIDTH="'+this.width+'" HEIGHT="'+this.height+'" '
	+ 'PLAY="'+this.play+'" '
	+ 'LOOP="'+this.loop+'" '
	+ (this.transparent?'WMODE="transparent" ':'')
	+ 'QUALITY="'+this.quality+'" '
	+ 'MENU="'+this.menu+'" '
	+ 'TYPE="application/x-shockwave-flash" '
	+ 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
	+ '<\/EMBED>'
	+ '<\/OBJECT>' ;

}
flash_player.prototype.affiche_erreur = function (){
	if(this.type_erreur=="aucun"){

	} else if(this.type_erreur=="picto_seul"){
		document.write('<div style="text-align:center;border:1px solid #CCCCCC; padding-top:'+(Math.ceil(this.height-31)/2)+'px;padding-bottom:'+(Math.round(this.height-31)/2)+'px;"><a href="http://www.macromedia.com/go/getflashplayer_fr" target="_blank"><img src="'+this.imageGetFlash+'" width="88" height="31" hspace="10" border="0" alt=""></a></div>');
	} else if (this.type_erreur=="complet") {
		this["affiche_erreur_"+this.langue_erreur]();
	} else if (this.type_erreur=="perso") {
		if (this.message_erreur!=""){
			document.write(this.message_erreur);
		} else {
			alert ('Type d\'erreur perso nécessite de definir la propriété : message_erreur !');
		}
	} else {
		alert ('Type d\'erreur inconnu !');
	}
}
//Debut script de détection
//
flash_player.prototype.affiche_erreur_eng = function() {
	document.write( '<div class="'+this.class_css_erreur+'"><span style="font-weight:normal;font-size: 11px;color: #000000;font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; line-height: 14px;">');
		 
	 if (this.actualVersion==0)
		document.write('You do not have the plugin Flash to view the animation.<br>You can download it free on the site of');
	 else
		document.write('Your plugin Flash isn\'t up to date to view the animation.<br>You can update it free on the site of ');
	 
	 document.write('<a href=\"http://www.macromedia.com/go/getflash" target=\"_blank\">Macromedia</a>.</span>');
	 document.write('<br><br><div style="text-align:center"><a href="http://www.macromedia.com/go/getflash" target="_blank"><img src="'+this.imageGetFlash+'" width="88" height="31" hspace="10" border="0" alt=""></a></div>');
	 
	 if (this.actualVersion!=0)
		document.write('<br><br><span align=\"center\" style=\"font-size: 9px;color: #000000;font-family:Trebuchet MS;\">Plugin version : '+this.flashDescription+'</span>');
}
flash_player.prototype.affiche_erreur_fra = function() {
	document.write( '<div class="'+this.class_css_erreur+'"><span style="font-weight:normal;font-size: 11px;color: #000000;font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; line-height: 14px;">');

	if (this.actualVersion==0)
		document.write('Vous ne disposez pas du plugin Flash pour visionner l\'animation.<br>Vous pouvez le t&eacute;l&eacute;charger gratuitement sur le site de ');
	else
		document.write('Votre plugin Flash n\'est pas &agrave; jour pour visionner l\'animation.<br>Vous pouvez le mettre à jour gratuitement sur le site de ');

	document.write('<a href=\"http://www.macromedia.com/go/getflashplayer_fr" target=\"_blank\">Macromedia</a>.</span>');
	document.write('<br><br><div style="text-align:center"><a style="display:inline;" href="http://www.macromedia.com/go/getflashplayer_fr" target="_blank"><img src="'+this.imageGetFlash+'" width="88" height="31" hspace="10" border="0" alt=""></a></div>');

	if (this.actualVersion!=0)
		document.write('<br><br><span align=\"center\" style=\"font-size: 9px;color: #000000;font-family:Trebuchet MS;\">Version plugin : '+this.flashDescription+'</span>');

	document.write('</div>\n');
}

// System globals
var flash1Installed = false;
var flash2Installed = false;    // boolean. true if flash 2 is installed
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false; 
var flash6Installed = false; 
var flash7Installed = false;    
var flash8Installed = false;    
var flash9Installed = false;    

var flashplayer_jsVersion = 1.0;            // the version of javascript supported

var flashplayer_isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var flashplayer_isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
flashplayer_jsVersion = 1.1;

// Write vbscript detection on ie win. IE on Windows doesn't support regular
// JavaScript plugins array detection.
if(flashplayer_isIE && flashplayer_isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
  document.write('flash10Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash"))) \n');
  document.write('<\/SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}