function loadFrmLivraison(Location,IdClient)
{
	var container = document.getElementById("divLivraison");
	container.style.left="5px";
	var xhr=null;
		if (window.XMLHttpRequest)
		{ 
			xhr = new XMLHttpRequest();
		}
			else if (window.ActiveXObject) 
			{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
				xhr.onreadystatechange = function()
				{
					// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
					if (xhr.readyState == 4)
					{
					var tbl = xhr.responseText;
					container.innerHTML = tbl;
					}
						else
						{
							container.innerHTML ="Chargement des coordonnées de livraison";
						}
				}
		xhr.open("POST", Location+"Ajax/ajaxCommande.php", true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
		xhr.send("action=loadFrmLivraison&Location="+Location+"&IdClient="+IdClient);	
}

function updateLivraison(Location,IdClient)
{
	var container=document.getElementById('divLivraison');
	var message=document.getElementById('MessageLivraison');
	var CurrentHeight = container.style.height;
	var Civilite=document.getElementById('CiviliteLivraison').value
	var Nom=document.getElementById('NomLivraison').value;
	var Prenom=document.getElementById('PrenomLivraison').value;
	var Adresse=document.getElementById('AdresseLivraison').value;
	var Cp=document.getElementById('CpLivraison').value;
	var Commune=document.getElementById('CommuneLivraison').value;
	var IdPays=document.getElementById('IdPaysLivraison').value;
	
	if (Civilite=="")
	{
		alert("Civilité est un champ obligatoire");
	}
	else if (Nom=="")
	{
		alert("Nom est un champ obligatoire");
	}
	else if (Prenom=="")
	{
		alert("Prénom est un champ obligatoire");
	}
	else if (Cp=="")
	{
		alert("Code postal est un champ obligatoire");
	}
	else if (Commune=="")
	{
		alert("Commune est un champ obligatoire");
	}
	else if (IdPays=="")
	{
		alert("Vous devez sélectionner un pays");
	}
	else
	{
	var xhr=null;
		if (window.XMLHttpRequest)
		{ 
			xhr = new XMLHttpRequest();
		}
			else if (window.ActiveXObject) 
			{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
				xhr.onreadystatechange = function()
				{
					// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
					if (xhr.readyState == 4)
					{
					var tbl = xhr.responseText;
					loadFrmLivraison(Location,IdClient);
					message.innerHTML="Adresse modifiée";
					
					}
						else
						{
							
							container.innerHTML ="Mise à jour en cours";
						}
				}
		xhr.open("POST", Location+"Ajax/ajaxCommande.php", true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
		xhr.send("action=updateLivraison&Location="+Location+"&IdClient="+IdClient+"&Civilite="+Civilite+"&Nom="+Nom+"&Prenom="+Prenom+"&Adresse="+Adresse+"&Cp="+Cp+"&Commune="+Commune+"&IdPays="+IdPays);
	}
}

function loadFrmFacturation(Location,IdClient)
{
	var container = document.getElementById("divFacturation");
	container.style.left="5px";
	var xhr=null;
		if (window.XMLHttpRequest)
		{ 
			xhr = new XMLHttpRequest();
		}
			else if (window.ActiveXObject) 
			{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
				xhr.onreadystatechange = function()
				{
					// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
					if (xhr.readyState == 4)
					{
					var tbl = xhr.responseText;
					container.innerHTML = tbl;
					}
						else
						{
							container.innerHTML ="Chargement des coordonnées de facturation";
						}
				}
		xhr.open("POST", Location+"Ajax/ajaxCommande.php", true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
		xhr.send("action=loadFrmFacturation&Location="+Location+"&IdClient="+IdClient);	
}

function updateFacturation(Location,IdClient)
{
	var container=document.getElementById('divFacturation');
	var message=document.getElementById('MessageFacturation');
	var CurrentHeight = container.style.height;
	var Civilite=document.getElementById('CiviliteFacturation').value
	var Nom=document.getElementById('NomFacturation').value;
	var Prenom=document.getElementById('PrenomFacturation').value;
	var Adresse=document.getElementById('AdresseFacturation').value;
	var Cp=document.getElementById('CpFacturation').value;
	var Commune=document.getElementById('CommuneFacturation').value;
	var IdPays=document.getElementById('IdPaysFacturation').value;
	
	if (Civilite=="")
	{
		alert("Civilité est un champ obligatoire");
	}
	else if (Nom=="")
	{
		alert("Nom est un champ obligatoire");
	}
	else if (Prenom=="")
	{
		alert("Prénom est un champ obligatoire");
	}
	else if (Cp=="")
	{
		alert("Code postal est un champ obligatoire");
	}
	else if (Commune=="")
	{
		alert("Commune est un champ obligatoire");
	}
	else if (IdPays=="")
	{
		alert("Vous devez sélectionner un pays");
	}
	else
	{
	var xhr=null;
		if (window.XMLHttpRequest)
		{ 
			xhr = new XMLHttpRequest();
		}
			else if (window.ActiveXObject) 
			{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
				xhr.onreadystatechange = function()
				{
					// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
					if (xhr.readyState == 4)
					{
					var tbl = xhr.responseText;
					loadFrmFacturation(Location,IdClient);
					message.innerHTML="Adresse modifiée";
					
					}
						else
						{
							
							container.innerHTML ="Mise à jour en cours";
						}
				}
		xhr.open("POST", Location+"Ajax/ajaxCommande.php", true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
		xhr.send("action=updateFacturation&Location="+Location+"&IdClient="+IdClient+"&Civilite="+Civilite+"&Nom="+Nom+"&Prenom="+Prenom+"&Adresse="+Adresse+"&Cp="+Cp+"&Commune="+Commune+"&IdPays="+IdPays);
	}
}