/* auteur: Alexandre Glouchkoff */
/* Date de création: 07/12/01 */

var navigateur = (document.getElementById || document.all || document.layers);
	
function getObj(name){
	if (document.getElementById){
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all){
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers){
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}
	
function cache(div_id){
	if (!navigateur) return;
	var x = new getObj(div_id);
	x.style.visibility = 'hidden';
	x.style.display = 'none';
	}

function montre(div_id){
	if (!navigateur) return;
	var x = new getObj(div_id);
	x.style.visibility = 'visible';
	x.style.display = 'block';
	}

function go(page,largeur,hauteur)
{
var top=(screen.height-hauteur)/2;
var left=(screen.width-largeur)/2;
options="'toolbar=0,location=0,directories=0,status=0,scrollbars=2,resizable=1,copyhistory=0,menuBar=0, width=" + largeur +", height=" + hauteur +", left=" + left + ", top=" + top + "'";
pop = this.open(page,'_blank',options);
pop.resizeTo(largeur,hauteur);
pop.focus();
}

function efface(champ)
{
	if (champ.value == "Identifiant" || champ.value=="00000000") champ.value = '';
}

function identification() {
	if ((this.formlogin.email.value == "Identifiant")||(this.formlogin.email.value=='')) {
   	window.alert("Veuillez entrer votre identifiant, merci.");
   	this.formlogin.email.focus();
   	return false;
	}
	else if ((this.formlogin.pass.value=='00000000')||(this.formlogin.pass.value=='')) {
   	window.alert("Veuillez entrer votre mot de passe, merci.");
   	this.formlogin.pass.focus();
   	return false;
	}
}

function shopping() {
	if ((this.formshopping.recherche.value.length < 1)||(this.formshopping.recherche.value=='Chercher un produit dans...')) {
   	window.alert("Veuillez entrer au moins un mot clé\ndans le champ de recherche, merci.");
   	this.formshopping.recherche.focus();
   	return false;
	}
}

function aliment() {
	if ((this.formaliment.kw.value.length < 1)||(this.formaliment.kw.value=='Tapez votre aliment ici...')) {
   	window.alert("Veuillez entrer au moins un mot clé\ndans le champ de recherche, merci.");
   	this.formaliment.kw.focus();
   	return false;
	}
}

function cook() {
	if ((this.recette.recherche.value.length < 1)||(this.recette.recherche.value=='Vos ingrédients ici...')) {
   	window.alert("Veuillez entrer au moins un ingrédient\ndans le champ de recherche, merci.");
   	this.recette.recherche.focus();
   	return false;
	}
}

function verif_bilan() {
	if (this.bilan.civ.value.length < 1) {
   	window.alert("Précisez votre civilité, merci.");
   	this.bilan.civ.focus();
   	return false;
	}
	if (this.bilan.pre.value.length < 2) {
   	window.alert("Entrez votre prénom, merci.");
   	this.bilan.pre.focus();
   	return false;
	}
	if (this.bilan.nom.value.length < 2) {
   	window.alert("Entrez votre nom, merci.");
   	this.bilan.nom.focus();
   	return false;
	}
	var x = this.bilan.mail.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)==0) {
   	window.alert("Vérifiez votre adresse e-mail, merci.");
   	this.bilan.mail.focus();
   	return false;
	}
	if (this.bilan.age.value.length < 1) {
   	window.alert("Indiquez votre âge, merci.");
   	this.bilan.age.focus();
   	return false;
	}
	if (this.bilan.tai.value.length < 1) {
   	window.alert("Indiquez votre taille, merci.");
   	this.bilan.tai.focus();
   	return false;
	}
	if (this.bilan.pds.value.length < 1) {
   	window.alert("Indiquez votre poids, merci.");
   	this.bilan.pds.focus();
   	return false;
	}
	if (this.bilan.sta.value.length < 1) {
   	window.alert("Indiquez votre stature, merci.");
   	this.bilan.sta.focus();
   	return false;
	}
	if (this.bilan.ap.value.length < 1) {
   	window.alert("Indiquez votre activité physique, merci.");
   	this.bilan.ap.focus();
   	return false;
	}
	if (this.bilan.med.checked != 1) {
   	window.alert("Confirmez l'avis de votre médecin traitant, merci.");
   	this.bilan.med.focus();
   	return false;
	}
	return true;
}

var message="Merci pour votre visite !";
function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}


function ScanCookie(variable)
	{
	cook = document.cookie;
	variable += "=";
	place = cook.indexOf(variable,0);
	if (place <= -1)
		return("0");
	else
		{
		end = cook.indexOf(";",place)
		if (end <= -1)
			return(unescape(cook.substring(place+variable.length,cook.length)));
		else
			return(unescape(cook.substring(place+variable.length,end)));
		}
	}
	
function CreationCookie(nom,valeur,permanent)
	{
	if(permanent)
		{
		dateExp = new Date(2020,11,11);
		dateExp = dateExp.toGMTString();
		ifpermanent = '; expires=' + dateExp + ';';
		}
	else
		ifpermanent = '';
	document.cookie = nom + '=' + escape(valeur) + ifpermanent;
	}

function testEntier(valeur)
{
  if (valeur == parseInt(valeur,10)) return true;
  else return false;
}

function testDate(jour,mois,annee)
{
  var erreur;
  erreur = 0;
  valeurJour = jour.toString();
  valeurMois = mois.toString();
  valeurAnnee = annee.toString();
  if ((!testEntier(valeurJour)) || (valeurJour.length != 2)) erreur = 1;
  if ((!testEntier(valeurMois)) || (valeurMois.length != 2))erreur = 1;
  if ((!testEntier(valeurAnnee)) || (valeurAnnee.length != 4)) erreur = 1;
  var bis;
  var maxFev;
  bis = valeurAnnee % 4;
  if (bis == 0) maxFev = 29;
  else maxFev = 28;
  var maxJours;
  maxJours = new Array(31,maxFev,31,30,31,30,31,31,30,31,30,31);
  if (valeurJour > maxJours[valeurMois-1]) erreur = 1;
  if (erreur == 0) return true;
  else return false;
}

function testSaisie()
{
  var jj;
  var mm;
  var aaaa;
  jj = document.ajouter.elements["jour"].value;
  mm = document.ajouter.elements["mois"].value;
  aaaa = document.ajouter.elements["annee"].value;
  if (testDate(jj,mm,aaaa)) return true;
  else 
  {
    window.alert("Veuillez verifier la date qui ne semble pas correcte, merci.");
    return false;
  }
}

function verif_profil() {
    if (this.profil.pa1.value =="") {
   	window.alert("Précisez vore consommation de thé, tisane");
   	this.profil.pa1.focus();
   	return false;
	}
    if (this.profil.pa2.value =="") {
   	window.alert("Précisez vore consommation de café");
   	this.profil.pa2.focus();
   	return false;
	}
    if (this.profil.pa3.value =="") {
   	window.alert("Précisez vore consommation de lait");
   	this.profil.pa3.focus();
   	return false;
	}
    if (this.profil.pa4.value =="") {
   	window.alert("Précisez vore consommation de vin");
   	this.profil.pa4.focus();
   	return false;
	}
    if (this.profil.pa5.value =="") {
   	window.alert("Précisez vore consommation d'apéritifs, alcools forts");
   	this.profil.pa5.focus();
   	return false;
	}
    if (this.profil.pa6.value =="") {
   	window.alert("Précisez vore consommation de soupe et bouillon de légumes");
   	this.profil.pa6.focus();
   	return false;
	}
    if (this.profil.pa7.value =="") {
   	window.alert("Précisez vore consommation de boissons sucrées, sodas, jus de fruits");
   	this.profil.pa7.focus();
   	return false;
	}
    if (this.profil.pa8.value =="") {
   	window.alert("Précisez vore consommation de pâtes, riz, pommes de terre, légumes secs");
   	this.profil.pa8.focus();
   	return false;
	}
    if (this.profil.pa9.value =="") {
   	window.alert("Précisez vore consommation de légumes, crudités");
   	this.profil.pa9.focus();
   	return false;
	}
    if (this.profil.pa10.value =="") {
   	window.alert("Précisez vore consommation de fruits, compotes");
   	this.profil.pa10.focus();
   	return false;
	}
    if (this.profil.pa11.value =="") {
   	window.alert("Précisez vore consommation de quiches, pizzas, feuilletés, tourtes");
   	this.profil.pa11.focus();
   	return false;
	}
    if (this.profil.pa12.value =="") {
   	window.alert("Précisez vore consommation de fromage");
   	this.profil.pa12.focus();
   	return false;
	}
    if (this.profil.pa13.value =="") {
   	window.alert("Précisez vore consommation de charcuteries, patés, saucissons");
   	this.profil.pa13.focus();
   	return false;
	}
    if (this.profil.pa14.value =="") {
   	window.alert("Précisez vore consommation de viandes, volailles, jambon, oeufs");
   	this.profil.pa14.focus();
   	return false;
	}
    if (this.profil.pa15.value =="") {
   	window.alert("Précisez vore consommation de poissons, crustacés, coquillages");
   	this.profil.pa15.focus();
   	return false;
	}
    if (this.profil.pa16.value =="") {
   	window.alert("Précisez vore consommation de plats cuisinés ou en sauce (maison ou du commerce)");
   	this.profil.pa16.focus();
   	return false;
	}
    if (this.profil.pa17.value =="") {
   	window.alert("Précisez vore consommation de snacks, barres, biscuits, gäteaux secs, chocolat");
   	this.profil.pa17.focus();
   	return false;
	}
    if (this.profil.pa18.value =="") {
   	window.alert("Précisez vore consommation de pâtisseries, viennoiseries");
   	this.profil.pa18.focus();
   	return false;
	}
    if (this.profil.pa19.value =="") {
   	window.alert("Précisez vore consommation de produits laitiers frais, desserts lactés");
   	this.profil.pa19.focus();
   	return false;
	}
    if (this.profil.pa20.value =="") {
   	window.alert("Précisez vore consommation de pains, biscottes, céréales");
   	this.profil.pa20.focus();
   	return false;
	}
}

function test_poids()
{
if ((document.bilan_poids.Age.value<18)||(document.bilan_poids.Age.value>70))
{
alert ("Votre age doit être compris en 18 et 70 ans.");
document.bilan_poids.Age.focus();
return false;
}

if ((document.bilan_poids.Taille.value<130)||(document.bilan_poids.Taille.value>220))
{
alert ("Votre taille doit être comprise en 130 et 220 cm.");
document.bilan_poids.Taille.focus();
return false;
}
if ((document.bilan_poids.Poids.value<35)||(document.bilan_poids.Poids.value>180))
{
alert ("Votre poids doit être compris en 35 et 180 kg.");
document.bilan_poids.Poids.focus();
return false;
}
if ((document.bilan_poids.tta.value!='-----------------')&&((document.bilan_poids.tta.value<45)||(document.bilan_poids.tta.value>140)))
{
alert ("Votre tour de taille doit être compris en 45 et 140 cm.");
document.bilan_poids.tta.focus();
return false;
}
if ((document.bilan_poids.tha.value!='-----------------')&&((document.bilan_poids.tha.value<50)||(document.bilan_poids.tha.value>150)))
{
alert ("Votre tour de hanches doit être compris en 50 et 150 cm.");
document.bilan_poids.tha.focus();
return false;
}
}
