
 function checkNumber(input, min, max,
msg) {
    msg = msg + " field has invalid data: " + input.value;

    var str = input.value;
    for (var i = 0; i < str.length; i++) {
        var ch = str.substring(i, i + 1)
        if ((ch < "0" || "9" < ch) && ch != '.') {
            alert(msg);
            return false;
        }
    }
    var num = parseFloat(str)
    if (num < min || max < num) {
        alert(msg + " not in range [" + min + ".." + max + "]");
        return false;
    }
    input.value = str;
    return true;
}

function computeField1(input)
{
    if (input.value != null && input.value.length != 0)
	input.value = "" + eval(input.value);
    computeForm1(input.form);
}

function computeForm1(form)
{
    form.c.value = (form.f.value-32)*5./9.
}

function computeField2(input)
{
    if (input.value != null && input.value.length != 0)
	input.value = "" + eval(input.value);
    computeForm2(input.form);
}

function computeForm2(form)
{
    form.f.value = form.c.value*9/5. + 32.
}

function computeField3(input)
{
    if (input.value != null && input.value.length != 0)
	input.value = "" + eval(input.value);
    computeForm3(input.form);
}

function computeForm3(form)
{
    form.km.value = form.miles.value*1.60935
}
function computeField4(input)
{
    if (input.value != null && input.value.length != 0)
	input.value = "" + eval(input.value);
    computeForm4(input.form);
}

function computeForm4(form)
{
    form.miles.value = form.km.value/1.60935
}

function computeField5(input)
{
    if (input.value != null && input.value.length != 0)
	input.value = "" + eval(input.value);
    computeForm5(input.form);
}

function computeForm5(form)
{
    form.m.value = form.feet.value*0.305
}
function computeField6(input)
{
    if (input.value != null && input.value.length != 0)
	input.value = "" + eval(input.value);
    computeForm6(input.form);
}

function computeForm6(form)
{
    form.feet.value = form.m.value/0.305
}

function clearForm1(form)
{
    form.f.value = "";
    form.c.value = "";
}
function clearForm2(form)
{
    form.miles.value = "";
    form.km.value = "";
}
function clearForm3(form)
{
    form.feet.value = "";
    form.m.value = "";
}
