// Flash Version Detector  v1.2.1
// documentation: http://www.dithered.com/javascript/flash_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
// with VBScript code from Alastair Hamilton (now somewhat modified)


function isDefined(property) {
  return (typeof property != 'undefined');
}

var flashVersion = 0;
function getFlashVersion() {
   var latestFlashVersion = 8;
   var agent = navigator.userAgent.toLowerCase(); 
   
   // NS3 needs flashVersion to be a local variable
   if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
      flashVersion = 0;
   }
   
   // NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
   if (navigator.plugins != null && navigator.plugins.length > 0) {
      var flashPlugin = navigator.plugins['Shockwave Flash'];
      if (typeof flashPlugin == 'object') { 
         for (var i = latestFlashVersion; i >= 3; i--) {
            if (flashPlugin.description.indexOf(i + '.') != -1) {
               flashVersion = i;
               break;
            }
         }
      }
   }

   // IE4+ Win32:  attempt to create an ActiveX object using VBScript
   else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
      var doc = '<scr' + 'ipt language="VBScript"\> \n';
      doc += 'On Error Resume Next \n';
      doc += 'Dim obFlash \n';
      doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
      doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
      doc += '   If IsObject(obFlash) Then \n';
      doc += '      flashVersion = i \n';
      doc += '      Exit For \n';
      doc += '   End If \n';
      doc += 'Next \n';
      doc += '</scr' + 'ipt\> \n';
      document.write(doc);
   }
      
   // WebTV 2.5 supports flash 3
   else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

   // older WebTV supports flash 2
   else if (agent.indexOf("webtv") != -1) flashVersion = 2;

   // Can't detect in all other cases
   else {
      flashVersion = flashVersion_DONTKNOW;
   }

   return flashVersion;
}

flashVersion_DONTKNOW = -1;

function FlashTagCodeManager(flashVersion, movieFilePath, movieWidth, movieHeight, tagId, localTextEvent, localTextLink){
	/**
	 *
	 */
	if(FlashTagCodeManager.arguments.length != FlashTagCodeManager.length) {
		document.write("Methode [FlashTagCodeManager] : "+FlashTagCodeManager.arguments.length+" paramètres ont été passés alors qu'il en faut "+FlashTagCodeManager.length);
		return false;
	}	
	// Champs obligatoires pour le tag object au cas ou le swf peut s'afficher correctement
	this.flashVersion = flashVersion;   // Version requise pour le SWF
	this.movieFilePath = movieFilePath; // Chemin du SWF
	this.movieWidth = movieWidth;       // Width du SWF
	this.movieHeight = movieHeight;     // Height du SWF
	this.tagId = tagId;                 // Id du SWF

	// Champs obligatoires pour le cas ou il faut télécharger le dernier player
	this.localTextEvent = localTextEvent; // Texte qui explique pourquoi il faut télécharger la dernière version
	this.localTextLink = localTextLink;   // Texte du lien pour télécharger


	// Champs faculatatifs pour le tag object au cas ou le swf peut s'afficher correctement
	this.tagAlign   = '';
	this.tagMenu    = 'false';
	this.tagQuality = 'high';
	this.tagBgColor ='#FFFFFF';

	// Champs faculatatifs pour le cas ou il faut télécharger le dernier player
	this.tableWidth     = 220;         // Largeur du tableau contenant le lien de téléchargement du dernier player
	this.cssNameLink    = 'mylancome'; // CSS du lien de téléchargement du dernier player
	this.topMargin      = 0;           // Espace au dessus du tableau contenant le lien de téléchargement du dernier player
	this.rightMargin    = 0;           // Espacea droite du tableau contenant le lien de téléchargement du dernier player
	this.bottomMargin   = 0;           // Espace en dessous du tableau contenant le lien de téléchargement du dernier player
	this.leftMargin     = 0;           // Espace a gauche du tableau contenant le lien de téléchargement du dernier player


	// METHODS
	this.init                = FlashTagCodeManagerInit;
	this.getFlashTagCode     = FlashTagCodeManagerGetFlashTagCode;
	this.getDownloadLinkCode = FlashTagCodeManagerGetDownloadLinkCode;

	// ADDITIONNAL METHODS pour le tag object au cas ou le swf peut s'afficher correctement
	this.setTagAlign         = new Function('tagAlign', 'this.tagAlign=tagAlign'); // modifie la valeur par défaut de l'attribut align du tab object
	this.setTagMenu          = new Function('tagMenu', 'this.tagMenu=tagMenu'); // modifie la valeur par défaut de l'attribut menu du tab object
	this.setTagQuality       = new Function('tagQuality', 'this.tagQuality=tagQuality'); // modifie la valeur par défaut de l'attribut quality du tab object
	this.setTagBgColor       = new Function('tagBgColor', 'this.tagBgColor=tagBgColor'); // modifie la valeur par défaut de l'attribut bgColor du tab object

	// ADDITIONNAL METHODS pour le cas ou il faut télécharger le dernier player
	this.setTableWidth   = new Function('tableWidth', 'this.tableWidth=tableWidth');
	this.setCssNameLink  = new Function('cssNameLink', 'this.cssNameLink=cssNameLink');
	this.setTopMargin    = new Function('topMargin', 'this.topMargin=topMargin');
	this.setRightMargin  = new Function('rightMargin', 'this.rightMargin=rightMargin');
	this.setBottomMargin = new Function('bottomMargin', 'this.bottomMargin=bottomMargin');
	this.setLeftMargin   = new Function('leftMargin', 'this.leftMargin=leftMargin');

}

function FlashTagCodeManagerInit(){
	/**
	 *
	 */
	var flashVersion = getFlashVersion();
	if (flashVersion >= this.flashVersion)
		document.write(this.getFlashTagCode());
	else
		document.write(this.getDownloadLinkCode(this.localTextEvent, this.localTextLink)); 

}

function FlashTagCodeManagerGetFlashTagCode() {

	var htmlCode = '<OBJECT	';
	htmlCode+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	htmlCode+=' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.flashVersion + ',0,0,0"';
	htmlCode+=' WIDTH="' + this.movieWidth + '"';
	htmlCode+=' HEIGHT="' + this.movieHeight + '"';
	htmlCode+=' id="' + this.tagId + '"';
	htmlCode+=' ALIGN="' + this.tagAlign + '">';
	htmlCode+='<PARAM NAME=movie VALUE="' + this.movieFilePath + '">';
	htmlCode+='<PARAM NAME=menu VALUE=' + this.tagMenu + '>';
	htmlCode+='<PARAM NAME=quality VALUE=' + this.tagQuality + '>';
	htmlCode+='<PARAM name=WMODE value=transparent>';
	htmlCode+='<param name=allowScriptAccess value=sameDomain >';
	htmlCode+='<PARAM NAME=bgcolor VALUE=' + this.tagBgColor + '>';
	htmlCode+='<EMBED allowscriptaccess="sameDomain" src="' + this.movieFilePath + '" menu=' + this.tagMenu + ' quality=' + this.tagQuality + ' bgcolor= ' + this.tagBgColor + ' WIDTH="' + this.movieWidth + '" HEIGHT="' + this.movieHeight + '" NAME="' + this.tagId + '" ALIGN="' + this.tagAlign + '" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';
	htmlCode+='</OBJECT>';

	return htmlCode;
}





function FlashTagCodeManagerGetDownloadLinkCode(){

	var htmlCode ='<table border="0" cellpadding="0" cellspacing="0" width="' + this.tableWidth + '">'; 

	htmlCode+='<tr><td colspan="3"><img src="/img/space.gif" height="' + this.topMargin + '" width="1" border="0"></td></tr>';

	htmlCode+='<tr>';
	htmlCode+='<td width="' + this.leftMargin + '"><img src="/img/space.gif" width="' + this.leftMargin + '" height="1" border="0"></td>';
	htmlCode+='<td><br/><br/>' + this.localTextEvent + '<br/><a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" class="' + this.cssNameLink + '">' + this.localTextLink  + '</a><br/></td>';
	htmlCode+='<td width="' + this.rightMargin + '"><img src="/img/space.gif" width="' + this.rightMargin + '" height="1" border="0"></td>';
	htmlCode+='</tr>';
	htmlCode+='</table>';
 
	htmlCode+='<br/>';

	htmlCode+='<table cellspacing="0" cellpadding="0" border="0" width="'+this.tableWidth+'">';
	htmlCode+='<tr>';
	htmlCode+='<td width="'+this.leftMargin+'"><img src="/img/space.gif" width="'+this.leftMargin+'" height="1" border="0"></td>';
	htmlCode+='<td><a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"><img src="/img/_en/_gb/pict_getflash.gif" border="0"></a></td>';
	htmlCode+='<td width="'+this.rightMargin+'"><img src="/img/space.gif" width="'+this.rightMargin+'" height="1" border="0"></td>';
	htmlCode+='</tr>';

	htmlCode+='<tr><td colspan="3"><img src="/img/space.gif" height="' + this.bottomMargin + '" width="1" border="0"></td></tr>';

	htmlCode+='</table>';

	htmlCode+='<br/>';

	return htmlCode;

}