
function popup(url, nomFen){
	window.maFen=window.open(url,nomFen,'fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=550,height=600,top=0,left=0,true');
	window.maFen.focus();
}

function isNumeric(num){
	var exp = new RegExp("^[0-9-.]*$","g");
	return exp.test(num);
}


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 verifier 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 caracteres invalides,\nveuillez verifier 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 caracteres invalides,\nveuillez verifier la partie apres l\'arobase.');
				emailAddress.focus();
				return false;
			}
		}
		if(user.match(validUser)==null){
			alert('L\'adresse Email semble incorrecte,\nveuillez verifier 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 verifier la partie apres 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 verifier 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 verifier 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 verifier le suffixe du domaine.');
			emailAddress.focus();
			return false;
		}
		if(len<2){
			alert('L\'adresse Email semble incorrecte.');
			emailAddress.focus();
			return false;
		}
	}
	return true;
}



function check_form(){
	var deb="Vous devez renseigner ";
	
	if(document.getElementById('contact_nom').value==""){
		alert(deb+"votre nom.");
		document.getElementById("contact_nom").focus();
		return false;
	}
	
	if(document.getElementById('contact_email').value==""){
				alert(deb+"votre adresse email.");
		document.getElementById("contact_email").focus();
		return false;
	}
	
	if(!isEmail(document.getElementById("contact_email"))){
		return false;
	}
	
	if(document.getElementById('contact_sujet').value==""){
		alert(deb+"le sujet du message");
		document.getElementById("contact_sujet").focus();
		return false;
	}
	
	if(document.getElementById('contact_message').value==""){
		alert(deb+"le contenu du message");
		document.getElementById("contact_message").focus();
		return false;
	}
	
	return true;
	
}


function verif_commande_etape1(){
	var ind=0;
	var compt=0;
	var marqueur=0;
	
	while(ind==0){
		var champ=document.getElementById("champs"+compt)
		if(champ){
			if(champ.value!=0)
				if (!isNumeric(champ.value)){
					marqueur=2;
					champ.focus();
				}else{
					marqueur=1;
				}
			compt++;
		}else
			ind=1;
	}
	if(marqueur==0){
		alert("Vous devez commander au moins l'une des publications.");
		return false;
	}else if(marqueur==2){
		alert("Vous devez indiquer un chiffre.");
		return false;
	}
	return true;
}



function verif_commande_etape2(){
	var deb="Vous devez renseigner ";

	if(document.getElementById('commande_nom').value==""){
		alert(deb+"votre nom.");
		document.getElementById("commande_nom").focus();
		return false;
	}
	
	if(document.getElementById('commande_prenom').value==""){
		alert(deb+"votre prénom.");
		document.getElementById("commande_prenom").focus();
		return false;
	}
	
	if(document.getElementById('commande_email').value==""){
				alert(deb+"votre adresse email.");
		document.getElementById("commande_email").focus();
		return false;
	}
	
	if(!isEmail(document.getElementById("commande_email"))){
		return false;
	}
	
	if(document.getElementById('commande_adresse').value==""){
		alert(deb+"votre adresse");
		document.getElementById("commande_adresse").focus();
		return false;
	}
	
	if(document.getElementById('commande_code_postal').value==""){
		alert(deb+"votre code postal");
		document.getElementById("commande_code_postal").focus();
		return false;
	}
	
		if(document.getElementById('commande_ville').value==""){
		alert(deb+"votre ville");
		document.getElementById("commande_ville").focus();
		return false;
	}
	
	return true;
}

function verif_recherche(){
	
	if(document.getElementById('word').value==""){
		alert("Vous devez remplir le champ de recherche");
		document.getElementById("word").focus();
		return false;
	}
	
	return true;
}

