function show(parentId)
{
	myParent = document.getElementById(parentId);

	if ((myParent.style.display == "none") || (myParent.style.display == "hidden") || (myParent.style.display == "")) {
		myParent.style.display = "block"
		if(parentId == 'search') {
			document.getElementById('searching').focus();
		} else if (parentId == 'ajout') {
			document.getElementById('link').focus();
		} else {
			this.focus();
		}
	} else {
		myParent.style.display = "none"
	}
}

function expand(expand)
{
	show('menu_'+expand);
	expandId = 'expand_'+expand;
	dossierId = 'dossier_'+expand;
	objet = document.getElementById(expandId);
	etat = objet.alt;
	if (etat == '-') {
		objet.src = "/images/tree_expand.gif";
		objet.alt = "+";
		document.getElementById(dossierId).style.background = "url(images/dossier.gif) no-repeat";
	} else {
		objet.src = "/images/tree_collapse.gif";
		objet.alt = "-";
		document.getElementById(dossierId).style.background = "url(images/dossier2.gif) no-repeat";
	}
}

function limite(zone,max)
{
	if (zone.value.length >= max) {
		zone.value = zone.value.substring(0,max);
	}
}

function addFav()
{
	if (document.all) {
		window.external.AddFavorite(location.href, document.title);
	} else {
		alert('Avec un navigateur autre que Microsoft Internet Explorer, faites CTRL+D pour ajouter cette page à vos favoris automatiquement.');
	}
}

function quantite(ref,nb)
{
	box = document.getElementById("quantite");
	newnb = box.value;
	if ((!isNumeric(newnb)) || (newnb < 1)) {
		newnb = 1;
	} else {
		newnb = parseInt(newnb)+parseInt(nb);
	}
	box.value = newnb;
	document.getElementById("quantite_link").href = "scripts/panier.php?ref="+ref+"&qtte="+newnb;
}

function quantite_mod(ref)
{
	nb = document.getElementById("quantite").value;
	if ((nb < 1) || (!isNumeric(nb))) {
		nb = 1;
	}
	document.getElementById("quantite_link").href = "scripts/panier.php?ref="+ref+"&qtte="+nb;
}

function isNumeric(nb)
{
	numChars = ".0123456789";
	var isNum = true;
	var index = 0;
	while ((index < nb.length) && (isNum)) {
		isNum = (numChars.indexOf(nb.charAt(index)) != -1);
		index ++;
	}
	if (!isNum) {
		return false;
	} else {
		return true;
	}
}

function article_marque()
{
	document.getElementById('article_marque').value = document.getElementById('article_listemarques').value;
}

function article_modele()
{
	document.getElementById('article_voiture').value = document.getElementById('article_listevoitures').value;
}