//Formulaire pop-up window

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}





//Formulaire email francais validation

function validatemailformfr() {

	if (document.frmmailfr.Nom.value=="") {
		alert("Veuillez entrer votre nom !");
		document.frmmailfr.Nom.focus();
		return false;
	}


	if (emailCheck(document.frmmailfr.Courriel.value) == false ) {
		return false;
	}

}

function emailCheck (emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
    	alert("Veuillez entrer une adresse de courriel valide !")
		document.frmmailfr.Courriel.focus();
		return false;
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null) {
    	alert("Veuillez entrer une adresse de courriel valide !")
		document.frmmailfr.Courriel.focus();
    	return false;
	}

	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
	  	for (var i=1;i<=4;i++) {
	    	if (IPArray[i]>255) {
	        	alert("Veuillez entrer une adresse de courriel valide !")
				document.frmmailfr.Courriel.focus();
				return false;
	    	}
    	}
    	return true;
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("Veuillez entrer une adresse de courriel valide !")
		document.frmmailfr.Courriel.focus();
    	return false;
	}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 ||
    		domArr[domArr.length-1].length>3) {
   		alert("Veuillez entrer une adresse de courriel valide !");
		document.frmmailfr.Courriel.focus();
   		return false;
	}
	if (len<2) {
   		var errStr="Veuillez entrer une adresse de courriel valide !"
		document.frmmailfr.Courriel.focus();
   		alert(errStr);
   		return false;
	}

	if (document.frmmailfr.Sujet.value=="") {
		alert("Veuillez entrer le sujet de votre message !");
		document.frmmailfr.Sujet.focus();
		return false;
	}

	if (document.frmmailfr.Message.value=="") {
		alert("Veuillez entrer votre message !");
		document.frmmailfr.Message.focus();
		return false;
	}

return true;

}










//Formulaire email english validation

function validatemailformen() {

	if (document.frmmailen.Name.value=="") {
		alert("Please, enter your name!");
		document.frmmailen.Name.focus();
		return false;
	}


	if (emailCheck2(document.frmmailen.Email.value) == false ) {
		return false;
	}

}

function emailCheck2 (emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
    	alert("Please, enter a valid email address!")
		document.frmmailen.Email.focus();
		return false;
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null) {
    	alert("Please, enter a valid email address!")
		document.frmmailen.Email.focus();
    	return false;
	}

	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
	  	for (var i=1;i<=4;i++) {
	    	if (IPArray[i]>255) {
	        	alert("Please, enter a valid email address!")
				document.frmmailen.Email.focus();
				return false;
	    	}
    	}
    	return true;
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("Please, enter a valid email address!")
		document.frmmailen.Email.focus();
    	return false;
	}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 ||
    		domArr[domArr.length-1].length>3) {
   		alert("Please, enter a valid email address!");
		document.frmmailen.Email.focus();
   		return false;
	}
	if (len<2) {
   		var errStr="Please, enter a valid email address!"
		document.frmmailen.Email.focus();
   		alert(errStr);
   		return false;
	}

	if (document.frmmailen.MySubject.value=="") {
		alert("Please, enter a subject!");
		document.frmmailen.MySubject.focus();
		return false;
	}

	if (document.frmmailen.Message.value=="") {
		alert("Please, enter your message!");
		document.frmmailen.Message.focus();
		return false;
	}

return true;

}