/****************************************************
 
	jonathan's early isMail script
 

 
	Pass a candidate string in 'candidate' and the function
 
	will return 'true' if the candidate appears to conform
 
	to a standard e-mail or 'false' otherwise.
 

 
	2000/02/20
 
****************************************************/
 

 
function isEmail( candidate) {
 
	var AtSym  = candidate.indexOf('@');
 
	var Period = candidate.lastIndexOf('.');
 
	var Space  = candidate.indexOf(' ');
 
	var Length = candidate.length -1;    // Array is from 0 to length-1
 

 
	if ((AtSym < 1) ||                   // '@' cannot be in first position
 
    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
 
    (Period == Length ) ||             // Must be atleast one valid char after '.'
 
    (Space  != -1))                    // No empty spaces permitted
 
   {  
 
      return false;
 
   }
 
return true;
 
}
 

 
/****************************************************
 
	generic functions
 
****************************************************/
 
function isDigits(str) {
 
	var i
 
	for (i = 0; i < str.length; i++) {
 
		mychar = str.charAt(i)
 
		if (mychar < "0" || mychar > "9")
 
			return false
 
	}
 
	return true
 
}
 

 
function isNumber(str) {
 
	numdecs = 0
 
	for (i = 0; i < str.length; i++) {
 
		mychar = str.charAt(i)
 
		if ((mychar >= "0" && mychar <= "9") || mychar 
 
			== ".") {
 
			if (mychar == ".")
 
				numdecs++
 
		}
 
		else 
 
			return false
 
	}
 
	if (numdecs > 1)
 
		return false	
 
return true
 
}
 

 
/* This takes a number with (possibly) a comma
 
and replaces it with a period  */
 

 
function isFrenchDecimal( source) {
 
	 var target="";
 
	for (i=0; i< source.length; i++) {
 
		tempChar = source.charAt( i);
 
		if (tempChar ==",") {
 
			tempChar=".";
 
		} else if (tempChar< "0") {
 
			return "";
 
		} else if (tempChar> "9") {
 
			return "";
 
		} 
 
		
 
		target = target +tempChar;
 

 
	}       
 
	return target;   
 
}
 

 
/****************************************************
 
	function isLogin
 

 
	Pass a candidate string in 'candidate' and the function
 
	will return 'true' if the candidate appears to contain
 
	between 5 and 8 letters or numbers and no punctuation.
 

 
 JM - 2001/02/21
 
****************************************************/
 

 
function isLogin( candidate) {
 
	var Length = candidate.length -1 ;				// Array is from 0 to length-1
 
	var i;
 
																						// now do testing
 
	if ((Length<4) || (Length>7)) {						// out of range?
 
		return false;
 
	} else {
 
	// is it a number
 
		for (i=0;i<Length; i++) {									// loop through string
 
			myChar = candidate.charAt(i)						// get the char
 
			if (myChar < "0" || myChar > "9") { 		// test for number
 
				if (myChar < "a" || myChar > "z") {		// failed! so text for char
 
					if (myChar < "A" || myChar > "Z") {	// failed so text for upperchar
 
						return false;
 
					}
 
				}				
 
			}
 
		}
 
	
 
	}
 
	return true;
 
}
 

 
/****************************************************
 
 function Verif
 
 designed to test forms for the wavin geothermie site
 
 
 
 There are 2 types of verification:
 
 - fields that must be filled, and filled correctly
 
 - fields that, if filled, must be filled correctly
 
 
 
 If a incorrectly filled field, or an empty obligatory
 
 field, is detected then the function should inform
 
 the visitor, and then set the focus to the field.
 

 
 JM - 2001/02/21
 
****************************************************/
 
 
 
function verifAccess() {
 

 
// ------------ get all fields ----------- //
 
	FirstName  = document.forms[0].prenom.value;
 
	LastName   = document.forms[0].nom.value;
 
	Address    = document.forms[0].adresse.value;
 
	PostCode   = document.forms[0].code_postal.value;
 
	Town       = document.forms[0].ville.value;
 
	Email      = document.forms[0].email.value;
 
	Siret      = document.forms[0].siret.value;
 
	Ape        = document.forms[0].ape.value;
 
	Profession = document.forms[0].profession.value;
	
	Firm       = document.forms[0].entreprise.value;
	
	Identify   = document.forms[0].loginpro.value;
 

 
// ------------ test fields ---------------//
 
	if (FirstName==""){
 
			window.alert('Veuillez remplir le champ : Prénom.');
 
			document.forms[0].prenom.focus();
 
			return false;
 
	}
 

 
	if (LastName==""){
 
			window.alert('Veuillez remplir le champ : Nom.');
 
			document.forms[0].nom.focus();
 
			return false;
 
	}
 

 
	if (Address==""){
 
			window.alert('Veuillez remplir le champ : Adresse.');
 
			document.forms[0].adresse.focus();
 
			return false;
 
	}
 

 
	if (PostCode==""){
 
			window.alert('Veuillez remplir le champ : Code Postal.');
 
			document.forms[0].code_postal.focus();
 
			return false;
 
	}
 

 
	if (Town==""){
 
			window.alert('Veuillez remplir le champ : Ville.');
 
			document.forms[0].ville.focus();
 
			return false;
 

	}
 

 
	if (Email==""){
 
			window.alert('Veuillez remplir le champ : email.');
 
			document.forms[0].ville.focus();
 
			return false;
 

	}
 

 
	if (Siret==""){
 
			window.alert('Veuillez remplir le champ : SIRET.');
 
			document.forms[0].siret.focus();
 
			return false;
 
	}
 

 
	if (Ape==""){
 
			window.alert('Veuillez remplir le champ : APE.');
 
			document.forms[0].ape.focus();
 
			return false;
 
	}
	

 
	if (Firm==""){
 
			window.alert('Veuillez remplir le champ : Entreprise.');
 
			document.forms[0].Entreprise.focus();
 
			return false;
 

	}
 

 
	// ----- test for valid e-mail, if exists ------- //
 
	if (Email!="") {
 
		if (!isEmail(Email)) {
 
				window.alert('Veuillez remplir le correctement le champ : E-mail.');
 
				document.forms[0].email.focus();
 
				return false;
 
		}
 
	}
 

 
	// ----- test for valid login -------------------- //
 
	if (Identify=="" || !isLogin(Identify)) {
 
			window.alert('Le champ Identifiant doit contenir entre 5 et 8 lettres ou chiffres, sans signes de ponctuation.');
 
			document.forms[0].loginpro.focus();
 
			return false;
 
	}
 

 
return true;
 
}
 

 
/****************************************************
 
 function verif
 
 designed to test forms for the wavin geothermie site
 
 
 
 There are 2 types of verification:
 
 - fields that must be filled, and filled correctly
 
 - fields that, if filled, must be filled correctly
 
 
 
 If a incorrectly filled field, or an empty obligatory
 
 field, is detected then the function should inform
 
 the visitor, and then set the focus to the field.
 

 
 JM - 2001/02/21
 
****************************************************/
 

 
function verifDemande() {
 

 
// ------------ get all relevant fields ----------- //
 
	FirstName  = document.forms[0].prenom.value;
 
	LastName   = document.forms[0].nom.value;
 
	Address    = document.forms[0].adresse.value;
 
	PostCode   = document.forms[0].code_postal.value;
 
	Town       = document.forms[0].ville.value;
 
	Email      = document.forms[0].email.value;
 
// ------------ test fields ---------------//
 
	if (FirstName==""){
 
			window.alert('Veuillez remplir le champ : Prénom.');
 
			document.forms[0].prenom.focus();
 
			return false;
 
	}
 

 
	if (LastName==""){
 
			window.alert('Veuillez remplir le champ : Nom.');
 
			document.forms[0].nom.focus();
 
			return false;
 
	}
 

 
	if (Address==""){
 
			window.alert('Veuillez remplir le champ : Adresse.');
 
			document.forms[0].adresse.focus();
 
			return false;
 
	}
 

 
	if (PostCode==""){
 
			window.alert('Veuillez remplir le champ : Code Postal.');
 
			document.forms[0].code_postal.focus();
 
			return false;
 
	}
 

 
	if (Town==""){
 
			window.alert('Veuillez remplir le champ : Ville.');
 
			document.forms[0].ville.focus();
 
			return false;
 
	}
 

 
	if (Email==""){
 
			window.alert('Veuillez remplir le champ : email.');
 
			document.forms[0].ville.focus();
 
			return false;
 
	}
 

 

	// ----- test for valid e-mail, if exists ------- //
 
	if (Email!="") {
 
		if (!isEmail(Email)) {
 
				window.alert('Veuillez remplir le correctement le champ : E-mail.');
 
				document.forms[0].email.focus();
 
				return false;
 
		}
 
	}
 
	return true;
 
}
 

 
/****************************************************
 
 function verif
 
 designed to test forms for the wavin geothermie site
 
 
 
 There are 2 types of verification:
 
 - fields that must be filled, and filled correctly
 
 - fields that, if filled, must be filled correctly
 
 
 
 If a incorrectly filled field, or an empty obligatory
 
 field, is detected then the function should inform
 
 the visitor, and then set the focus to the field.
 

 
 JM - 2001/02/21
 
****************************************************/
 

 
function verifPro() {
 

 
// ------------- get all relevant fields --------------//
 
	SurfaceHab			= document.forms[0].surf_hab_chauffee.value;
 
	NbNiveaux				= document.forms[0].nb_niveaux.value;
 
	HautSsPlafond		= document.forms[0].haut_ss_plaf.value;		// float
 
	SurfChaufferie	= document.forms[0].surf_chaufferie.value;
 
	SurfGarage			= document.forms[0].surf_garage.value;
 
	EpaissIsoVert		= document.forms[0].epaiss_iso_vert.value;
 
	EpaissIsoSols		= document.forms[0].epaiss_iso_sols.value;
 
	EpaissIsoPlaf		= document.forms[0].epaiss_iso_plaf.value;
 
	NbPersonnes			= document.forms[0].nb_personnes.value;
 
	NbDouches				= document.forms[0].nb_douches.value;
 
	NbBaignoires		= document.forms[0].nb_baignoires.value;
 
	NbBalneos				= document.forms[0].nb_balneos.value;
 
	SurfPiscine			= document.forms[0].surf_piscine.value;
 
	SurfTerrain			= document.forms[0].surf_terrain.value;
 
	Altitude				= document.forms[0].altitude.value;
 
// ------------- test fields if exists ------------------//
 

 

 
	if (SurfaceHab !="") {
 
		if (!isDigits(SurfaceHab)) {
 
				window.alert('Le champ \'Surface Habitable Chauffée\' ne peut contenir que des chiffres.');
 
				document.forms[0].surf_hab_chauffee.focus();
 
				return false;
 
		}
 
	}
 

 
	if (NbNiveaux !="") {
 
		if (!isDigits(NbNiveaux)) {
 
				window.alert('Le champ \'Nombre Niveaux\' ne peut contenir que des chiffres.');
 
				document.forms[0].nb_niveaux.focus();
 
				return false;
 
		}
 
	}
 
	
 
	if (SurfChaufferie !="") {
 
		if (!isDigits(SurfChaufferie)) {
 
				window.alert('Le champ \'Chaufferie\' ne peut contenir que des chiffres.');
 
				document.forms[0].surf_chaufferie.focus();
 
				return false;
 
		}
 
	}
 
	
 
	if (SurfGarage !="") {
 
		if (!isDigits(SurfGarage)) {
 
				window.alert('Le champ \'Garage\' ne peut contenir que des chiffres.');
 
				document.forms[0].surf_garage.focus();
 
				return false;
 
		}
 
	}
 

 
	if (EpaissIsoVert !="") {
 
		if (!isDigits(EpaissIsoVert)) {
 
				window.alert('Le champ \'Epaisseur Isolation Verticale\' ne peut contenir que des chiffres.');
 
				document.forms[0].epaiss_iso_vert.focus();
 
				return false;
 
		}
 
	}
 
	
 
	if (EpaissIsoSols !="") {
 
		if (!isDigits(EpaissIsoSols)) {
 
				window.alert('Le champ \'Epaisseur Isolation Sols\' ne peut contenir que des chiffres.');
 
				document.forms[0].epaiss_iso_sols.focus();
 
				return false;
 
		}
 
	}
 
	
 
	if (EpaissIsoPlaf !="") {
 
		if (!isDigits(EpaissIsoPlaf)) {
 
				window.alert('Le champ \'Epaisseur Isolation Plafonds\' ne peut contenir que des chiffres.');
 
				document.forms[0].epaiss_iso_plaf.focus();
 
				return false;
 
		}
 
	}
 

 
	if (NbPersonnes !="") {
 
		if (!isDigits(NbPersonnes)) {
 
				window.alert('Le champ \'Nombre de personnes\' ne peut contenir que des chiffres.');
 
				document.forms[0].nb_personnes.focus();
 
				return false;
 
		}
 
	}
 

 
	if (NbDouches !="") {
 
		if (!isDigits(NbDouches)) {
 
				window.alert('Le champ \'Nombre de douches\' ne peut contenir que des chiffres.');
 
				document.forms[0].nb_douches.focus();
 
				return false;
 
		}
 
	}
 
	
 
	if (NbBaignoires !="") {
 
		if (!isDigits(NbBaignoires)) {
 
				window.alert('Le champ \'Nombre de baignoires\' ne peut contenir que des chiffres.');
 
				document.forms[0].nb_baignoires.focus();
 
				return false;
 
		}
 
	}
 
	
 
	if (NbBalneos !="") {
 
		if (!isDigits(NbBalneos)) {
 
				window.alert('Le champ \'Nombre de balnéos\' ne peut contenir que des chiffres.');
 
				document.forms[0].nb_balneos.focus();
 
				return false;
 
		}
 
	}
 
	
 
	if (SurfPiscine !="") {
 
		if (!isDigits(SurfPiscine)) {
 
				window.alert('Le champ \'Surface Piscine\' ne peut contenir que des chiffres.');
 
				document.forms[0].surf_piscine.focus();
 
				return false;
 
		}
 
	}
 
	
 
	if (SurfTerrain !="") {
 
		if (!isDigits(SurfTerrain)) {
 
				window.alert('Le champ \'Surface Terrain\' ne peut contenir que des chiffres.');
 
				document.forms[0].surf_terrain.focus();
 
				return false;
 
		}
 
	}
 
	
 
	if (Altitude !="") {
 
		if (!isDigits(Altitude)) {
 
				window.alert('Le champ \'Altitude\' ne peut contenir que des chiffres.');
 
				document.forms[0].altitude.focus();
 
				return false;
 
		}
 
	}
 
	
 
	if (HautSsPlafond !="") {
 
		HautSsPlafond = isFrenchDecimal(HautSsPlafond);
 
		if (HautSsPlafond=="") {
 
			window.alert('Le champ \'Hauteur Sous Plafond\' ne peut contenir que des chiffres.');
 
			document.forms[0].haut_ss_plaf.focus();
 
			return false;
 
		} else {
 
			document.forms[0].haut_ss_plaf.value = HautSsPlafond; 
 
		}
 
	}
 

 
	return true;
 
}
 

 
/****************************************************
 
 function verif
 
 designed to test forms for the wavin geothermie site
 
 
 
 There are 2 types of verification:
 
 - fields that must be filled, and filled correctly
 
 - fields that, if filled, must be filled correctly
 
 
 
 If a incorrectly filled field, or an empty obligatory
 
 field, is detected then the function should inform
 
 the visitor, and then set the focus to the field.
 

 
 JM - 2001/02/21
 
 
 
 Special case: the contents of this function have been
 
 Already covered by the above.
 
****************************************************/
 

 
function verifPart() {
 
	if (!verifDemande()) {
 
		return false;
 
	} else if (!verifPro()) {
 
		return false;
 
	}
 
	return true;
 
} 


/****************************************************
 
 function verif
 
 designed to test forms for the wavin geothermie site
 
 
 
 There are 2 types of verification:
 
 - fields that must be filled, and filled correctly
 
 - fields that, if filled, must be filled correctly
 
 
 
 If a incorrectly filled field, or an empty obligatory
 
 field, is detected then the function should inform
 
 the visitor, and then set the focus to the field.
 

 
 JM - 2001/02/21
 
 
 
 Special case: the contents of this function have been
 
 Already covered by the above.
 
****************************************************/
 

 
function verifFormation() {
 // ------------ get all relevant fields ----------- //
 
	FirstName  = document.forms[0].prenom.value;
 
	LastName   = document.forms[0].nom.value;
	
	Firm       = document.forms[0].entreprise.value;
 
	Address    = document.forms[0].adresse.value;
 
	PostCode   = document.forms[0].code_postal.value;
 
	Town       = document.forms[0].ville.value;
 
	Email      = document.forms[0].email.value;
	
	if(document.forms[0].date != undefined) TheDate = document.forms[0].date.value;
	//Level 		= document.forms[0].formation.value;
 
// ------------ test fields ---------------//
 
	if (FirstName==""){
 
			window.alert('Veuillez remplir le champ : Prénom.');
 
			document.forms[0].prenom.focus();
 
			return false;
 
	}
 

 
	if (LastName==""){
 
			window.alert('Veuillez remplir le champ : Nom.');
 
			document.forms[0].nom.focus();
 
			return false;
 
	}
	

 
	if (Firm==""){
 
			window.alert('Veuillez remplir le champ : Entreprise.');
 
			document.forms[0].entreprise.focus();
 
			return false;
 
	}
 

 
	if (Address==""){
 
			window.alert('Veuillez remplir le champ : Adresse.');
 
			document.forms[0].adresse.focus();
 
			return false;
 
	}
 

 
	if (PostCode==""){
 
			window.alert('Veuillez remplir le champ : Code Postal.');
 
			document.forms[0].code_postal.focus();
 
			return false;
 
	}
 

 
	if (Town==""){
 
			window.alert('Veuillez remplir le champ : Ville.');
 
			document.forms[0].ville.focus();
 
			return false;
 
	}
 
 	if ( document.forms[0].date != undefined && TheDate==""){
 
			window.alert('Veuillez remplir le champ : Dates souhaitées.');
 
			document.forms[0].date.focus();
 
			return false;
 
	}

 
	/*if (Email==""){
 
			window.alert('Veuillez remplir le champ : email.');
 
			document.forms[0].email.focus();
 
			return false;
 
	}*/
 	
	/*if (Level==""){
 
			window.alert('Veuillez remplir le champ : Niveau.');
 
			document.forms[0].niveau.focus();
 
			return false;
 
	}*/

 

	// ----- test for valid e-mail, if exists ------- //
 
	if (Email!="") {
 
		if (!isEmail(Email)) {
 
				window.alert('Veuillez remplir correctement le champ : E-mail.');
 
				document.forms[0].email.focus();
 
				return false;
 
		}
 
	}
 
	return true;
 
}
 
 
 
 function verifSalon() {
 // ------------ get all relevant fields ----------- //
 
	FirstName  = document.forms[0].prenom.value;
 
	LastName   = document.forms[0].nom.value;
	
	Firm       = document.forms[0].entreprise.value;
 
	Address    = document.forms[0].adresse.value;
 
	PostCode   = document.forms[0].code_postal.value;
 
	Town       = document.forms[0].ville.value;
 
	Email      = document.forms[0].email.value;
 
// ------------ test fields ---------------//
 
	if (FirstName==""){
 
			window.alert('Veuillez remplir le champ : Prénom.');
 
			document.forms[0].prenom.focus();
 
			return false;
 
	}
 

 
	if (LastName==""){
 
			window.alert('Veuillez remplir le champ : Nom.');
 
			document.forms[0].nom.focus();
 
			return false;
 
	}
	

 
	if (Firm==""){
 
			window.alert('Veuillez remplir le champ : Entreprise.');
 
			document.forms[0].entreprise.focus();
 
			return false;
 
	}
 

 
	if (Address==""){
 
			window.alert('Veuillez remplir le champ : Adresse.');
 
			document.forms[0].adresse.focus();
 
			return false;
 
	}
 

 
	if (PostCode==""){
 
			window.alert('Veuillez remplir le champ : Code Postal.');
 
			document.forms[0].code_postal.focus();
 
			return false;
 
	}
 

 
	if (Town==""){
 
			window.alert('Veuillez remplir le champ : Ville.');
 
			document.forms[0].ville.focus();
 
			return false;
 
	}
 
	/*if (Email==""){
 
			window.alert('Veuillez remplir le champ : email.');
 
			document.forms[0].email.focus();
 
			return false;
 
	}*/

	// ----- test for valid e-mail, if exists ------- //
 
	if (Email!="") {
 
		if (!isEmail(Email)) {
 
				window.alert('Veuillez remplir correctement le champ : E-mail.');
 
				document.forms[0].email.focus();
 
				return false;
 
		}
 
	}
 
	return true;
 
}
 

 
/****************************************************
 
 function clearform
 
 clear the input of all the fields of the form
 
****************************************************/
 

 
function clearform() {
 
 document.forms[0].reset();
 
}
 

 
