//correspond à un import
document.write('<SCRIPT LANGUAGE="Javascript" src="functions/js/lib-ajax.js"></SCRIPT>');

function ajaxmenu()
{ 
	getXhr(); 
	xhr.onreadystatechange = function()
	{ 
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			var ind=document.getElementById('pays_hote').selectedIndex;
			var valeur=document.getElementById('pays_hote').options[ind].value;
			if (ind==0)
			{
				var chaine = xhr.responseText;
			}
			var i;
			//alert(chaine);
			var pays;
			var id_pays;
			var tableau_pays = chaine.split('|');
			for(var j=1; j<tableau_pays.length+1; j++)
			{
				if (document.getElementById('representation').options[j]!=null)
				{
					document.getElementById('pays_hote').options[j].value = null;
					document.getElementById('pays_hote').options[j].text = null;
				}
			}
			for (i=0;i<tableau_pays.length-1;i++)
			{
				pays=tableau_pays[i].split('/');
				id_pays=pays[0];
				pays=pays[1];
				new_element=new Option(pays,id_pays,false,true);
				document.getElementById('pays_hote').options[i+1] = new_element;
			}
			/*for (i=0;i<tableau_pays.length-1;i++){
				if (document.getElementById('pays_hote').options[i].text==valeur){
					document.getElementById('pays_hote').selectedIndex=i;
				}
			}*/
			document.getElementById('pays_hote').selectedIndex=0;
			//new_element=new Option(chaine,chaine,false,true);
			//document.getElementById('time').value = chaine;
			//document.getElementById('pays_hote').options[0] = new_element;
		}
	}
	var valeur_menu;
	var ind_valeur_menu;
	ind_valeur_menu=document.getElementById('representation').selectedIndex;
	valeur_menu=document.getElementById('representation').options[ind_valeur_menu].value;
	xhr.open("POST",'functions/php/generation-menu.php',true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	if (valeur_menu!="")
	{
		xhr.send("valeur="+valeur_menu);
	}
	else
	{
		xhr.send("init=");
	}
	//xhr.send("cdcl=1");
}


function ajaxmenu2()
{ 
	getXhr(); 
	xhr.onreadystatechange = function()
	{ 
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			var ind=document.getElementById('representation').selectedIndex;
			var valeur=document.getElementById('representation').options[ind].value;
			if (ind==0)
			{
				var chaine = xhr.responseText;
			}
			var i;
			//alert(chaine);
			var ind=document.getElementById('representation').selectedIndex;
			var valeur=document.getElementById('representation').options[ind].value;
			var pays;
			var id_pays;
			var tableau_pays = chaine.split('|');
			for(var j=1; j<tableau_pays.length+1; j++)
			{
				if (document.getElementById('representation').options[j]!=null)
				{
					document.getElementById('representation').options[j].value = null;
					document.getElementById('representation').options[j].text = null;
				}
			}
			for (i=0;i<tableau_pays.length-1;i++)
			{
				pays=tableau_pays[i].split('/');
				id_pays=pays[0];
				pays=pays[1];
				new_element=new Option(pays,id_pays,false,true);
				document.getElementById('representation').options[i+1] = new_element;
			}
			document.getElementById('representation').selectedIndex=0;
		}
	}
	var valeur_menu;
	var ind_valeur_menu;
	ind_valeur_menu=document.getElementById('pays_hote').selectedIndex;
	valeur_menu=document.getElementById('pays_hote').options[ind_valeur_menu].value;
	xhr.open("POST",'functions/php/generation-menu.php',true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	if (valeur_menu!="")
	{
		xhr.send("valeur="+valeur_menu);
	}
	else
	{
		xhr.send("init=");
	}
}