function IsValidEmail(s){
	if(s == "") return false;
	var at = s.indexOf('@');
	if(at == -1) return false;
	if(at != s.lastIndexOf('@')) return false;
	var dot = s.indexOf('.', at+2);
	if(dot == -1) return false;
	if(dot != s.lastIndexOf('.')) return false;
	if(s.charAt(0) == '.' || s.charAt(s.Length-1) == '.' || s.charAt(at-1) == '.') return false;
	
	return true;
}

function Verif(){
	if(document.form.nom.value == ""){
		alert("Please enter your last name");
		document.form.nom.focus();
		return;
	}
	
	if(document.form.prenom.value == ""){
		alert("Please enter your first name");
		document.form.prenom.focus();
		return;
	}
	
	if(document.form.email.value == ""){
		alert("Please enter your email");
		document.form.email.focus();
		return;
	}
	
	if(!IsValidEmail(document.form.email.value)){
		alert("Your email is invalid");
		document.form.email.focus();
		return;
	}
	
	if(document.form.msg.value == ""){
		alert("Please enter your message");
		document.form.msg.focus();
		return;
	}
	
	if(document.form.cp.value != ""){
		var chkZ=1;
		for(i=0;i<document.form.cp.value.length;i++){
			if(document.form.cp.value.charAt(i) < "0" || document.form.cp.value.charAt(i) > "9") chkZ = -1;
			if(chkZ == -1){
				alert("Please enter a correct zip code");
				document.form.cp.focus();
				return;
			}
		}
	}
	
	if(document.form.tel.value != ""){
		var chkZ=1;
		for(i=0;i<document.form.tel.value.length;i++){
			if(document.form.tel.value.charAt(i) < "0" || document.form.tel.value.charAt(i) > "9") chkZ = -1;
			if(chkZ == -1){
				alert("Please enter a correct telephone number ");
				document.form.tel.focus();
				return;
			}
		}
	}
	
	if(document.form.fax.value != ""){
		var chkZ=1;
		for(i=0;i<document.form.fax.value.length;i++){
			if(document.form.fax.value.charAt(i) < "0" || document.form.fax.value.charAt(i) > "9") chkZ = -1;
			if(chkZ == -1){
				alert("Please enter a correct fax number");
				document.form.fax.focus();
				return;
			}
		}
	}
	
	document.form.submit();
}

