  /**
   * Derived from Apple's suggested sniffer.
   * @param {String} desc e.g. Shockwave Flash 7.0 r61
   * @return {String} 7.0.61
   */
   	var LumiereDiv = document.getElementById('Lumiere');
	LumiereDiv.style.display = "none";
	
function getVersionFlash() { 

  function getFlashVersion(desc) {
    var matches = desc.match(/[\d]+/g);
    matches.length = 3;  // To standardize IE vs FF
	var resultfv = matches.join('.');
    return resultfv;
	//console.log('ext :'+resultfv);
  }

  var hasFlash = false;
  var flashVersion = '';
 
     var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
    hasFlash = mimeType && mimeType.enabledPlugin;
    if (hasFlash) {
      flashVersion = getFlashVersion(mimeType.enabledPlugin.description);
	 // console.log('flashversion :'+flashVersion);
    }
	  //  var plugin = navigator.plugins['Shockwave Flash'];
	

	
	if (flashVersion) { return flashVersion; }
		else {// return "rien du tout";
	
//	return "pouet";

	try { var ax  = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); 
	if (ax) { throw "bon"; } else { throw "pasbon"; } 
	}
	
	catch(e) {
		if (e=="bon") {
    // Try 7 first, since we know we can use GetVariable with it
      var ax7 = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
	 var ax6 = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
	  var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
		
      hasFlash = true;
      flashVersion = getFlashVersion(ax.GetVariable('$version'));
	  flashVersion7 = getFlashVersion(ax7.GetVariable('$version'));
	  flashVersion6 = '6.0.21';
	  
	  if (flashVersion) {
		  return flashVersion;
	  }
	  else {	 
	  			if(flashVersion7) {
									return flashVersion7;  
	  								}
									else { if (flashVersion6) {
											return flashVersion6;	
											}
									}
				  }
		}
	}
	///fini du else
		}

}

var resultat = document.getElementById('avertissementflash');
//console.log(resultat);

//var test = getVersionFlash();
var test = getVersionFlash();

if (test) {
var reg=new RegExp("[.]+", "g");
var versionget = test.split(reg);

//console.log(versionget);

//console.log('test:'+ test);
if( versionget[0]<= 9) { 
resultat.innerHTML= "Mettez à niveau votre lecteur et passez à Flash Player 10 pour pouvoir visualiser les vidéos de la TricTrac TV de façon optimales. <a href='http://www.adobe.com/go/getflashplayer/'>Mettre à niveau maintenant.</a>  (Ceci est un conseil amical de la TTTeam.)";
resultat.style.display = 'block';
}

}

function RemoveAllChilds(target,decalage){
	if( !decalage ){ decalage = 0 ; }
	if(target != undefined){
		while(target.childNodes.length>=(decalage+1)){
		target.removeChild(target.childNodes[decalage]);
		}
	}
}

function thisMovie(movieName) {
         if (navigator.appName.indexOf("Microsoft") != -1) {
             return window[movieName];
         } else {
             return document[movieName];
         }
     }


function VerifLumiere() {
	
		var LumiereDiv = document.getElementById('Lumiere');
		var FlashDiv = document.getElementById("FlashID");
	switch (LumiereDiv.style.display) {
		case "none":

			break;
		case "block":
			console.log(document.getElementById("FlashID"));

			thisMovie("FlashID").sendToActionScript({type:"LumiereVerif",arg1:true});

		
			break;
		default: return "error";
		
		
	}
	
}

function CinemaMode(modeselect) {
	var LumiereDiv = document.getElementById('Lumiere');
/*
	switch (modeselect) {
		case "on":
			LumiereDiv.style.display = "none"; 
			break;
		case "off":
			LumiereDiv.style.display = "block"; 
			break;
		default: LumiereDiv.style.display = "none";

	}
	
	*/
	var opacitytab = new Array();
	opacitytab = [ "0", "0.20", "0.40", "0.60", "0.80", "0.9" ];
	
	LumiereDiv.onclick = function() {
		//console.log(LumiereDiv);
			//RemoveAllChilds(LumiereDiv, 0);	
		//LumiereDiv.style.display = "none";
//		LumiereDiv.style.opacity = 0;
						var i = 6;
				var intervalEteindre = function() {

				LumiereDiv.style.opacity = opacitytab[i];
					if (i==0) {
						LumiereDiv.style.display = "none";
						clearInterval(EteindreOn);
					}
					i--;
				//	console.log(i);
				
				
				}
				 VerifLumiere();
				var EteindreOn = setInterval(intervalEteindre, 100);
				
		
	}
	

	
	if (LumiereDiv.style.display == "none") {
		LumiereDiv.style.display = "block";
		LumiereDiv.style.position = "fixed";
		LumiereDiv.style.height = "100%";
		LumiereDiv.style.width = "100%";
		LumiereDiv.style.backgroundColor = "#000000";
		LumiereDiv.style.zIndex = "998";
		LumiereDiv.style.left = "0";
		LumiereDiv.style.top = "0";
		
		var i = 0;
		var intervalAllumer = function() {
			
		LumiereDiv.style.opacity = opacitytab[i];
		if (i==6) {
				LumiereDiv.style.display = "block";
				clearInterval(AllumerOn);
			}
			i++;
		//	console.log(i);
		}
		var AllumerOn = setInterval(intervalAllumer, 100);

	}
	else {
			if (LumiereDiv.style.display == "block") {
					LumiereDiv.style.position = "fixed";
				LumiereDiv.style.height = "100%";
				LumiereDiv.style.width = "100%";
				LumiereDiv.style.backgroundColor = "#000000";
				LumiereDiv.style.zIndex = "998";
				LumiereDiv.style.left = "0";
				LumiereDiv.style.top = "0";
				
				var i = 6;
				var intervalEteindre = function() {
			
					LumiereDiv.style.opacity = opacitytab[i];
					if (i==0) {
						LumiereDiv.style.display = "none";
						clearInterval(EteindreOn);
					}
					i--;
				//	console.log(i);
				}
				var EteindreOn = setInterval(intervalEteindre, 100);
			
			}
	}
}
