function echeck(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("Invalid E-mail")
		return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail")
	   return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Invalid E-mail")
	    return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
	    alert("Invalid E-mail")
	    return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Invalid E-mail")
	    return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
	    alert("Invalid E-mail")
	    return false
	}
	if (str.indexOf(" ")!=-1){
	    alert("Invalid E-mail")
	    return false
	}
	return true					
}



function check_submit(opt){
    //name
	if (document.formContactUs.name.value.length==0){
       alert("Name missing");
       document.formContactUs.name.focus();
       return false;
    }
	//company
    if (document.formContactUs.company.value.length==0){
       alert("Company missing");
	   document.formContactUs.company.focus();
       return false;
    }
	//position	
	if (document.formContactUs.position.selectedIndex==0){
       alert("Select a position");
       document.formContactUs.position.focus();
       return false;
    }
	//phone
	if (document.formContactUs.phone.value.length==0){
       alert("Phone missing");
       document.formContactUs.phone.focus();
       return false;
    }
	//email
	if (document.formContactUs.email.value.length==0){
		alert("Email missing");
		document.formContactUs.email.focus();
		return false;
	}
	if (echeck(document.formContactUs.email.value)==false){
		document.formContactUs.email.focus();
		return false;
	}
	//comments
	if (document.formContactUs.comments.value.length==0){
       alert("Comments missing");
       document.formContactUs.comments.focus();
       return false;
    }
	if(opt)
		document.formContactUs.orders.value = adaptiveCalculator[index];
    document.formContactUs.submit();
} 


function echeckfra(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 non-valide")
		return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Email non-valide")
	   return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Email non-valide")
	    return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
	    alert("Email non-valide")
	    return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Email non-valide")
	    return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
	    alert("Email non-valide")
	    return false
	}
	if (str.indexOf(" ")!=-1){
	    alert("Email non-valide")
	    return false
	}
	return true					
}



function check_submitfra(opt){
    //name
	if (document.formContactUs.name.value.length==0){
       alert("Nom manquants");
       document.formContactUs.name.focus();
       return false;
    }
	//company
    if (document.formContactUs.company.value.length==0){
       alert("Nom de votre soci\u00e9t\u00e9 manquant");
	   document.formContactUs.company.focus();
       return false;
    }
	//position	
	if (document.formContactUs.position.selectedIndex==0){
       alert("S\u00e9lectionner une case");
       document.formContactUs.position.focus();
       return false;
    }
	//phone
	if (document.formContactUs.phone.value.length==0){
       alert("Num\u00e9ro de t\u00e9l\u00e9phone manquant");
       document.formContactUs.phone.focus();
       return false;
    }
	//email
	if (document.formContactUs.email.value.length==0){
		alert("Adresse \u00e9lectronique manquant");
		document.formContactUs.email.focus();
		return false;
	}
	if (echeckfra(document.formContactUs.email.value)==false){
		document.formContactUs.email.focus();
		return false;
	}
	//comments
	if (document.formContactUs.comments.value.length==0){
       alert("Commentaires manquants");
       document.formContactUs.comments.focus();
       return false;
    }
	if(opt)
		document.formContactUs.orders.value = adaptiveCalculator[index];
    document.formContactUs.submit();
} 