// JavaScript Document

			function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//________________________________________________________________

function validName(name) {
			if (name == "") {
				return false
			}
	
			for (i=0; i<name.length; i++) {
				if (!((name.charCodeAt(i) >= 65 && name.charCodeAt(i) <= 90) || (name.charCodeAt(i) >= 97 && name.charCodeAt(i) <= 122) || (name.charCodeAt(i) == 32))) {	
					return false;					
				}
			}		
			return true;	
}

//__________________________________________________________________
function validNum(num) {
			if (num == "") {
				return false;
			}
			for (i=0; i<num.length; i++) {
				if ((num.charAt(i) < "0") || (num.charAt(i) > "9")) {
				return false;
				}
			}
		return true;
}

//________________________________________________________________
function valid3Num(num) {
			if (num.length < 3) {
				return false;
			}
			for (i=0; i<num.length; i++) {
				if ((num.charAt(i) < "0") || (num.charAt(i) > "9")) {
				return false;
				}
			}
		return true;
}
//_____________________________________________________________
function valid4Num(num) {
			if (num.length < 4) {
				return false;
			}
			for (i=0; i<num.length; i++) {
				if ((num.charAt(i) < "0") || (num.charAt(i) > "9")) {
				return false;
				}
			}
		return true;
}
//________________________________________________________________
function validStreet(street) {
			if (street == "") {
				return false
			}
			for (i=0; i<street.length; i++) {
				if (street.charCodeAt(i)== 32) {
					return false;					
				}
			}	
			for (i=0; i<street.length; i++) {
				if (!((street.charCodeAt(i) >= 65 && street.charCodeAt(i) <= 90) || (street.charCodeAt(i) >= 97 && street.charCodeAt(i) <= 122) || (street.charCodeAt(i)==46))) {	
					return false;					
				}
			}		
			return true;	
}
//__________________________________________________________________

function validPostalCode(pc_zip) {

	invalidChars = "/:,;&#*()+=`<>?{}[]$%!"

	// is the street field empty?
	if (pc_zip == "") {
		return false
	}

	// are there invalid characters in the field?
	for (i = 0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
	
		if (pc_zip.indexOf(badChar,0) > -1) {
			return false
		}

	}

	return true
}
//___________________________________________________________________
//is the users email address valid?

		function validEmail(email) {
			invalidChars = " /:,;!#$%^&*"
			if (email =="") {
				return false
				}
			if (email ==  "name@provider.com"){
				return false
				}
			
			for (i=0; i<invalidChars.length; i++)  {
				badChar = invalidChars.charAt(i)
				if (email.indexOf(badChar, 0) > -1)  {
					return false
			 			}
				}
				atPos = email.indexOf("@", 1)
				if (atPos == -1)  {
					return false
				}
				if (email.indexOf("@", atPos+1)  != -1)  {
					return false
				}

				//Is there at least one dot in the email address? What is it's position?
				dotPos = email.indexOf(".", atPos)
				if (dotPos == -1)  {
					return false
				}
				
				//What is the lastIndexOf the dot in the email address?  If there is no dot at all, then this returns false (so its the same as dotPos), but the lastdotPos value is used later on
				var lastdotPos = email.lastIndexOf(".")
				if (lastdotPos == -1)  {
					return false
				}

				//Are there two dots in a row in the email address?
				if (lastdotPos+1 == dotPos) {	
					return false
				}	

				//is the extension of the email too long?
				if (lastdotPos+5 == email.length)  {
					return false
				}	

				//is there at least a two letter extension on the email address
				if (dotPos+3 > email.length) {
					return false
				}

				//how many three-letter extensions are there?
				if (lastdotPos > dotPos + 8) {
					return false
				}

			return true

			}
//________________________________________________________________
			
function validStreet(street) {

	invalidChars = "/:,;&#*()+=`<>?{}[]$%!"

	// is the street field empty?
	if (street == "") {
		return false
	}

	// are there invalid characters in the field?
	for (i = 0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
	
		if (street.indexOf(badChar,0) > -1) {
			return false
		}

	}

	return true
}

//__________________________________________________________		
			function validForm(orderForm) {
				if (!validName(orderForm.name.value)) {
					alert("Il y a une erreur dans l'entrée 'nom', svp correcte.")
					orderForm.name.focus()
					orderForm.name.select()
					return false
				}
				if (!validStreet(orderForm.address.value)) {
					alert("Il y a une erreur dans l'entrée ‘adresse', svp correcte.")
					orderForm.address.focus()
					orderForm.address.select()
					return false
				}
				if (!validStreet(orderForm.city.value)) {
					alert("Il y a une erreur dans l'entrée ‘ville ', svp correcte.")
					orderForm.city.focus()
					orderForm.city.select()
					return false
				}
				if (!validStreet(orderForm.province.value)) {
					alert("Remplissez votre province ou etat.")
					orderForm.province.focus()
					orderForm.province.select()
					return false
				}
				if (!validPostalCode(orderForm.postalcode.value)) {
					alert("Remplissez votre code postal.")
					orderForm.postalcode.focus()
					orderForm.postalcode.select()
					return false
				}
				if (!valid3Num(orderForm.homephone1.value)) {
					alert("Il y a une erreur dans l'entrée ' téléphone ', svp correcte")
					orderForm.homephone1.focus()
					orderForm.homephone1.select()
					return false
				}
				if (!valid3Num(orderForm.homephone2.value)) {
					alert("Il y a une erreur dans l'entrée ' téléphone ', svp correcte.")
					orderForm.homephone2.focus()
					orderForm.homephone2.select()
					return false
				}
				if (!valid4Num(orderForm.homephone3.value)) {
					alert("Il y a une erreur dans l'entrée ' téléphone ', svp correcte.")
					orderForm.homephone3.focus()
					orderForm.homephone3.select()
					return false
				}
				//check to see if the email's valid
				if (!validEmail(orderForm.email.value)) {
					alert("Il y a une erreur dans l'entrée 'email', svp correcte.")
					orderForm.email.focus()
					orderForm.email.select()
					return false
				}	
				// If we made it to here, everything's valid, so return true
					return true
				
				}
			
