/*ETES VOUS CONNECTE ? ABONNEMENT RECETTE */

function ajaxIsConnectRec(argRubrique, argTitre) {
	var xhr=null;
	var tmpRandom;
	
	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur

	xhr.onreadystatechange = function() {
		test_result_ajaxRec(xhr, argRubrique, argTitre);
	};
	//on appelle la fonction php Abonnementrecette.php
	tmpRandom = Math.round(100*Math.random());
	Vadresse = "/isconnect.php?jj="+tmpRandom;
	xhr.open("GET",Vadresse, true);
	xhr.send(null);
}

function test_result_ajaxRec(xhr, argRubrique, argTitre)
{
	var reponse;
	var docXML= xhr.responseXML;
	if(xhr.readyState == '4' && xhr.status == 200){
		var items = docXML.getElementsByTagName("valeur")
		//on fait juste une boucle sur chaque élément "donnee" trouvé

		for (i=0;i<items.length;i++)
		{
			// si logge == OK
			if(items.item(i).firstChild.data == "true"){

				var xhr=null;
				if (window.XMLHttpRequest)
				{
				xhr = new XMLHttpRequest();
				}
				else if (window.ActiveXObject)
				{
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				//on définit l'appel de la fonction au retour serveur

				xhr.onreadystatechange = function() {
					deja_abonne_recette(xhr, argRubrique, argTitre);
				};
				//on appelle la fonction php Abonnementrecette.php
				xhr.open("GET", "/affThemes.php", true);
				xhr.send(null);

			}else{
				ShowHide('inscrire_compte','visible');
			}
		}
	}
}	

function deja_abonne_recette(xhr, argRubrique, argTitre){

	var docXML= xhr.responseXML;
	if(xhr.readyState == '4' && xhr.status == 200){
		// recup des recettes si possible
		try{
				/// test recettes ds xml
				var test_recette  = docXML.getElementsByTagName("id_recette")[0].firstChild.nodeValue;

				document.getElementById("argTitre").innerHTML = "<p>Vous Ãªtes abonné au thÃ¨me</p><p class='texte_different_infobulle'>"+argTitre+"</p>";
				document.getElementById("btn").innerHTML = " ";
		}catch(e){
				document.getElementById("btn").innerHTML = '<a href="#"><img id="btnx" src="/Images2/ok_recettes.gif" style="vertical-align: text-bottom;" onclick="abonner(\'tcm:2-37-4\',\'Recette\');"></a>';
				document.getElementById("argTitre").innerHTML = '<p>Vous souhaitez vous abonner au thÃ¨me </p><p class="texte_different_infobulle">'+argTitre+"</p><p>En vous abonnant, vous pourrez consulter les deux derniÃ¨res Recettes du site</p>";
		}
		montre('TipLayer');
	}
}

function montre(object){
  if (document.layers && document.layers[object])
    { 
    document.layers[object].visibility = 'visible';
    } 
  else if (document.all)
    {
    document.all[object].style.visibility = 'visible';
    document.all[object].style.zIndex = 100;
    }
  else if (document.getElementById) 
    {
    document.getElementById(object).style.visibility = 'visible';
	document.getElementById(object).style.zIndex = 100; 
    } 
}


function cache(object) {
  if (document.layers && document.layers[object])
    { 
    document.layers[object].visibility = 'hidden';
    } 
  else if (document.all)
    { 
    document.all[object].style.visibility = 'hidden';
    }
  else if (document.getElementById) 
    {
    document.getElementById(object).style.visibility = 'hidden'; 
    } 
}


function ajaxAbonnementRecette(argRubTCM){
	var xhr=null;

	if (window.XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { alert_ajaxTheme(xhr); };

	//on appelle la fonction php inscriptRecette.php
	xhr.open("POST", "/Abonnementrecette.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("RubTCM="+argRubTCM);
}

function ajaxSuprAbonnRecette(argRubTCM){
	var xhr=null;
	if (window.XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { alert_ajaxTheme(xhr); };

	//on appelle la fonction php SupprAbonnementrecette.php
	xhr.open("POST", "/SupprAbonnementrecette.php", true);
	xhr.send("RubTCM="+argRubTCM);
}

//			/*RECETTES FAVORITES*/
//			function ajaxInsertRecette(rct_oid)
//			{
//				var xhr=null;
//
//				if (window.XMLHttpRequest){
//					xhr = new XMLHttpRequest();
//				}
//				else if (window.ActiveXObject)
//				{
//					xhr = new ActiveXObject("Microsoft.XMLHTTP");
//				}
//			//	xhr.onreadystatechange = function() { alert_recette_ajax(xhr); };
//				xhr.onreadystatechange = function() { ajaxAffiche(); };
//
//				//on appelle la fonction php insertRecetteFav.php
//				xhr.open("POST", "/insertRecetteFav.php", true);
//
//				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//				xhr.send("rct_oid="+rct_oid);
//			}

// function alert_recette_ajax(xhr)
//{
//	var code;
//	var iMax;
//	var iMax2;
//	var docXML= xhr.responseXML;
//	
//	if(xhr.readyState == '4' && xhr.status == 200){
//
//
//		var itemsTitre = docXML.getElementsByTagName("titre");
//		var itemsURL = docXML.getElementsByTagName("url");
//
//		if(itemsTitre.length<3){
//			iMax = itemsTitre.length;
//			iMax2 = itemsTitre.length;
//		}else{
//			iMax = itemsTitre.length;
//			iMax2 = 3;
//		}
//
//		//on fait juste une boucle sur chaque élément "url" trouvé
//		for (i=0;i<iMax;i++)
//		{
//			if(i==0){
//				code = "<div class=\"lyr3\"><p class=\"text1_lyr1\"><a href=\"#\" class=\"lien3_lyr1\">Mes recettes favorites <span  style=\"margin-left:140px;\">"+iMax+" articles</span></a><a href=\"#\" onclick=\"ShowHide('lyr2','hidden')\" class=\"lien3_lyr1\" style=\"margin-left:130px;\"><img src=\"/Images/fermer_articles_compte2_tcm2-1859.gif\" alt=\"\" style=\"vertical-align:text-bottom;\" /></a></p></div><div style=\"padding-top:7px;\"></div>";
//			}
//			code = code+"<div class=\"lyr4\"><p><a href=\""+itemsURL.item(i).firstChild.data+"\" class=\"lien1_lyr1\">&nbsp;<img src=\"/Images/puce1_menu_compte2_tcm2-1680.gif\" alt=\"\" />&nbsp;"+itemsTitre.item(i).firstChild.data+"</a></p></div>";
//			code = code+"<div class=\"lyr5\"><p>.......................................................................................</p></div>";
//			//code = code+"<div class=\"lyr7\"><p><a href=\"/"+ReplaceSpeURL(itemsNivlib.item(i).firstChild.data)+"\" class=\"lien4_lyr1\">"+itemsNivlib.item(i).firstChild.data+"</a></p></div>";
//			code = code+"<div class=\"lyr7\"><p></p></div>";
//			code = code+"<div class=\"lyr6\"><p><a style=\"cursor: pointer\" onclick=\"ajaxSuppr('"+itemsURL.item(i).firstChild.data+"','non')\"><img src=\"/Images/poubelle3_menu_compte_tcm2-1871.gif\" alt=\"\" onmouseover=\"this.src='/Images/poubelle2_menu_compte_tcm2-1872.gif'\" onmouseout=\"this.src='/Images/poubelle3_menu_compte_tcm2-1871.gif'\" /></a></p></div>";
//			code = code+"<div style=\"clear:both;\"></div>"
//		}
//		if(i==0){
//			document.getElementById('lyr2').innerHTML = "";
//		}else{
//			document.getElementById('lyr2').innerHTML = code+"<br /><p class=\"text2_lyr1\"><a href=\"#\" onclick=\"ShowHide('lyr2','hidden')\" class=\"lien2_lyr1\">&nbsp;&raquo; Fermer</a><a style=\"cursor: pointer\" onclick=\"ajaxSuppr('vide','oui', '')\" class=\"lien2_lyr1\"><span style=\"margin-left:330px;\">&raquo; Vider le panier</span></a></p></div>";;
//		}
//		for (i=0;i<iMax2;i++)
//		{
//			if(i==0){
//				code = "<p  style=\"padding-top:5px;\"><img src=\"/Images/puce1_menu_compte2_tcm2-1680.gif\" alt=\"\" class=\"marge_droite_et_gauche\" /><a href=\""+itemsURL.item(i).firstChild.data+"\" class=\"lien1_menu_compte2\">"+itemsTitre.item(i).firstChild.data+"</a></p>";
//			}
//			else
//			{
//				code = code+"<p><img src=\"/Images/puce1_menu_compte2_tcm2-1680.gif\" alt=\"\" class=\"marge_droite_et_gauche\" /><a href=\""+itemsURL.item(i).firstChild.data+"\" class=\"lien1_menu_compte2\">"+itemsTitre.item(i).firstChild.data+"</a></p>";
//			}
//		}
//		if(i==0){
//			document.getElementById('sc1').innerHTML = "";
//		}else{
//			document.getElementById('sc1').innerHTML = code+"<p><span class=\"texte1_menu_compte2\">></span><a style=\"cursor: pointer\" class=\"lien2_menu_compte2\" onclick=\"ShowHide('lyr2','visible')\">Tous mes articles favoris...</a></p><br />";
//		}
//	}
//
//	
//}

/*ARTICLES FAVORIS*/

function ajaxInsert(argRubrique, argType)
{
	var xhr=null;
	
	if (window.XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xhr.onreadystatechange = function() { alert_ajax(xhr); };
	//on appelle la fonction php insertFav.php
	xhr.open("POST", "/insertFav.php", true);

	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("argRubrique="+argRubrique+"&argType="+argType);
}


function ajaxSuppr(argRubrique, argGlobale, argType)
{
	var xhr=null;

	if (window.XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xhr.onreadystatechange = function() { alert_ajax(xhr); };
//	if(argGlobale == 'non'){
		//on appelle la fonction php insertFav.php
		xhr.open("POST", "/supprFav.php", true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send("argRubrique="+argRubrique+"&argType="+argType+"&argGlobale="+argGlobale);
//	}else{
//		//on appelle la fonction php insertFav.php
//		xhr.open("POST", "/viderFav.php", true);
//		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//		xhr.send("UrlCible="+argUrlCible);
//	}
}

function ajaxAffiche()
{
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}

	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { alert_ajax(xhr); };

	//on appelle la fonction php afficheFav.php
	var ulr = "/afficheFav.php?x="+Math.random();
	xhr.open("GET", ulr, true);
	xhr.send(null);
}

function alert_ajax(xhr)
{
	var code;
	var iMax;
	var iMax2;
	var docXML= xhr.responseXML;
	var i=0;
	
	if(xhr.readyState == '4' && xhr.status == 200){

	try{
		var itemsNivlib = docXML.getElementsByTagName("nivlib");
		var itemsTitre = docXML.getElementsByTagName("titre");
		var itemsURL = docXML.getElementsByTagName("url");
		var id		 = docXML.getElementsByTagName("id");
		var type	 = docXML.getElementsByTagName("type");

		if(itemsTitre.length<3){
			iMax = itemsTitre.length;
			iMax2 = itemsTitre.length;
		}else{
			iMax = itemsTitre.length;
			iMax2 = 3;
		}

		//on fait juste une boucle sur chaque élément "url" trouvé
		for (i=0;i<iMax;i++)
		{

		// generation 2e liste
			if(i==0){
				code = "<div class=\"lyr3\"><p class=\"text1_lyr1\"><a href=\"#\" class=\"lien3_lyr1\">Mes articles favoris <span  style=\"margin-left:140px;\">"+iMax+" articles</span></a><a href=\"#\" onclick=\"ShowHide('lyr2','hidden')\" class=\"lien3_lyr1\" style=\"margin-left:130px;\"><img src=\"/Images/fermer_articles_compte2_tcm2-1859.gif\" alt=\"\" style=\"vertical-align:text-bottom;\" /></a></p></div><div style=\"padding-top:7px;\"></div>";
			}
			code = code+"<div class=\"lyr4\"><p><a href=\""+itemsURL.item(i).firstChild.data+"\" class=\"lien1_lyr1\">&nbsp;<img src=\"/Images/puce1_menu_compte2_tcm2-1680.gif\" alt=\"\" />&nbsp;"+itemsTitre.item(i).firstChild.data+"</a></p></div>";
			code = code+"<div class=\"lyr5\"><p>.......................................................................................</p></div>";
			code = code+"<div class=\"lyr7\"><p><a href=\"/"+ReplaceSpeURL(itemsNivlib.item(i).firstChild.data)+"\" class=\"lien4_lyr1\">"+itemsNivlib.item(i).firstChild.data+"</a></p></div>";
			code = code+"<div class=\"lyr6\"><p><a style=\"cursor: pointer\" onclick=\"ajaxSuppr('"+id.item(i).firstChild.data+"','non','"+type.item(i).firstChild.data+"')\"><img src=\"/Images/poubelle3_menu_compte_tcm2-1871.gif\" alt=\"\" onmouseover=\"this.src='/Images/poubelle2_menu_compte_tcm2-1872.gif'\" onmouseout=\"this.src='/Images/poubelle3_menu_compte_tcm2-1871.gif'\" /></a></p></div>";
			code = code+"<div style=\"clear:both;\"></div>"
		}
		if(i==0){
			document.getElementById('lyr2').innerHTML = "";
			document.getElementById('lyr2').style.display = "none";
		}else{
			document.getElementById('lyr2').innerHTML = code+"<br /><p class=\"text2_lyr1\"><a href=\"#\" onclick=\"ShowHide('lyr2','hidden')\" class=\"lien2_lyr1\">&nbsp;&raquo; Fermer</a><a style=\"cursor: pointer\" onclick=\"ajaxSuppr('vide','oui', '')\" class=\"lien2_lyr1\"><span style=\"margin-left:330px;\">&raquo; Vider le panier</span></a></p></div>";;
		}
		

	// generation 1ere liste
		for (i=0;i<iMax2;i++)
		{
			if(i==0){
				code = "<p  style=\"padding-top:5px;\"><img src=\"/Images/puce1_menu_compte2_tcm2-1680.gif\" alt=\"\" class=\"marge_droite_et_gauche\" /><a href=\""+itemsURL.item(i).firstChild.data+"\" class=\"lien1_menu_compte2\">"+itemsTitre.item(i).firstChild.data+"</a></p>";
			}else{
				code = code+"<p><img src=\"/Images/puce1_menu_compte2_tcm2-1680.gif\" alt=\"\" class=\"marge_droite_et_gauche\" /><a href=\""+itemsURL.item(i).firstChild.data+"\" class=\"lien1_menu_compte2\">"+itemsTitre.item(i).firstChild.data+"</a></p>";
			}
		}
		
		// tous mes articles favoris
		if(i==0){
			document.getElementById('sc1').innerHTML = "";
		}else{
			document.getElementById('sc1').innerHTML = code+"<p><span class=\"texte1_menu_compte2\">></span><a style=\"cursor: pointer\" class=\"lien2_menu_compte2\" onclick=\"ShowHide('lyr2','visible')\">Tous mes articles favoris...</a></p><br />";
		}
	}catch(e){}	
	}

}


/*ETES VOUS CONNECTE ? VERSION ARTICLE FAVORIS*/

function ajaxIsConnectArt(argRubrique, argType) {
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur

	xhr.onreadystatechange = function() {
		test_result_ajaxArt(xhr, argRubrique, argType);
	};
	//on appelle la fonction php isconnect.php?jj=
	tmpRandom = Math.round(100*Math.random());
	Vadresse = "/isconnect.php?jj="+tmpRandom;
	xhr.open("GET", Vadresse, true);
	xhr.send(null);
}

function test_result_ajaxArt(xhr, argRubrique, argType)
{
	var reponse;
	var docXML= xhr.responseXML;

	if(xhr.readyState == '4' && xhr.status == 200 ){
		var items = docXML.getElementsByTagName("valeur")
		//on fait juste une boucle sur chaque élément "donnee" trouvé
		
		for (i=0;i<items.length;i++)
		{
			// si logge == OK
			if(items.item(i).firstChild.data == "true"){
				ajaxInsert(argRubrique, argType);
	//			if(argType == 'A'){
	//				ajaxInsert(argRubrique);
	//			}else{
	//				if(argType == 'R'){
	//					ajaxInsertRecette(argRubrique);
	//				}else{
	//					ajaxInscripTheme(argRubrique);
	//				}
	//			}
			}else{
				ShowHide('inscrire_compte','visible');
			}
		}
	}
}

/* INSCRIPTION AUX THEMES - MENU DU JOUR  */

function ajaxInscripTheme(argRubTCM)
{
	var xhr=null;

	if (window.XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { alert_ajaxTheme(xhr); };

	//on appelle la fonction php inscriptTheme.php
	xhr.open("POST", "/inscriptTheme.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("RubTCM="+argRubTCM);
}

function ajaxSuprTheme(argRubTCM, argGlobale)
{

	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { alert_ajaxTheme(xhr); };
	if(argGlobale=='non'){
		//on appelle la fonction php affthemes.php
		xhr.open("POST", "/supprThemes.php", true);
	}else{
		//on appelle la fonction php affthemes.php
		xhr.open("POST", "/supprRubrique.php", true);
	}
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("RubTCM="+argRubTCM);
}

function ajaxAfficheTheme()
{
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { alert_ajaxTheme(xhr); };

	//on appelle la fonction php affthemes.php
	xhr.open("GET", "/affThemes.php", true);
	xhr.send(null);
}

function alert_ajaxTheme(xhr)
{
	var code;
	var indice;
	var docXML= xhr.responseXML;
	var Kmax;
	code = "";
	if(xhr.readyState == '4' && xhr.status == 200){
	//alert(xhr.responseText);	
	// recup des recettes

	try{
			/// test recettes ds xml
            var test_recette  = docXML.getElementsByTagName("id_recette")[0].firstChild.nodeValue;
			code = code+"<h6 class=\"onglet2_menu_compte2\">Les recettes</h6><div class=\"conteneur_h6_menu_compte2\"><a style=\"cursor: pointer; margin-left:15px;\" onclick=\"ajaxSuprAbonnRecette()\"><img src=\"/Images/poubelle1_menu_compte_tcm2-1681.gif\" alt=\"\" /></a></div>";
			code = code+"<ul class=\"ul_menu_compte2\">";
			for(i=0;i<2;i++){
				var lien_recette  = '/' + docXML.getElementsByTagName("id_recette")[i].firstChild.nodeValue;
				var titre_recette = docXML.getElementsByTagName("titre_recette")[i].firstChild.nodeValue;
				titre_recette_lim = limit_len(titre_recette);
				code = code+"<ul class=\"ul_menu_compte2\"><li class=\"li_menu_compte2\"><a href=\"" + lien_recette + "\" class=\"lien1_menu_compte2\" title=\"" +  titre_recette + "\">"+titre_recette_lim+"</a></li>";
			}	
			code = code+"</ul>";

	}catch(e){
	}

	try{
	
		if(docXML.getElementsByTagName("url")){
		//on fait juste une boucle sur chaque élément "Rubrique" trouvé
 		var itemsArticle = docXML.getElementsByTagName("article");
		for (i=0;i<2;i++)
		{
			indice = i+1;
			code = code+"<h6 class=\"onglet"+FindMyIndice(itemsArticle[0].childNodes[i].tagName)+"_menu_compte2\">"+ReplaceSpe(itemsArticle[0].childNodes[i].tagName)+"<div class=\"conteneur_h6_menu_compte2\"><a style=\"cursor: pointer\" onclick=\"ajaxSuprTheme('"+itemsArticle[0].childNodes[i].childNodes[0].childNodes[0].childNodes[0].nodeValue+"','oui')\"><img src=\"/Images/poubelle1_menu_compte_tcm2-1681.gif\" alt=\"\" /></a></div></h6>"
			code = code+"<ul class=\"ul_menu_compte2\">";
			for (j=0;j<itemsArticle[0].childNodes[i].childNodes.length;j++)
			{
//				code = code+"<li class=\"li_menu_compte2\"><a href=/"+ReplaceSpeURL(itemsArticle[0].childNodes[i].tagName)+"/"+ReplaceSpeURL(itemsArticle[0].childNodes[i].childNodes[j].tagName)+"/ class=\"lien1_menu_compte2\"><b style='color:#FFFFFE'>"+ReplaceSpe(itemsArticle[0].childNodes[i].childNodes[j].tagName)+"</b></a><div class=\"conteneur_h6_menu_compte2\" ><a style=\"cursor: pointer\" onclick=\"ajaxSuprTheme('"+itemsArticle[0].childNodes[i].childNodes[j].childNodes[0].childNodes[0].nodeValue+"','non')\"><img src=\"/Images/poubelle3_menu_compte_tcm2-1871.gif\" alt=\"\" onmouseover=\"this.src='/Images/poubelle2_menu_compte_tcm2-1872.gif'\" onmouseout=\"this.src='/Images/poubelle3_menu_compte_tcm2-1871.gif'\" /></a></div></li>";
				code = code+"<li class=\"li_menu_compte2\"><a href=/"+ReplaceSpeURL(itemsArticle[0].childNodes[i].tagName)+"/"+ReplaceSpeURL(itemsArticle[0].childNodes[i].childNodes[j].tagName)+"/ class=\"lien1_menu_compte2\"><b style='color:#FFFFFE'>"+ReplaceSpe(itemsArticle[0].childNodes[i].childNodes[j].tagName)+"</b></a><div class=\"conteneur_h6_menu_compte2\" ><a style=\"cursor: pointer\" onclick=\"ajaxSuprTheme('"+itemsArticle[0].childNodes[i].childNodes[j].childNodes[0].childNodes[0].nodeValue+"','non')\"><img src=\"/Images/poubelle3_menu_compte_tcm2-1871.gif\" alt=\"\" onmouseover=\"this.src='/Images/poubelle2_menu_compte_tcm2-1872.gif'\" onmouseout=\"this.src='/Images/poubelle3_menu_compte_tcm2-1871.gif'\" style=\"margin-left:8px;\" /></a></div></li>";

				code = code+"<ul class=\"ul_menu_compte2\">";
				if(itemsArticle[0].childNodes[i].childNodes[j].childNodes.length > 9){
					Kmax = 9;
				}else{
					Kmax = itemsArticle[0].childNodes[i].childNodes[j].childNodes.length;
				}
				for (k=0;k<Kmax;k=k+3){
					string_txt = itemsArticle[0].childNodes[i].childNodes[j].childNodes[k+1].childNodes[0].nodeValue;
					string_txt_lim = limit_len(string_txt);
					code = code+"<li class=\"li_menu_compte2\"><a href=\""+itemsArticle[0].childNodes[i].childNodes[j].childNodes[k+2].childNodes[0].nodeValue+"\" class=\"lien1_menu_compte2\" title=\"" + string_txt + "\">&nbsp; <img src=\"/Images/puce2_menu_compte_tcm2-1862.gif\" /> "+ string_txt_lim + "</a></li>";

				}
				code = code+"</ul>";
			}
			code = code+"</ul>";
		}

		}

		}catch(e){

		}

		/// recup des menus
		if(docXML.getElementsByTagName("entree")[0].firstChild){
		var entre 	= docXML.getElementsByTagName("entree")[0].firstChild.nodeValue;
		entre_lim = limit_len(entre);
		}
		if(docXML.getElementsByTagName("plat")[0].firstChild){
		var plat  	= docXML.getElementsByTagName("plat")[0].firstChild.nodeValue;
		plat_lim = limit_len(plat);
		}
		if(docXML.getElementsByTagName("dessert")[0].firstChild){
		var dessert = docXML.getElementsByTagName("dessert")[0].firstChild.nodeValue;
		dessert_lim = limit_len(dessert);
		}
		
		if((docXML.getElementsByTagName("entree")[0].firstChild) || (docXML.getElementsByTagName("plat")[0].firstChild) || (docXML.getElementsByTagName("dessert")[0].firstChild)){
			if((entre != '0') && (plat != '0')){ 
				code = code+'<h6 class="onglet4_menu_compte2">Mon Nutri Menu du jour</h6>' +
							'<ul class="ul_menu_compte2"><li class="li_menu_compte2"><a href="/nutripratiq/nutri-menus/Nutrimenu7.php" class="lien1_menu_compte2" title=\"' + entre + '\" >- ' + entre_lim + '</a></li>' +
							'<li class="li_menu_compte2"><a href="/nutripratiq/nutri-menus/Nutrimenu7.php" class="lien1_menu_compte2" title=\"' + plat + '\">- ' + plat_lim + '</a></li>' +
							'<li class="li_menu_compte2"><a href="/nutripratiq/nutri-menus/Nutrimenu7.php" class="lien1_menu_compte2" title=\"' + dessert + '\">- ' + dessert_lim + '</a></li></ul>';
				i++;
			}	
		}

		if(code==""){
			document.getElementById('sc2').innerHTML = ""
		}else{
			document.getElementById('sc2').innerHTML = code
		}
	
	}
}

function limit_len(arg){
		if(arg.length > 22){
			arg = arg.substr(0, 22) + '...';  
		}
	return arg;	
}

/* LISTING PAR THEMES*/

function ajaxListing(argTCM)
{
	var xhr=null;

	if (window.XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xhr.onreadystatechange = function() { alert_ajaxListing(xhr); };
	//on appelle la fonction php ArticleParTheme.php
	xhr.open("POST", "/ArticleParTheme.php", true);

	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("TCMRub="+argTCM);	
}

function alert_ajaxListing(xhr)
{
	var code;
	var indice;
	var docXML= xhr.responseXML;
	var Kmax;
	try{
	code  = "<form action=\"\" method=\"\"><select id=\"select1\" class=\"select_espace_gym3\" onChange=\"javascript:document.location.href=this.options[this.options.selectedIndex].value;\">";
	code += "<option value=\"\" disabled=\"disabled\" selected=\"selected\">Vos exercices :</option>";
	if(xhr.readyState == '4' && xhr.status == 200){
		var itemsArticle = docXML.getElementsByTagName("article");
		//on fait juste une boucle sur chaque élément "Rubrique" trouvé
		for (i=0; i<itemsArticle[0].childNodes.length; i=i+2)
		{
			code = code + "<option value='" + itemsArticle[0].childNodes[i].childNodes[0].nodeValue + "'>"+itemsArticle[0].childNodes[i+1].childNodes[0].nodeValue+"</option>"
		}
		code += "</select></form>";
		document.getElementById('select_exos').innerHTML = code;
	}
	}catch(e){}	
}

/*ETES VOUS CONNECTE ? VERSION THEME*/

function ajaxIsConnectGym(argRubrique, argTitre) {
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { test_result_ajax_gym(xhr, argRubrique, argTitre); };
	//on appelle la fonction php isconnect.php?jj=
	tmpRandom = Math.round(100*Math.random());
	Vadresse = "/isconnect.php?jj="+tmpRandom;
	xhr.open("GET", Vadresse, true);
	xhr.send(null);
}

function test_result_ajax_gym(xhr, argRubrique, argTitre)
{
	var reponse;
	var docXML= xhr.responseXML;
	if(xhr.readyState == '4' && xhr.status == 200){
		var items = docXML.getElementsByTagName("valeur")
		//on fait juste une boucle sur chaque élément "donnee" trouvé

		for (i=0;i<items.length;i++)
		{
			// si logge == OK
			if(items.item(i).firstChild.data == "true"){
			
				var xhr=null;
				if (window.XMLHttpRequest)
				{
				xhr = new XMLHttpRequest();
				}
				else if (window.ActiveXObject)
				{
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				//on définit l'appel de la fonction au retour serveur

				xhr.onreadystatechange = function() {
					deja_abonne_gym(xhr, argRubrique, argTitre);
				};
				//on appelle la fonction php Abonnementrecette.php
				xhr.open("GET", "/affThemes.php", true);
				xhr.send(null);
				
			}else{
				ShowHide('inscrire_compte','visible');
			}
		}
	}
}

function deja_abonne_gym(xhr, argRubrique, argTitre){

	var docXML= xhr.responseXML;
	if(xhr.readyState == '4' && xhr.status == 200){
		// recup des recettes si possible
		try{
				/// test 
				var test  = docXML.getElementsByTagName(trim(argTitre))[0].firstChild.nodeValue;

				document.getElementById("argTitre").innerHTML = "<p>Vous Ãªtes abonné au thÃ¨me</p><p class='texte_different_infobulle'>"+argTitre+"</p>";
				document.getElementById("btn").innerHTML = " ";
		}catch(e){
				document.getElementById("btn").innerHTML = '<a href="#"><img id="btnx" src="/Images2/ok_gym.gif" style="vertical-align: text-bottom;" onclick="abonner(\'' + argRubrique + '\', \'' + argTitre + '\');"></a>';
				document.getElementById("argTitre").innerHTML = '<p>Vous souhaitez vous abonner au thÃ¨me </p><p class="texte_different_infobulle">'+argTitre+"</p><p>En vous abonnant, vous pourrez consulter les deux derniers articles du site</p>";
		}
		montre('TipLayer');
	}
}

function ReplaceSpe(argString){
	argString = argString.replace("Cote", "CÃ´té");
	argString = argString.replace("Developpement", "Développement");
	argString = argString.replace("Sante", "Santé");
	argString = argString.replace("vitalite", "vitalité");
	argString = argString.replace("Idee", "Idée");
	argString = argString.replace(/_/g, " ");
	return argString;
}

function ReplaceSpeURL(argString){
	argString = argString.replace("Idee_ligne_par_Taillefine", "Idee_ligne");
	argString = argString.replace(/é/g,'e');
	argString = argString.replace(/Ã /g,'a');
	argString = argString.replace(/Ã¨/g,'e');
	argString = argString.replace(/Ã´/g,'o');
	argString = argString.toLowerCase();
	argString = argString.replace(/ /g, "_");
	argString = argString.replace(/_/g, "-");
	return argString;
}
function FindMyIndice(argString){
	switch (argString) {
		case "Nutrition_magazine":
			argString = 1;
		break;
		case "La_NutriBox":
			argString = 4;
		break;
		case "Les_Marques":
			argString = 5;
		break;
		case "Recettes":
			argString = 2;
		break;
		case "Espace_Gym":
			argString = 3;
		break;
		case "Forum":
			argString = 6;
		break;
	}
	return argString;
}


/*SIGNALER UN ABUS SUR UN COMMENTAIRE*/

function ajaxAbus(argIdCom, argRetour) {
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	
	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { 
		if (xhr.readyState == 4 && xhr.status == 200){ 
			ShowHide('abus_commentaire','visible');
		}
	};       
	
	//on appelle la fonction php signalerabus.php
	xhr.open("POST", "/signalerabus.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("id_comment="+argIdCom);
}


/*AJOUTER UN PSEUDO A UN COMPTE*/

function ajaxPseudo(argPseudo, argRetour) {
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	
	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { 
		if(xhr.responseText == 1){
			window.location.reload();
		}
		else {
			var content = document.getElementById(argRetour);
			content.innerHTML = xhr.responseText ;
		}
	};       
	
	//on appelle la fonction php signalerabus.php
	xhr.open("POST", "/creerpseudo.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("pseudo="+argPseudo);
}

/*MOT DE PASSE OUBLIE*/

function ajaxMotDePasse(argEmail, argRetour) {
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	

	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { 
		if(xhr.responseText == 1){
			window.location.reload();
		}
		else {
			var content = document.getElementById(argRetour);
			content.innerHTML = xhr.responseText ;
		}
	};       
	
	//on appelle la fonction php signalerabus.php
	xhr.open("POST", "/motdepasseoublie.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("email="+argEmail);
}


/*IUP*/
function ajaxIUP(argIUP, argRetour) {
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	

	
	//on appelle la fonction php signalerabus.php
	xhr.open("POST", "/iup.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("IUP="+argIUP);
	//on définit l'appel de la fonction au retour serveur

	if(argRetour!=''){
		xhr.onreadystatechange = function() {
			parent.location.href = argRetour;
		};
	}
}

/*AUTHENTIFICATION*/

function ajaxAuthentification(argEmail, argPass, argRetour,argadr,argiup) {
	var xhr=null;
	

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	//on appelle la fonction php signalerabus.php
	xhr.open("POST", "/authentification.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("email="+argEmail+"&pass="+argPass);

	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { 
		if(xhr.responseText != "ko"){
		//	alert('');

			if(argRetour=="iup"){
				window.location.href = '/compte/inscription/pop_iup.php?adrretour='+argadr;
			}else if(argRetour=="iup2"){
				window.location.href = '/compte/inscription/pop_iup.php?adrretour='+argadr+'&chance=1';
			}else if(argRetour=="inscription"){
				if(argiup!=""){
					ajaxIUP(argiup, argadr);
				}else{
					parent.location.href = argadr;
				}
			}else{
				window.location.reload();
			}
		}else {
			var content = document.getElementById('retour_authentification');
			content.innerHTML = xhr.responseText ;
		}
	};       
	
	
}


/* BON DE REDUCTION */

function ajaxRecup_br()
{
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { set_ajax_br(xhr); };

	//on appelle la fonction php aff_nbr_br.php
	xhr.open("POST", "/aff_nbr_br.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send(null);
}

function set_ajax_br(xhr)
{
	if (xhr.readyState == 4 && xhr.status == 200){ 
		var docXML= xhr.responseXML;
		var txt1 = docXML.getElementsByTagName("str")[0].firstChild.nodeValue;
		txt = 'Il vous reste ' + txt1 + ' de'; 

		try{
		document.getElementById('br3').innerHTML = txt;
		}catch(e){}

		try{
			document.getElementById('bloc_reduction').innerHTML = txt1+' ';
		}catch(e){}

		try{
			if(txt1 == ' bon'){	
				document.getElementById('reduction').style.display = 'none';
			}else{
				document.getElementById('reduction').style.display = 'block';
			}
		}catch(e){}

	}
}

/* AFFICHAGE PLAT DU JOUR + IMAGE */

function ajax_plat_jour()
{
	var xhr2=null;

	if (window.XMLHttpRequest)
	{
		xhr2 = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr2 = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur
	xhr2.onreadystatechange = function() { aff_plat_jour(xhr2); };

	//on appelle la fonction php aff_nbr_br.php
	xhr2.open("POST", "/aff_mnu_jour.php", true);
	xhr2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr2.send(null);
}

function aff_plat_jour(xhr2)
{
	var docXML= xhr2.responseXML;

	if(xhr2.readyState == '4' && xhr2.status == 200){
	
        var plat = docXML.getElementsByTagName("plat")[0].firstChild.nodeValue;
		if (document.getElementById('plat_validation_finale')) {
		document.getElementById('plat_validation_finale').innerHTML = plat;
			if (document.getElementById('accomp_validation_finale')) {
				var accomp = docXML.getElementsByTagName("accomp")[0].firstChild.nodeValue;
				document.getElementById('accomp_validation_finale').innerHTML = accomp;
			}
			if (document.getElementById('image_validation_finale')) {
				var vignette = docXML.getElementsByTagName("image")[0].firstChild.nodeValue;
				//	document.getElementById('image_validation_finale').src = image;
				//	document.images['image_validation_finale'].src =  vignette;
				setTimeout('aff_image_val_final("'+ vignette +'")', 2000);
			}
			if (document.getElementById('img_vignette')) {
				var vignette = docXML.getElementsByTagName("vignette")[0].firstChild.nodeValue;
				setTimeout('aff_image("'+ vignette +'")', 2000);
			}else if(document.getElementById('img_tiers')){
				var vignette = docXML.getElementsByTagName("tiers")[0].firstChild.nodeValue;
				setTimeout('aff_image("'+ vignette +'")', 2000);
			}
			
		}
	}
}

function aff_image(vignette){
	if(document.images['img_vignette']){
	document.images['img_vignette'].src = vignette ;
}
    if(document.images['img_tiers']){
	document.images['img_tiers'].src = vignette ;
	}
	return;
}
function aff_image_val_final(vignette){
	document.images['image_validation_finale'].src = vignette ;
	return;
}

function ajaxIsConnectNutrimag(argRubrique, argTitre) {
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { test_result_ajax_Nutrimag(xhr, argRubrique, argTitre); };
	//on appelle la fonction php isconnect.php?jj=
	tmpRandom = Math.round(100*Math.random());
	Vadresse = "/isconnect.php?jj="+tmpRandom;
	xhr.open("GET", Vadresse, true);
	xhr.send(null);
}

function test_result_ajax_Nutrimag(xhr, argRubrique, argTitre)
{
	var reponse;
	var docXML= xhr.responseXML;
	if(xhr.readyState == '4' && xhr.status == 200){
		var items = docXML.getElementsByTagName("valeur")
		//on fait juste une boucle sur chaque élément "donnee" trouvé

		for (i=0;i<items.length;i++)
		{
			// si logge == OK
			if(items.item(i).firstChild.data == "true"){
			
				var xhr=null;
				if (window.XMLHttpRequest)
				{
				xhr = new XMLHttpRequest();
				}
				else if (window.ActiveXObject)
				{
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				//on définit l'appel de la fonction au retour serveur

				xhr.onreadystatechange = function() {
					deja_abonne_Nutrimag(xhr, argRubrique, argTitre);
				};
				//on appelle la fonction php Abonnementrecette.php
				xhr.open("GET", "/affThemes.php", true);
				xhr.send(null);
				
			}else{
				ShowHide('inscrire_compte','visible');
			}
		}
	}
}

function deja_abonne_Nutrimag(xhr, argRubrique, argTitre){

	var docXML= xhr.responseXML;

	var test_noeud = '';
	switch (argRubrique) {
		case 'tcm:2-221-4':
		test_noeud = 'Cote_enfants';
	break;
		case 'tcm:2-223-4':
		test_noeud = 'Developpement_durable';
		break;
	case 'tcm:2-33-4':
		test_noeud = 'Sante-Vitalite';
		break;
	case 'tcm:2-45-4':
		test_noeud = 'Idee_ligne_par_Taillefine';
		break;
	case 'tcm:2-53-4':
		test_noeud = 'Moments_Plaisir';
		break;
	case 'tcm:2-222-4':
		test_noeud = 'Jeunes_mamans';
		break;
	default: 
		break;
	}
	
	if(xhr.readyState == '4' && xhr.status == 200){
		// recup des recettes si possible
		try{
				/// test 
				var test  = docXML.getElementsByTagName(test_noeud)[0].firstChild.nodeValue;

				document.getElementById("argTitre").innerHTML = "<p>Vous Ãªtes abonné au thÃ¨me</p><p class='texte_different_infobulle'>"+argTitre+"</p>";
				document.getElementById("btn").innerHTML = " ";
		}catch(e){
				document.getElementById("btn").innerHTML = '<a href="#"><img id="btnx" src="/Images2/ok.gif" style="vertical-align: text-bottom;" onclick="abonner(\'' + argRubrique + '\', \'' + argTitre + '\');"></a>';
				document.getElementById("argTitre").innerHTML = '<p>Vous souhaitez vous abonner au thÃ¨me </p><p class="texte_different_infobulle">'+argTitre+"</p><p>En vous abonnant, vous pourrez consulter les deux derniers articles du site</p>";
		}
		montre('TipLayer');
	}
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ajaxAbonnAllGym(argTitre){
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//on définit l'appel de la fonction au retour serveur

	xhr.onreadystatechange = function() {
		test_result_ajax_abonn_all(xhr, argTitre);
	};
	//on appelle la fonction php Abonnementrecette.php
	tmpRandom = Math.round(100*Math.random());
	Vadresse = "/isconnect.php?jj="+tmpRandom;	
	xhr.open("GET", Vadresse, true);
	xhr.send(null);
}

function test_result_ajax_abonn_all(xhr, argTitre)
{
	var reponse;
	var docXML= xhr.responseXML;
	if(xhr.readyState == '4' && xhr.status == 200){
		var items = docXML.getElementsByTagName("valeur")
		//on fait juste une boucle sur chaque élément "donnee" trouvé

		for (i=0;i<items.length;i++)
		{
			// si logge == OK
			if(items.item(i).firstChild.data == "true"){
			
				var xhr=null;
				if (window.XMLHttpRequest)
				{
				xhr = new XMLHttpRequest();
				}
				else if (window.ActiveXObject)
				{
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				//on définit l'appel de la fonction au retour serveur

				xhr.onreadystatechange = function() {
					deja_abonne_all_gym(xhr, argTitre);
				};
				//on appelle la fonction php Abonnementrecette.php
				xhr.open("GET", "/affThemes.php", true);
				xhr.send(null);
				
			}else{
				ShowHide('inscrire_compte','visible');
			}
		}
	}
}	

function deja_abonne_all_gym(xhr, argTitre){

	var docXML= xhr.responseXML;
	if(xhr.readyState == '4' && xhr.status == 200){
		// recup des recettes si possible
		try{
			var Tableau_gym = new Array("Relaxation", "Ventre", "Jambes", "Silhouette");
			for(var i=0; i < Tableau_gym.length; i++){
				var test_gym = docXML.getElementsByTagName(Tableau_gym[i])[0].firstChild.nodeValue;
				document.getElementById("argTitre").innerHTML = "<p>Vous Ãªtes abonné au thÃ¨me </p><p class='texte_different_infobulle'>"+argTitre+"</p>";
				document.getElementById("btn").innerHTML = " ";
			}
		}catch(e){
				document.getElementById("btn").innerHTML = '<a href="#"><img id="btnx" src="/Images2/ok_gym.gif" style="vertical-align: text-bottom;" onclick="abonner(\'Gym\',\''+argTitre+'\');"></a>';
				document.getElementById("argTitre").innerHTML = '<p>Vous souhaitez vous abonner au thÃ¨me </p><p class="texte_different_infobulle">'+argTitre+"</p><p>En vous abonnant, vous pourrez consulter les derniers articles du site</p>";
		}
		montre('TipLayer');
	}
}

function envoyer_article_mail(dTitre,dChapo){
		//Parametres Ã  récuperer
		var dUrl = document.location.href;
		var dPrenom = document.getElementsByName("prenom")[0].value;
		var dMail = document.getElementsByName("votre_email")[0].value;
		var dMailDestinataire = document.getElementsByName("email_destinataire")[0].value;
		var dMessage = document.getElementsByName("message")[0].value;
	
		//On cache le 1er div et on montr le 2eme
		document.getElementById("ndiv2").style.visibility="visible";
		document.getElementById("ndiv").style.visibility="hidden";
		
		//Ajax pour envoyer le mail
		if (window.XMLHttpRequest)                
		{ 
			xhr = new XMLHttpRequest();    
		} 
		else 
		if (window.ActiveXObject)                    
		{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");  
		}
	
		
		xhr.open( "POST", "/envoie_mail.php",  true);
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xhr.send("chapo="+dChapo+"&titre="+dTitre+"&url="+dUrl+"&prenom="+dPrenom+"&votre_email="+dMail+"&email_destinataire="+dMailDestinataire+"&message="+dMessage); 			
}

function envoyer_article_mail_nutri(dTitre,dChapo,typeNutri){
		//Parametres Ã  récuperer
		if(typeNutri=="menu"){
			var dUrl = document.location.href+"/nutripratiq/nutri-menus/";
		}else if(typeNutri=="produit"){
			var dUrl = document.location.href+"/nutripratiq/nutri-produits/";
		}else if(typeNutri=="repere"){
			var dUrl = document.location.href+"/nutripratiq/nutri-repere/";
		}else if(typeNutri=="dialogue"){
			var dUrl = document.location.href+"/nutripratiq/nutri-dialogue/";
		}
		
		if(typeNutri=="repere"){
			var num = 0;
		}else if(typeNutri=="dialogue"){
			var num = 1;
		}else if(typeNutri=="produit"){
			var num = 2;
		}else if(typeNutri=="menu"){
			var num = 3;
		}
		
		var dPrenom = document.getElementsByName("prenom")[num].value;
		var dMail = document.getElementsByName("votre_email")[num].value;
		var dMailDestinataire = document.getElementsByName("email_destinataire")[num].value;
		var dMessage = document.getElementsByName("message")[num].value;
	
		//On cache le 1er div et on montr le 2eme
		document.getElementById("ndiv2").style.visibility="visible";
		
		if(typeNutri=="menu"){
			document.getElementById("ndiv_menu").style.visibility="hidden";
		}else if(typeNutri=="produit"){
			document.getElementById("ndiv_produit").style.visibility="hidden";
		}else if(typeNutri=="repere"){
			document.getElementById("ndiv_repere").style.visibility="hidden";
		}else if(typeNutri=="dialogue"){
			document.getElementById("ndiv_dialogue").style.visibility="hidden";
		}
		
		//Ajax pour envoyer le mail
		if (window.XMLHttpRequest)                
		{ 
			xhr = new XMLHttpRequest();    
		} 
		else 
		if (window.ActiveXObject)                    
		{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");  
		}
	
		
		xhr.open( "POST", "/envoie_mail.php",  true);
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xhr.send("chapo="+dChapo+"&titre="+dTitre+"&url="+dUrl+"&prenom="+dPrenom+"&votre_email="+dMail+"&email_destinataire="+dMailDestinataire+"&message="+dMessage); 			
}

/**********************************************Liste des BR pour la recharge de la page lors de l'authentification********************************************************/
function ajaxListebr(agrParam){
	var xhr=null;
	alert(agrParam);
	if (window.XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}

	//on appelle la fonction php Listebr.php
	xhr.open("POST", "/Listebr.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("Param="+agrParam);
}

function ajaxcheckgagnant(){
	var xhr=null;

	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	
		
	//on appelle la fonction php signalerabus.php
	xhr.open("POST", "/checkgagnant.php", true);
	
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	
	xhr.send("IUP=");
	//on dÃƒÂ©finit l'appel de la fonction au retour serveur
	xhr.onreadystatechange = function() { 
		window.location.href = '/minisites/90ans/exclusif_abonnes_magazine_danone_et_vous/decouvrez-si-vous-avez-gagne.php' ;
	};
}