function getFlashVersion(){ 
  try { 
    try { 
      // avoid fp6 minor version lookup issues 
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
      try { axo.AllowScriptAccess = 'always'; } 
      catch(e) { return '6,0,0'; } 
    } catch(e) {} 
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
  // other browsers 
  } catch(e) { 
    try { 
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; 
      } 
    } catch(e) {} 
  } 
  return '0,0,0'; 
} 

// Ouvre une popup	
function popup(url, nomFen){
	window.open(url,nomFen,'fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=561,height=570,top=0,left=0,true');
}

//Vérifie que l'email entré est valable

function isEmail(emailAddress){
	emailAddressValue=emailAddress.value.toLowerCase();
	var 			countryTLDs=/^(ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$/;
	var gTLDs=/^(aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org)$/;
	var basicAddress=/^(.+)@(.+)$/;
	var specialChars='\\(\\)><@,;:\\\\\\\"\\.\\[\\]';
	var validChars='\[^\\s'+specialChars+'\]';
	var validCharset='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\'-_.';
	var quotedUser='(\"[^\"]*\")';
	var atom=validChars+'+';
	var word='('+atom+'|'+quotedUser+')';
	var validUser=new RegExp('^'+word+'(\.'+word+')*$');
	var symDomain=new RegExp('^'+atom+'(\.'+atom+')*$');
	var matchArray=emailAddressValue.match(basicAddress);
	if(emailAddress.value==''||emailAddress==null){
		return true;
	}
	if(matchArray==null){
		alert('L\'adresse Email semble incorrecte,\nveuillez vérifier la syntaxe.');
		emailAddress.focus();
		return false;
	}else{
		var user=matchArray[1];
		var domain=matchArray[2];
		for(i=0;i<user.length;i++){
			if(validCharset.indexOf(user.charAt(i))==-1){
				alert('L\'adresse Email contient des caractères invalides,\nveuillez vérifier la partie avant l\'arobase.');
				emailAddress.focus();
				return false;
			}
		}
		for(i=0;i<domain.length;i++){
			if(validCharset.indexOf(domain.charAt(i))==-1){
				alert('L\'adresse Email contient des caractères invalides,\nveuillez vérifier la partie après l\'arobase.');
				emailAddress.focus();
				return false;
			}
		}
		if(user.match(validUser)==null){
			alert('L\'adresse Email semble incorrecte,\nveuillez vérifier la partie avant l\'arobase.');
			emailAddress.focus();
			return false;
		}
		var atomPat=new RegExp('^'+atom+'$');
		var domArr=domain.split('.');
		var len=domArr.length;
		for(i=0;i<len;i++){
			if(domArr[i].search(atomPat)==-1){
				alert('L\'adresse Email semble incorrecte,\nveuillez vérifier la partie après l\'arobase.');
				emailAddress.focus();
				return false;
			}
		}
		if((domArr[domArr.length-1].length==2)&&(domArr[domArr.length-1].search(countryTLDs)==-1)){
			alert('L\'adresse Email semble incorrecte,\nveuillez vérifier le suffixe du domaine.');
			emailAddress.focus();
			return false;
		}
		if((domArr[domArr.length-1].length>2)&&(domArr[domArr.length-1].search(gTLDs)==-1)){
			alert('L\'adresse Email semble incorrecte,\nveuillez vérifier le suffixe du domaine.');
			emailAddress.focus();
			return false;
		}
		if((domArr[domArr.length-1].length<2)||(domArr[domArr.length-1].length>6)){
			alert('L\'adresse Email semble incorrecte,\nveuillez vérifier le suffixe du domaine.');
			emailAddress.focus();
			return false;
		}
		if(len<2){
			alert('L\'adresse Email semble incorrecte.');
			emailAddress.focus();
			return false;
		}
	}
	return true;
}


// Vérifie que tous les champs requis du formulaire inscription sont remplis

function validForm_inscription(){
	var deb = "Vous devez remplir ";
	var fin = " pour pouvoir jouer.";
	
	if(document.getElementById("civilite").value == ""){
   		alert(deb+"le champ CIVILITE"+fin);
   		document.getElementById("civilite").focus();
   		return false;
 	}
	
 	if(document.getElementById("nom").value == ""){
   		alert(deb+"le champ NOM"+fin);
   		document.getElementById("nom").focus();
   		return false;
 	}
 	if(document.getElementById("prenom").value == ""){
 		alert(deb+"le champ PRENOM"+fin);
 		document.getElementById("prenom").focus();
   		return false;
 	}
	if(document.getElementById("email").value==""){
		alert(deb+"le champ EMAIL"+fin);
   		document.getElementById("email").focus();
   		return false;
	}	
	if(!isEmail(document.getElementById("email"))){
  		return false;
  	}
	
  	if(document.getElementById("reglement").checked == false){
  		alert("Vous devez accepter le règlement"+fin);
  		return false;
  	}
	
	if(document.getElementById("userCode").value == ""){
 		alert(deb+"le code de securite"+fin);
 		document.getElementById("userCode").focus();
   		return false;
 	}
}



function validForm_parr(){
	var deb = "Vous devez remplir ";
	var fin = " pour pouvoir jouer.";
	
 	if(document.getElementById("email_ami1").value=="" && document.getElementById("email_ami2").value=="" && document.getElementById("email_ami3").value==""){
		alert("Vous devez indiquer au moins une adresse mail à parrainer");
   		document.getElementById("email_ami1").focus();
   		return false;
	}
	
	if(document.getElementById("email_ami1").value!=""){	
		if(!isEmail(document.getElementById("email_ami1"))){
			return false;
		}
	}
	
	if(document.getElementById("email_ami2").value!=""){	
		if(!isEmail(document.getElementById("email_ami2"))){
			return false;
		}
	}
	
	if(document.getElementById("email_ami3").value!=""){	
		if(!isEmail(document.getElementById("email_ami3"))){
			return false;
		}
	}
}