function chgcoul(ob,ref,id){
	document.getElementById('ref'+id).innerHTML=ref+"-"+ob.value+"-"+document.getElementById('taille'+id).options[document.getElementById('taille'+id).selectedIndex].value;
}

function chgtaille(ob,ref,id){
	document.getElementById('ref'+id).innerHTML=ref+"-"+document.getElementById('coul'+id).options[document.getElementById('coul'+id).selectedIndex].value+"-"+ob.value;
}

function chgcond(ob,id){
	document.getElementById('prix'+id).selectedIndex=ob.selectedIndex;
	document.getElementById('affprix'+id).innerHTML="&nbsp;<b>"+document.getElementById('prix'+id).options[ob.selectedIndex].value+"</b> Euros";
	document.getElementById('idProd['+id+']').value=ob.options[ob.selectedIndex].text;	
}

function chgcondss(ob,id){
	document.getElementById('quantite3').value=ob.options[ob.selectedIndex].text;
	document.getElementById('prix'+id).selectedIndex=ob.selectedIndex;
	chgqte(document.getElementById('quantite3'),id);
}

function chgprix(ob,id){
	document.getElementById('cond'+id).selectedIndex=ob.selectedIndex;
}

function getbestprice(id) {
	
	var prix=document.getElementById('prix'+id);
	var cond=document.getElementById('cond'+id);
	var qte=document.getElementById('idProd['+id+']').value*1;
	var cnt=prix.length;	
	var bp=prix.options[0].value;	
	var nindex=0;

	for(i=0;i<cnt;i++){		
		if (qte >= ((cond.options[i].value)*1)) {
			bp=prix.options[i].value;nindex=i;
		}
	}

	prix.selectedIndex=nindex;
	prix.blur();
	return bp;

}


function getbestpricess(id) {
	
	var prix=document.getElementById('prix'+id);
	var cond=document.getElementById('cond'+id);
	var qte=document.getElementById('quantite3').value*1;
	var cnt=prix.length;	
	var bp=prix.options[0].value;	
	var nindex=0;
	for(i=0;i<cnt;i++){		
		if (qte >= ((cond.options[i].value)*1)) {
			bp=prix.options[i].value;nindex=i;
		}
	}
	prix.selectedIndex=nindex;
	prix.blur();
	return bp;

}


function modqte(id) {
	var bp=getbestprice(id);
	document.getElementById('affprix'+id).innerHTML="&nbsp;<b>"+bp+"</b> Euros";
}

function chgqte(ob,id) {	
	var p=ob.value;
	var bp=getbestpricess(id);
	var pp=remplace(document.getElementById('prix'+id).options[document.getElementById('prix'+id).selectedIndex].value,',','.');
	var tt=p*pp;
	tt=tt.toFixed(2);
	document.getElementById('affprix'+id).innerHTML="<b>"+bp+"</b>";
	document.getElementById('totalEuros').value=remplace(tt,'.',',');
}