function suppLivraison(lien)
{
	if(confirm("Êtes-vous certain(e) de vouloirs supprimer cette case livraison?"))
	{
		document.location.href = lien;
	}
}

function validerCommande()
{
	var err = "";
	
	var compagnie = document.getElementById("compagnie").value;
	var prenom = document.getElementById("prenom").value;
	var nom = document.getElementById("nom").value;
	var nocivique = document.getElementById("nocivique").value;
	var rue = document.getElementById("rue").value;
	var ville = document.getElementById("ville").value;
	var codepostal = document.getElementById("codepostal").value;
	var telind = document.getElementById("telind").value;
	var telno = document.getElementById("telno").value;
	var sujet = document.getElementById("sujet").value;
	var po = document.getElementById("po").value;
	var description = document.getElementById("description").value;
	var courriel = document.getElementById("courriel").value;
	
	if(compagnie == "")
	{
		err += "Le champs compagnie est requis.\r\n";
	}
	
	if(prenom == "")
	{
		err += "Le champs prénom est requis.\r\n";
	}
	
	if(nom == "")
	{
		err += "Le champs nom est requis.\r\n";
	}
	
	if(nocivique == "")
	{
		err += "Le champs numéro civique est requis.\r\n";
	}
	
	if(rue == "")
	{
		err += "Le champs rue est requis.\r\n";
	}
	
	if(ville == "")
	{
		err += "Le champs ville est requis.\r\n";
	}
	
	if(codepostal == "")
	{
		err += "Le champs code postal est requis.\r\n";
	}
	
	if((telind == "") || (telno == ""))
	{
		err += "Le champs numéro de téléphone est requis.\r\n";
	}
	
	if(sujet == "")
	{
		err += "Le champs sujet est requis.\r\n";
	}
	
	if(po == "")
	{
		err += "Le champs PO est requis.\r\n";
	}
	
	if(description == "")
	{
		err += "Le champs description est requis.\r\n";
	}	
	
	if(courriel == "")
	{
		err += "Le champs courriel est requis.\r\n";
	}	
	else	
	{
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(courriel)) 
		{
				err += "Le champs courriel n'est pas valide.\r\n";
		}
	}
	
	if(err != "")
		alert(err);
	else
		document.getElementById("compagnie").form.submit();
}


function suppNouvelle(page, id)
{
	if(confirm("Êtes-vous certains de vouloir supprimer cette nouvelle?"))
	{
		document.location.href = page + "&action=supprimer&id=" + id;
	}
}

function suppClient(page, id)
{
	if(confirm("Êtes-vous certains de vouloir supprimer ce client?"))
	{
		document.location.href = page + "&action=supprimer&id=" + id;
	}
}

function enterSubmit(event, txt)
{
	if(event.keyCode == 13)
	{
		if (event) 
			keycode = event.keyCode;
		else if (e) 
			keycode = e.which;
		else return true;

		if (keycode == 13)
		{
		   txt.form.submit();
		   return false;
		}
		else
		   return true;
	}
}

function initNav()
{
	if (typeof document.body.style.maxHeight == 'undefined')
	{
		var nav = document.getElementById("navigation");
		if(nav)
		{
			var lis = nav.getElementsByTagName("li");
			for (var i=0; i<lis.length; i++)
			{
				lis[i].onmouseover = function()
				{
					this.className += " hover";
				}
				lis[i].onmouseout = function()
				{
					this.className = this.className.replace(" hover", "");
				}
			}
		}
	}
}
function initNavWidth()
{
	var _ul = document.getElementById("navigation").getElementsByTagName("ul");
	var _max = 0;
	for (var i=0; i<_ul.length; i++)
	{
		var _a = _ul[i].getElementsByTagName("a");
		for (var j=0; j<_a.length; j++) {
			if (_a[j].parentNode.parentNode == _ul[i]) {
				if (_max < _a[j].offsetWidth)
					_max = _a[j].offsetWidth;
			}
		}
		_ul[i].parentNode.parentNode.style.width = (_max) + 40 + 'px';
		_max = 0;
	}
}

if (window.addEventListener)
{
	window.addEventListener("load", initNavWidth, false);
}
else if (window.attachEvent)
{
	window.attachEvent("onload", initNavWidth);
	window.attachEvent("onload", initNav);
}
