//English Validation -------------------------------------
function echeckenglish(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1){
		alert("Email is invalid")
		return (false);
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("Email is invalid")
		return (false);
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Email is invalid")
		return (false);
	}

	if (str.indexOf(at,(lat+1))!=-1){
		alert("Email is invalid")
		return (false);
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Email is invalid")
		return (false);
	}

	if (str.indexOf(dot,(lat+2))==-1){
		alert("Email is invalid")
		return (false);
	}
		
	if (str.indexOf(" ")!=-1){
		alert("Email is invalid")
		return (false);
	}

 	return (true);					
}

function validateEnglishForm(){
	//check language
	if (document.englishform.language.value != "English"){
		alert("Invalid language");
		document.englishform.language.focus();
		return (false);
	}
	
	//check name
	if (document.englishform.name.value == ""){
		alert("Your name is required");
		document.englishform.name.focus();
		return (false);
	}
	
	//check address
	if (document.englishform.address.value == ""){
		alert("Your address is requires");
		document.englishform.address.focus();
		return (false);
	}
	
	//check city
	if (document.englishform.city.value == ""){
		alert("Your city is required");
		document.englishform.city.focus();
		return (false);
	}
	
	//check Province/State
	if (document.englishform.province.value == ""){
		alert("Your Province or State is required");
		document.englishform.province.focus();
		return (false);
	}
	
	//check Country
	if (document.englishform.country.value == ""){
		alert("Your Country is required");
		document.englishform.country.focus();
		return (false);
	}
	
	//check Postal Code
	if (document.englishform.postal.value == ""){
		alert("Your Postal Code or Zip Code is required");
		document.englishform.postal.focus();
		return (false);
	}
	
	//check Phone number
	if (document.englishform.phone.value == ""){
		alert("Your phone number is required");
		document.englishform.phone.focus();
		return (false);
	}
	
	var email=document.englishform.email
	if ((document.englishform.email.value==null)||(document.englishform.email.value=="")){
		alert("Your Email is required")
		document.englishform.email.focus()
		return (false);
	}
	
	if (echeckenglish(document.englishform.email.value)==false){
		document.englishform.email.value=""
		document.englishform.email.focus()
		return (false);
	}
	return (true);
}


//French Validation ------------------------------------
function echeckfrench(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1){
		alert("Votre courriel n\'est pas valide")
		return (false);
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("Votre courriel n\'est pas valide")
		return (false);
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Votre courriel n\'est pas valide")
		return (false);
	}

	if (str.indexOf(at,(lat+1))!=-1){
		alert("Votre courriel n\'est pas valide")
		return (false);
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Votre courriel n\'est pas valide")
		return (false);
	}

	if (str.indexOf(dot,(lat+2))==-1){
		alert("Votre courriel n\'est pas valide")
		return (false);
	}
		
	if (str.indexOf(" ")!=-1){
		alert("Votre courriel n\'est pas valide")
		return (false);
	}

 	return (true);					
}

function validateFrenchForm(){
	//check language
	if (document.frenchform.language.value != "French"){
		alert("La langue n'est pas valide");
		document.frenchform.language.focus();
		return (false);
	}
	
	//check name
	if (document.frenchform.name.value == ""){
		alert("Votre nom est requis");
		document.frenchform.name.focus();
		return (false);
	}
	
	//check address
	if (document.frenchform.address.value == ""){
		alert("Votre adresse est requise");
		document.frenchform.address.focus();
		return (false);
	}
	
	//check city
	if (document.frenchform.city.value == ""){
		alert("Votre ville est requise");
		document.frenchform.city.focus();
		return (false);
	}
	
	//check Province/State
	if (document.frenchform.province.value == ""){
		alert("Votre province ou état est requis");
		document.frenchform.province.focus();
		return (false);
	}
	
	//check Country
	if (document.frenchform.country.value == ""){
		alert("Votre pays est requis");
		document.frenchform.country.focus();
		return (false);
	}
	
	//check Postal Code
	if (document.frenchform.postal.value == ""){
		alert("Votre code postal ou zip est requis");
		document.frenchform.postal.focus();
		return (false);
	}
	
	//check Phone number
	if (document.frenchform.phone.value == ""){
		alert("Votre numéro de téléphone est requis");
		document.frenchform.phone.focus();
		return (false);
	}
	
	var email=document.frenchform.email
	if ((document.frenchform.email.value==null)||(document.frenchform.email.value=="")){
		alert("Votre courriel est requis")
		document.frenchform.email.focus()
		return (false);
	}
	
	if (echeckfrench(document.frenchform.email.value)==false){
		document.frenchform.email.value=""
		document.frenchform.email.focus()
		return (false);
	}
	return (true);
}