// JavaScript Document
function verifEmail(email) {
invalidMailChars = "/\?!()<^>àâèéêëîïôöùûç#%*µ¨£$,;:+{}'";
erreurMail=false;
//recherche des caractères contenus dans invalidChars	
for (i=0;i<invalidMailChars.length;i++){
if(email.indexOf(invalidMailChars.charAt(i))!=-1) {
erreurMail=true;
}
}
if  (email.indexOf(' ')!==-1 ) {erreurMail=true;} // si il n'y a un espace
if  (email.indexOf('.')==-1  || email.indexOf('@')==-1) {erreurMail=true;} // si il n'y a ni "@" ni "."
if  (email.indexOf('..')!==-1 || email.indexOf('@.')!==-1 || email.indexOf('.@')!==-1) {erreurMail=true;} // si il y a ".." ,".@","@."
if  (email.indexOf('@')!=email.lastIndexOf('@')) {erreurMail=true;} // si il y a plus de deux "@"
if ((email.indexOf('@')==0) || (email.indexOf('.')==0) || (email.lastIndexOf('@')==email.length-1) || (email.lastIndexOf('.')==email.length-1)) {erreurMail=true;} // si  "@" ou "." commencent ou finissent => si il n'y a que un "." ou un "@" ou ".@" ou "@."
if ((email.lastIndexOf('@')-email.lastIndexOf('.'))>1) {erreurMail=true;} // si le dernier "." est avant "@"
if (email.length-1-email.lastIndexOf('.')==1) {erreurMail=true;} // si le dernier "." est suivi d'un seul caractere
return erreurMail;		
}
function IsNumeric(strString)
//  check for valid numeric strings	
{
var strValidChars = "0123456789.-";
var strChar;
var blnResult = true;
if (strString.length == 0) return false;
//  test strString consists of valid characters listed above
for (i = 0; i < strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
{
blnResult = false;
}
}
return blnResult;
}
function validForm() {
error = "";
with(document.booking) {
if(name.value == "") {
error += " Your name is missing\n";
}
//EMAIL VALID
if(verifEmail(email.value)) {
error += " Your e-mail is not valid\n";
}
if(arrival.value == "") {
error += " Your arrival date is missing\n";
}
if(departure.value == "") {
error += " Your departure date is missing\n";
}
}
if(error!= "") {
error = "The form has errors in the following fields : \n"+error
alert(error);
return false;
} else {
document.booking.submit();
}
}
function validFormContactUs() {
error = "";
with(document.contactus) {
if(name.value == "") {
error += " Your name is missing\n";
}
//EMAIL VALID
if(verifEmail(email.value)) {
error += " Your e-mail is not valid\n";
}
}
if(error!= "") {
error = "The form has errors in the following fields : \n"+error
alert(error);
return false;
} else {
document.contactus.submit();
}
}


