//************************************************
// inscription.js
//
// Form validation
//
//************************************************


//************************************************
// soumettre()
//************************************************
function soumettre() {
	
	// EMAIL
	if (!checkEmail(document.inscription.email.value)) {return;}
	
	// FORMAT
	if (!document.inscription.format[0].checked && !document.inscription.format[1].checked) {
		alert("Veuillez choisir le format de courriel.");
		return;
	}
	
	// FIRSTNAME
	if (document.inscription.first_name.value.length == 0) {
		alert("Veuillez entrer votre prénom.");
		return;
	}
	
	// LASTNAME
	if (document.inscription.last_name.value.length == 0) {
		alert("Veuillez entrer votre nom.");
		return;
	}
	
	// TELEPHONE
	if (document.inscription.phone1.value.length == 0) {
		alert("Veuillez entrer votre numéro de téléphone.");
		return;
	}
	
	// REGION
	if (document.inscription.custom_region.value.length == 0) {
		alert("Veuillez indiquer votre région.");
		return;
	}
	
	
	// COMMENT
	if (document.inscription.custom_comment.value.length == 0) {
		alert("Veuillez indiquer comment vous avez entendu parler de nos services.");
		return;
	}
	
	// HORIZON
	if (document.inscription.custom_horizon.value.length == 0) {
		alert("Veuillez indiquer dans combien de temps vous prévoyer acheter.");
		return;
	}
	
	
	// ADRESSE
	if (document.inscription.street.value.length == 0) {
		alert("Veuillez indiquer votre adresse.");
		return;
	}
	
	
	// ZIP
	if (document.inscription.zip.value.length == 0) {
		alert("Veuillez indiquer votre code postal.");
		return;
	}
	
	
	// CITY
	if (document.inscription.city.value.length == 0) {
		alert("Veuillez indiquer votre ville.");
		return;
	}
	
	
	// Submit form
	document.inscription.submit();
	
} // soumettre


//************************************************
// checkEmail()
//************************************************
function checkEmail(VAL) {
	
	if (VAL.length == 0) {
		alert("Veuillez entrer votre adresse email.");
		return false;
	}
	
	if (VAL.indexOf("@") == -1) {
		alert("Veuillez entrer une adresse email valide.");
		return false;
	}
	
	return true;
	
} // checkEmail


