/* 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 process_keypress() { 
if (window.event.type == "keypress" & window.event.keyCode == 13) 
alert("Touche ENTREE inopérante, utilisez le bouton prévu à cet effet, merci."); 
return !(window.event.type == "keypress" & window.event.keyCode == 13); 
} 
		
function LmOver(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#FFFFFF";
elem.style.cursor = 'hand'}

function LmOut(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#339933";}

function LmDown(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#FFFFFF";}

function LmOver2(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('SPAN')[0].style.color = "#FFFFFF";
elem.style.cursor = 'hand'}

function LmOut2(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('SPAN')[0].style.color = "#339933";}

function LmDown2(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('SPAN')[0].style.color = "#FFFFFF";}

function LmUp(path)
{location.href = path;}
	
function efface(champ)
{
	if (champ.value != "Chercher ici dans..." && champ.value!="Tapez votre aliment ici...") champ.value = '';
}

function getElementsByClass(searchClass, node, tag) { 
    var classElements = new Array(); 
    if ( node == null ) 
        node = document; 
    if ( tag == null ) 
        tag = '*'; 
    var els = node.getElementsByTagName(tag); 
    var elsLen = els.length; 
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); 
    for (i = 0, j = 0; i < elsLen; i++) { 
        if ( pattern.test(els[i].className) ) { 
            classElements[j] = els[i]; 
            j++; 
        } 
    } 
    return classElements; 
} 
  
function tailleFonte(classe, taille) { 
    cibles = getElementsByClass('mod'); 
    for (i=0; i < cibles.length; i++) { 
        cibles[i].style.fontSize = taille;
		cibles[i].style.lineHeight = taille/10.5;
        } 
    }

function no_accent(my_string) {
var new_string = String (my_string);
new_string = new_string.replace(RegExp("(\u0040|&#x40|&#064;|@|&commat;|\u0061|&#x61|&#097;|\u00C0|&#xC0|&#192;|À|&Agrave;|\u00C1|&#xC1|&#193;|Á|&Aacute;|\u00C2|&#xC2|&#194;|Â|&Acirc;|\u00C3|&#xC3|&#195;|Ã|&Atilde;|\u00C4|&#xC4|&#196;|Ä|&Auml;|\u00C5|&#xC5|&#197;|Å|&Aring;|\u00E0|&#xE0|&#224;|à|&agrave;|\u00E1|&#xE1|&#225;|á|&aacute;|\u00E2|&#xE2|&#226;|â|&acirc;|\u00E3|&#xE3|&#227;|ã|&atilde;|\u00E4|&#xE4|&#228;|ä|&auml;|\u00E5|&#xE5|&#229;|å|&aring;)","gi"),'a');
new_string = new_string.replace(RegExp("(\u00C7|&#xC7|&#199;|Ç|&Ccedil;|\u00E7|&#xE7|&#231;|ç|&ccedil;)","gi"),'c');
new_string = new_string.replace(RegExp("(\u00D0|&#xD0|&#208;|Ð|&ETH;)","gi"),'d');
new_string = new_string.replace(RegExp("(\u0065|&#x65;|&#101;|\u00C8|&#xC8;|&#200;|È|&Egrave;|\u00C9|&#xC9;|&#201;|É|&Eacute;|\u00CA|&#xCA;|&#202;|Ê|&Ecirc;|\u00CB|&#xCB;|&#203;|Ë|&Euml;|\u00E8|&#xE8;|&#232;|è|&egrave;|\u00E9|&#xE9;|&#233;|é|&eacute;|\u00EA|&#xEA;|&#234;|ê|&ecirc;|\u00EB|&#xEB;|&#235;|ë|&euml;)","gi"),'e');
new_string = new_string.replace(RegExp("(\u0069|&#x69|&#105;|\u00CC|&#xCC|&#204;|Ì|&Igrave;|\u00CD|&#xCD|&#205;|Í|&Iacute;|\u00CE|&#xCE|&#206;|Î|&Icirc;|\u00CF|&#xCF|&#207;|Ï|&Iuml;|\u00EC|&#xEC|&#236;|ì|&igrave;|\u00ED|&#xED|&#237;|í|&iacute;|\u00EE|&#xEE|&#238;|î|&icirc;|\u00EF|&#xEF|&#239;|ï|&iuml;)","gi"),'i');
new_string = new_string.replace(RegExp("(\u006E|&#x6E|&#110;|\u00D1|&#xD1|&#209;|Ñ|&Ntilde;|\u00F1|&#xF1|&#241;|ñ|&ntilde;)","gi"),'n');
new_string = new_string.replace(RegExp("(\u006F|&#x6F|&#111;|\u00D2|&#xD2|&#210;|Ò|&Ograve;|\u00D3|&#xD3|&#211;|Ó|&Oacute;|\u00D4|&#xD4|&#212;|Ô|&Ocirc;|\u00D5|&#xD5|&#213;|Õ|&Otilde;|\u00D6|&#xD6|&#214;|Ö|&Ouml;|\u00F2|&#xF2|&#242;|ò|&ograve;|\u00F3|&#xF3|&#243;|ó|&oacute;|\u00F4|&#xF4|&#244;|ô|&ocirc;|\u00F5|&#xF5|&#245;|õ|&otilde;|\u00F6|&#xF6|&#246;|ö|&ouml;|\u00F8|&#xF8|&#248;|ø|&oslash;)","gi"),'o');
new_string = new_string.replace(RegExp("(\u0075|&#x75|&#117;|\u00D9|&#xD9|&#217;|Ù|&Ugrave;|\u00DA|&#xDA|&#218;|Ú|&Uacute;|\u00DB|&#xDB|&#219;|Û|&Ucirc;|\u00DC|&#xDC|&#220;|Ü|&Uuml;|\u00F9|&#xF9|&#249;|ù|&ugrave;|\u00FA|&#xFA|&#250;|ú|&uacute;|\u00FB|&#xFB|&#251;|û|&ucirc;|\u00FC|&#xFC|&#252;|ü|&uuml;)","gi"),'u');
new_string = new_string.replace(RegExp("(\u0079|&#x79|&#121;|\u00DD|&#xDD|&#221;|Ý|&Yacute;|\u00FD|&#xFD|&#253;|ý|&yacute;|\u00FF|&#xFF|&#255;|ÿ|&yuml;)","gi"),'y');
new_string = new_string.replace(RegExp("(\u00C6|&#xC6|&#198;|Æ|&AElig;|\u00E6|&#xE6|&#230;|æ|&aelig;)","gi"),'ae');
new_string = new_string.replace(RegExp("(\u008C|&#x8C|&#140;|Œ|&OElig;|\u009C|&#x9C|&#156;|œ|&oelig;)","gi"),'oe');
return new_string;
}

function searchcss() {
document.getElementById("q").style.border = "solid #ff9933 2px;";
document.getElementById("q").style.fontSize = "12px";
document.getElementById("q").style.lineHeight = "11px";
document.getElementById("q").style.width = "200px";
}

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

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

function lettre() {
	if ((this.formlettre.email.value.length < 1)||(this.formlettre.email.value=='Tapez votre email ici...')) {
   	window.alert("Veuillez entrer votre adresse email\ndans le champ du formulaire, merci.");
   	this.formlettre.email.focus();
   	return false;
	}
}

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

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

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

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

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 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 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.cal.elements["jour"].value;
  mm = document.cal.elements["mois"].value;
  aaaa = document.cal.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 testSaisie_2()
{
  jj1 = document.cal.elements["jour1"].value;
  mm1 = document.cal.elements["mois1"].value;
  aaaa1 = document.cal.elements["annee1"].value;
  jj2 = document.cal.elements["jour2"].value;
  mm2 = document.cal.elements["mois2"].value;
  aaaa2 = document.cal.elements["annee2"].value;
  if (testDate(jj1,mm1,aaaa1)&&testDate(jj2,mm2,aaaa2)) return true;
  else 
  {
    window.alert("Veuillez verifier les dates qui ne semblent pas correctes, merci.");
    return false;
  }
}

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

function montre_cache (quoi) {
	if (document.getElementById) {
		var pour = document.getElementById(quoi).style;
		if (pour.display == "block") {
			pour.display = "none";
			} else {
			pour.display = "block";
			}
			return false;
		} else {
		return true;
	}
}

function login() {
	if ((document.formlogin.email.value == "Tapez votre email")||(document.formlogin.email.value=='')) {
		window.alert("Veuillez entrer votre email, merci.");
		document.formlogin.email.focus();
		return false;
		}
		else if ((document.formlogin.pass.value=='00000000')||(document.formlogin.pass.value=='')) {
		window.alert("Veuillez entrer votre mot de passe, merci.");
		document.formlogin.pass.focus();
		document.getElementById('inf').innerHTML = '<a href=\"./?action=abonne&service=password\" target=\"_parent\">Retrouver votre mot de passe ?</a>';
		return false;
		}
}
function Submit_Form() {
    document.getElementById('valider').disabled=true;
    document.getElementById('submitmess').innerHTML='<img src=\"images/waiting.gif\" border=\"0\">';
}

function onClose(){
if(window.screenTop>10000)
{
fenetre=window.open("/partenaires/","fenetre","status=yes,directories=yes,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes,location=yes,width=840,height=720,top=0,left=0")}
}


function test_poids()
{
if (isNaN(document.bilan_poids.Age.value)||(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 (isNaN(document.bilan_poids.Taille.value)||(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 (isNaN(document.bilan_poids.Poids.value)||(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!='-----------------')&&(isNaN(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!='-----------------')&&(isNaN(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;
}
}

function test_programme()
{
if (isNaN(document.bilan_poids.Age.value)||(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 (isNaN(document.bilan_poids.Taille.value)||(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 (isNaN(document.bilan_poids.Poids.value)||(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.sexe.value=='f') {document.programme_partenaire.gender.value = 0;} else {document.programme_partenaire.gender.value = 1;}
document.programme_partenaire.age.value = document.bilan_poids.Age.value;
document.programme_partenaire.height.value = document.bilan_poids.Taille.value;
document.programme_partenaire.weight.value = document.bilan_poids.Poids.value;
}

function test_pdukan()
{
if (isNaN(document.bilan_poids.Age.value)||(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 (isNaN(document.bilan_poids.Taille.value)||(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 (isNaN(document.bilan_poids.Poids.value)||(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.sexe.value=='f') {document.programme_partenaire.user_type.value = 1;} else {document.programme_partenaire.user_type.value = 0;}
document.programme_partenaire.age.value = document.bilan_poids.Age.value;
document.programme_partenaire.size.value = document.bilan_poids.Taille.value;
document.programme_partenaire.weighToday.value = document.bilan_poids.Poids.value;
}

function ecrire(ident,texte)
{
document.getElementById(ident).innerHTML = texte;
}

function twNeowin(wurl,wnom,w,h,ws) { 
  var options = "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0, scrollbars="+ws+",width="+w+",height="+h;
  var twNeowin = window.open(wurl, wnom, options);
  if(twNeowin.focus){twNeowin.focus();} 
}

function verifmail()
{
var x = document.getElementById('form_???').mail;
					     var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
					     if (  !filter.test(x.value) || x.value.length < 7)   {
						     alert("Votre adresse E-mail ne semble pas valide !");
						     x.focus();
						     return false ;
					     }
}
