function confSupp()
{
	if(confirm('Etes vous sûr(e) de vouloir supprimer cet élément ?'))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ajouterAListe(champs_id, liste_id, err_txt, plus)
{
	var item = document.getElementById(champs_id).options[document.getElementById(champs_id).options.selectedIndex];
	var la_liste = document.getElementById(liste_id);
	
	if (item.value != "")
	{
		if (plus != "")
			la_liste.options[la_liste.options.length] = new Option(plus + ' : ' + item.text, plus + ':' + item.value + ':' + item.text);
		else
			la_liste.options[la_liste.options.length] = new Option(item.text, item.value);
		document.getElementById(champs_id).options.selectedIndex = 0;
	}
	else if (err_txt != "")
		alert(err_txt);
}

function retirerAListe(liste_id, err_txt)
{
	var la_liste = document.getElementById(liste_id);
	if (la_liste.options.selectedIndex >= 0)
		la_liste.options[la_liste.options.selectedIndex] = null;
	else if (err_txt != "")
		alert(err_txt);
}

function valide_produit()
{
	la_liste = document.getElementById('categs');
	for(i = 0; i < la_liste.length; i++){
		la_liste.options[i].selected = true;
	}
}

function toggleProduct(obj, id_total)
{
	var total = document.getElementById(id_total);

	if (obj.checked == true)
	{
		// Cas de l'ajout
		obj.checked = true;
		total.value = parseInt(total.value)+parseInt(obj.value);
	}
	else
	{
		// Cas de la suppression
		obj.checked = false;
		total.value = parseInt(total.value)-parseInt(obj.value);
	}
}

function addArticle(select_name, id_total)
{
	var total = document.getElementById(id_total);
	var selects = document.getElementsByName(select_name);
	var somme = 0;
	
	for (var i = 0; i < selects.length; i++)
	{
		var obj = selects[i];
		if (obj.options[obj.selectedIndex].value != '-1')
		{
			somme = somme+parseFloat(obj.options[obj.selectedIndex].value.replace(new RegExp('[0-9]+_'), ''));
		}
	}
	if (somme != 0)
	{
		total.value = somme;
	}
}

function echangeValid()
{
	var estSup = (parseFloat(document.getElementById('total_commande').value) > (parseFloat(document.getElementById('total_livre').value)+5));
	var estInf = (parseFloat(document.getElementById('total_commande').value) < (parseFloat(document.getElementById('total_livre').value)-5));
	
	if (!estSup && !estInf)
	{
		return true;
	}
	alert('Vous devez sélectionner pour le même montant de produits');
	return false;
}

function IE_CorrectAlpha_PNG(){
for(i=0; i<document.images.length; i++){
img = document.images[i];
imgExt = img.src.substring(img.src.length-3, img.src.length);
imgExt = imgExt.toUpperCase();
if (imgExt == "PNG"){
imgID = (img.id) ? "id='" + img.id + "' " : "";
imgClass= (img.className) ? "class='" + img.className + "' " : "";
imgTitle= (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
imgStyle= "display:inline-block;" + img.style.cssText;
if (img.align == "left") { imgStyle = "float:left;" + imgStyle; } else if (img.align == "right"){ imgStyle = "float:right;" + imgStyle; }
if (img.parentElement.href) { imgStyle = "cursor:hand;" + imgStyle; }
strNewHTML = '<span '+imgID+imgClass+imgTitle+' style="width:'+img.width+'px; height:'+img.height+'px;'+imgStyle+';'+'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img.src+'\', sizingMethod=\'scale\');"></span>';
img.outerHTML = strNewHTML;
i = i-1;
}}}

if (navigator.appName == 'Microsoft Internet Explorer')
	window.attachEvent("onload", IE_CorrectAlpha_PNG); 
