function ReplaceElementsByStyleClass (className, add, init) {

  var mult;
  mult = (parseInt(document.forms["quantite"].elements["quant"].value) + add) / (parseInt(document.forms["quantite"].elements["quant"].value));
  if (add == 0)
	  mult = (parseInt(document.forms["quantite"].elements["quant"].value)) / init;
  if (document.forms["quantite"].elements["quant"].value == "1" && add == -1)
	    mult = 1;
  var all = document.all ? document.all :
      document.getElementsByTagName('*');
    var elements = new Array();
    var number;
    var unit;
    for (var e = 0; e < all.length; e++)
    {
    	if (all[e].className == 'quant')
    	{
    		number = parseFloat(all[e].innerHTML);
    		number = (number * mult * 100) / 100;
    		all[e].innerHTML = number;
    	}
    	if (all[e].className == 'quant_unit')
    	{
    		if (all[e].innerHTML == "1")
                unit = 0;
    		else if (all[e].innerHTML == "2")
    			unit = 2;
    		else
    			unit = 1;
    	}
      if (all[e].className == 'quant_aff')
      {
      if (unit == 0)
    all[e].innerHTML = roundfloat(parseFloat(number));
      if (unit == 1)
    all[e].innerHTML = roundhalf(parseFloat(number));
      if (unit == 2)
    all[e].innerHTML = roundint(parseFloat(number));
      }
    }
    return;
  }
function incremente(champProd) {
  document.getElementById(champProd).value++;
}
function decremente(champProd) {
  if (document.getElementById(champProd).value > '1')
  document.getElementById(champProd).value--;
}


function roundhalf(value) {

    var cibles = new Array (
            0.5,
            1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 9,
            10, 12, 12.5, 15, 17.5, 20, 25, 30, 40, 50, 60, 70, 75,
            100, 120, 125, 150, 200, 250, 300, 350, 400, 450, 500, 600, 700, 750,
            1000, 1200, 1250, 1500, 1750, 2000
        );

if (value < 0.5)
	return (0.5);
    var i = 0;
    var dessous = 0;
    var dessus = 0;
    var prec = 0;
    for (i = 0; i < cibles.length; i++) {
         
        if ( value <= cibles[i] ) {

            dessous = value - prec;
            dessus = cibles[i] - value;
           
            if (dessous < dessus) {
                return prec;
            }
            else {
                return cibles[i];
            }
           
        }
        prec = cibles[i];
    }
    if (value > 500)
	value = (Math.round(parseFloat(value)/500)*500);
    return (Math.round(value*100))/100;
   
}

function roundint(value) {

    var cibles = new Array (
        1, 2, 3, 4, 5, 6, 7, 8, 9,
        10, 12, 15, 18, 20, 25, 30, 40, 50, 60, 70, 75,
        100, 120, 125, 150, 200, 250, 300, 350, 400, 450, 500, 600, 700, 750,
        1000, 1200, 1250, 1500, 1750, 2000
    );

if (value < 0.5)
	return (0.5);
    var i = 0;
    var dessous = 0;
    var dessus = 0;
    var prec = 0;
    for (i = 0; i < cibles.length; i++) {
         
        if ( value <= cibles[i] ) {

            dessous = value - prec;
            dessus = cibles[i] - value;
           
            if (dessous < dessus) {
                return prec;
            }
            else {
                return cibles[i];
            }
           
        }
        prec = cibles[i];
    }
    if (value > 500)
	value = (Math.round(parseFloat(value)/500)*500);
    return (Math.round(value*100))/100;
   
}

function roundfloat(value) {
    var cibles = new Array (
        0.1, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.8, 0.9,
        1, 1.2, 1.25, 1.5, 2, 2.5, 3, 4, 4.5, 5, 6, 7, 7.5,
        10, 12, 12.5, 15, 17.5, 20, 25, 30, 40, 50, 60, 70, 75,
        100, 120, 125, 150, 200, 250, 300, 350, 400, 450, 500, 600, 700, 750,
        1000, 1200, 1250, 1500, 1750, 2000
    );
   

    var prec = 0;
    var i = 0;
    var dessous = 0;
    var dessus = 0;
    for (i = 0; i < cibles.length; i++) {
               
        if ( value < cibles[i] ) {
           
            dessous = value - prec;
            dessus = cibles[i] - value;
           
            if (dessous < dessus) {
                return prec;
            }
            else {
                return cibles[i];
            }
           
        }
        prec = cibles[i];
    }
    if (value < 100) return Math.round(value*10)/10;
    if (value < 1000) return Math.round(value/10)*10;
    if (value < 10000) return Math.round(value/100)*100;
    if (value < 100000) return Math.round(value/1000)*1000;
    return Math.round(value/10000)*10000;
}