// ****************************************************************** VALIDATION DU FORMULAIRE begin ******************************************************** //
function verifSelection() {

// -------------------------------------------------------------------------------------------- Validation du type de la carte ----------------------------------------------------------------------------------- //
if (document.formProducts.cctype.value == "") {
alert("Enter your credit card type")
return false
} 

// -------------------------------------------------------------------------------------------- Validation du nom de la carte ----------------------------------------------------------------------------------- //
if (document.formProducts.ccname.value == "") {
alert("Enter your credit card type")
return false
} 

// -------------------------------------------------------------------------------------------- Validation du numéro de la carte -------------------------------------------------------------------------------- //
if (document.formProducts.ccnumber.value == "") {
alert("Enter the credit card number")
return false
} 

// -------------------------------------------------------------------------------------------- Validation du mois de l'expiration de la carte ---------------------------------------------------------------------- //
if (document.formProducts.ccexpm.value == "") {
alert("Enter the month expiration of the credit card")
return false
} 

// -------------------------------------------------------------------------------------------- Validation de l'année d'expiration de la carte ------------------------------------------------------------------- //
if (document.formProducts.ccexpy.value == "") {
alert("Enter the year expiration of the credit card")
return false
} 

// -------------------------------------------------------------------------------------------- Validation du CCV de la carte ----------------------------------------------------------------------------------- //
if (document.formProducts.ccccv.value == "") {
alert("Enter your CCV number")
return false
} 

// -------------------------------------------------------------------------------------------- Validation du prénom ---------------------------------------------------------------------------------------------- //
if (document.formProducts.spfirst.value == "") {
alert("Enter your first name")
return false
} 

// -------------------------------------------------------------------------------------------- Validation du nom de famille -------------------------------------------------------------------------------------- //
if (document.formProducts.splast.value == "") {
alert("Enter your last name")
return false
} 

// -------------------------------------------------------------------------------------------- Validation de l'adresse --------------------------------------------------------------------------------------------- //
if (document.formProducts.spadd.value == "") {
alert("Enter your address")
return false
}

// -------------------------------------------------------------------------------------------- Validation de la rue -------------------------------------------------------------------------------------------------- //
if (document.formProducts.spstreet.value == "") {
alert("Enter your street")
return false
} 

// -------------------------------------------------------------------------------------------- Validation de la ville -------------------------------------------------------------------------------------------------- //
if (document.formProducts.spcity.value == "") {
alert("Enter your city")
return false
}

// -------------------------------------------------------------------------------------------- Validation du code postal --------------------------------------------------------------------------------------------- //
if (document.formProducts.spzip.value == "") {
alert("Enter your zip code")
return false
} 

// -------------------------------------------------------------------------------------------- Validation adresse de shipping si differents ---------------------------------------------------------------------------------------------- //
if(document.getElementById('sameshipadd').checked == false){
	// -------------------------------------------------------------------------------------------- Validation du prénom ---------------------------------------------------------------------------------------------- //
	if (document.formProducts.spfirstsh.value == "") {
	alert("Enter your shipping address first name")
	return false
	} 
	
	// -------------------------------------------------------------------------------------------- Validation du nom de famille -------------------------------------------------------------------------------------- //
	if (document.formProducts.splastsh.value == "") {
	alert("Enter your shipping address last name")
	return false
	} 
	
	// -------------------------------------------------------------------------------------------- Validation de l'adresse --------------------------------------------------------------------------------------------- //
	if (document.formProducts.spaddsh.value == "") {
	alert("Enter your shipping address")
	return false
	}
	
	// -------------------------------------------------------------------------------------------- Validation de la rue -------------------------------------------------------------------------------------------------- //
	if (document.formProducts.spstreetsh.value == "") {
	alert("Enter your shipping address street")
	return false
	} 
	
	// -------------------------------------------------------------------------------------------- Validation de la ville -------------------------------------------------------------------------------------------------- //
	if (document.formProducts.spcitysh.value == "") {
	alert("Enter your shipping address city")
	return false
	}
	
	// -------------------------------------------------------------------------------------------- Validation du code postal --------------------------------------------------------------------------------------------- //
	if (document.formProducts.spzipsh.value == "") {
	alert("Enter your shipping address zip code")
	return false
	}
}

// -------------------------------------------------------------------------------------------- Validation du téléphone --------------------------------------------------------------------------------------------- //
//if (document.formProducts.champ13.value == "") {
//alert("Enter your phone number")
//return false
//} 

// -------------------------------------------------------------------------------------------- Validation du courriel -------------------------------------------------------------------------------------------- //
if (document.formProducts.email.value == "") {
alert("Enter your email")
return false
}

invalidChars = " /:,;'"

for (i=0; i < invalidChars.length; i++) {	// does it contain any invalid characters?
badChar = invalidChars.charAt(i)

if (document.formProducts.email.value.indexOf(badChar,0) > -1) {
alert("Your e-mail contains invalid characters. Please check.")
document.formProducts.email.focus()
return false
}
}

atPos = document.formProducts.email.value.indexOf("@",1)			// there must be one "@" symbol
if (atPos == -1) {
alert('Your e-mail does not contain the "@". Please check.')
document.formProducts.email.focus()
return false
}

if (document.formProducts.email.value.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
alert('There must be a sign "@". Please check.')
document.formProducts.email.focus()
return false
}

periodPos = document.formProducts.email.value.indexOf(".",atPos)

if (periodPos == -1) {					// and at least one "." after the "@"
alert('You ve forgotten the point. " after the "@". Please check.')
document.formProducts.email.focus()
return false
}

if (periodPos+3 > document.formProducts.email.value.length)	{		// must be at least 2 characters after the 
alert('There must be at least two characters after the "." Please check.')
document.formProducts.email.focus()
return false
}

if (document.formProducts.emailconf.value == "") {
alert("Confirm your email")
return false
}

invalidChars = " /:,;'"

for (i=0; i < invalidChars.length; i++) {	// does it contain any invalid characters?
badChar = invalidChars.charAt(i)

if (document.formProducts.emailconf.value.indexOf(badChar,0) > -1) {
alert("Your e-mail contains invalid characters. Please check.")
document.formProducts.emailconf.focus()
return false
}
}

atPos = document.formProducts.emailconf.value.indexOf("@",1)			// there must be one "@" symbol
if (atPos == -1) {
alert('Your e-mail does not contain the "@". Please check.')
document.formProducts.emailconf.focus()
return false
}

if (document.formProducts.emailconf.value.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
alert('There must be a sign "@". Please check.')
document.formProducts.emailconf.focus()
return false
}

periodPos = document.formProducts.emailconf.value.indexOf(".",atPos)

if (periodPos == -1) {					// and at least one "." after the "@"
alert('You ve forgotten the point. " after the "@". Please check.')
document.formProducts.emailconf.focus()
return false
}

if (periodPos+3 > document.formProducts.emailconf.value.length)	{		// must be at least 2 characters after the 
alert('There must be at least two characters after the ".." Please check.')
document.formProducts.emailconf.focus()
return false
}
// Si le courriel et la confirmation du courriel ne sont pas pareil
if(document.formProducts.email.value != document.formProducts.emailconf.value)
{
	alert('Your email confirmation does not correspond to your email')
	document.formProducts.emailconf.focus()
	return false
}

// -------------------------------------------------------------------------------------------- Validation de la méthode de livraison ------------------------------------------------------------------------------ //
/*var chks = document.getElementsByName('case5[]');


nbrecases1 = chks.length

	flag = 0

		for (i = 0; i < nbrecases1 ; i++) {

			if (chks[i].checked) {

			flag = 1

			}

		}


if (flag == 0) {

alert("Please indicate the method of delivery")
return false;
}





// -------------------------------------------------------------------------------------- Validation des cases à cocher (choix du produit) ------------------------------------------------------------------------- //
var chks1 = document.getElementsByName('case1[]');
var chks2 = document.getElementsByName('case2[]');
var chks3 = document.getElementsByName('case3[]');
var chks4 = document.getElementsByName('case4[]');
var chks9 = document.getElementsByName('case9[]');
var chks10 = document.getElementsByName('case10[]');

// Validation de la case1 (produit #1)
nbrecases = chks1.length

	flag1 = 0

		for (i = 0; i < nbrecases ; i++) {

			if (chks1[i].checked) {

			flag1 = 1

			}

		}
		
// Validation de la case2 (produit #2)
nbrecases = chks2.length

	flag2 = 0

		for (i = 0; i < nbrecases ; i++) {

			if (chks2[i].checked) {

			flag2 = 1

			}

		}
		
// Validation de la case3 (produit #3)
nbrecases = chks3.length

	flag3 = 0

		for (i = 0; i < nbrecases ; i++) {

			if (chks3[i].checked) {

			flag3 = 1

			}

		}

// Validation de la case4 (produit #4)
nbrecases = chks4.length

	flag4 = 0

		for (i = 0; i < nbrecases ; i++) {

			if (chks4[i].checked) {

			flag4 = 1

			}

		}
		
// Validation de la case9 (produit #9)
nbrecases = chks9.length

	flag9 = 0

		for (i = 0; i < nbrecases ; i++) {

			if (chks9[i].checked) {

			flag9 = 1

			}

		}
		
// Validation de la case10 (produit #10)
nbrecases = chks10.length

	flag10 = 0

		for (i = 0; i < nbrecases ; i++) {

			if (chks10[i].checked) {

			flag10 = 1

			}

		}
		
if (flag1 == 0 && flag2 == 0 && flag3 == 0 && flag4 == 0 && flag9 == 0 && flag10 == 0) {

alert("We cannot process your order, please select a product in the CHOICE OF PACKAGE section.")
return false;
}*/

} 


