function replaceSubString(originalString, searchForString, replaceWithString) {
    var objRegExp = eval("/" + searchForString + "/g");
    return (originalString.replace(objRegExp, replaceWithString));
}

function isNumber(item, min, max) {

    item.value = replaceSubString(item.value, ",", ".");
    item.value = replaceSubString(item.value, " ", "");

    if (item.value.length == 0) {
        alert("Calcul interrompu : vous devez renseigner ce champ !");
        item.focus();
        return false;
    }

    if (!isNaN(item.value)) {
        if (min != null) if (parseFloat(item.value) < min) item.value = min;
        if (max != null) if (parseFloat(item.value) > max) item.value = max;
        return true;
    }

    alert("Calcul interrompu :\n\n\"" + item.value + "\" n'est pas un nombre valide !");
    item.focus();
    return false;
}

function round(number, decimal) {
    var factor = Math.pow(10, decimal);
    return Math.round(number * factor) / factor;
}

function compute(form) {
    if (!isNumber(form.Charge, 1, 9999)) return false;
    var charge = form.Charge.value;
    form.Charge1.value = round(charge * 0.66, 0);
    form.Charge2.value = round(charge * 0.735, 0);
    form.Charge3.value = round(charge * 0.8, 0);
    form.Charge4.value = round(charge * 0.86, 0);
    form.Charge5.value = round(charge * 0.9, 0);
    form.Charge6.value = round(charge * 0.925, 0);
    form.Charge7.value = round(charge * 0.8, 0);
}