function yhteydenotto()
{
window.open('/yhteydenotto.html','na','width=600,height=650,resizable=yes,screenX=100,screenY=100');
}

function kanta_asiakkuus()
{
window.open('/kanta_asiakassopimus.html','na','width=450,height=600,resizable=yes,screenX=100,screenY=100');
}

//painoindeksi lasketaan jakamalla paino pituuden neliöllä

function laske(form) {
      form.painoind.value =
        Math.round(form.paino.value/((form.pituus.value/100)*(form.pituus.value/100))*10)/10;
}

/*
*    This JavaScript is (c)1999 Michael Sullivan.
*    All rights reserved.
*/
function bodyfat1calculate()
{
var waistunits = document.bodyfat1.waistunits.value;
var waist = document.bodyfat1.waist.value;
var weightunits = document.bodyfat1.weightunits.value;
var weight = document.bodyfat1.weight.value;

    if (waistunits == "centimeters")
    {
        waist /= 2.54;
    }
    if (weightunits == "kiloa")
    {
        weight *= 2.2;
    }
    var sex = document.bodyfat1.sex.options[document.bodyfat1.sex.selectedIndex].value;
    var a = waist * 4.15;
    var b = weight * 1.082;
    var c = b - a;
    var lbm;
    if (sex == "Male")
    {
        lbm = c + 98.42;
    }
    else
    {
        lbm = c + 76.76;
    }
    var fatweight = weight - lbm;
    var bodyfat = fatweight / weight * 100.0;
    var factor = 1.0;
    if (weightunits == "kiloa")
    {
        factor = 2.2;
    }
    document.bodyfat1.bodyfat.value = bodyfat;
    document.bodyfat1.fatWeight.value = Math.round(fatweight / factor) + " " +  weightunits;
    document.bodyfat1.leanWeight.value = Math.round(lbm / factor) + " " + weightunits;
    document.bodyfat1.calories.value = Math.round(lbm * 13.83);
}

function calculateAll()
{
    bodyfat1calculate();
}
