
function calcPhcp(ehcp, par, sr, cr)
{
    phcp = ehcp * sr / 113 + cr - par;
    return phcp;
}

function calculate()
{
    // haal Exact handicap op
    tmp_ehcp = document.getElementById("ehcp").value;
    tmp_s = tmp_ehcp.replace(',','.');
    ehcp = new Number(tmp_s);

    // berekenen playing handicap
    hbt = Math.round(calcPhcp(ehcp, 72.0, 136, 71.9));
    hmt = Math.round(calcPhcp(ehcp, 72.0, 134, 70.9));
    dbt = Math.round(calcPhcp(ehcp, 72.0, 129, 72.6));
    dmt = Math.round(calcPhcp(ehcp, 72.0, 130, 71.8));

    // vul de velden
    document.getElementById("hbtphcp").value = hbt;
    document.getElementById("hmtphcp").value = hmt;
    document.getElementById("dbtphcp").value = dbt;
    document.getElementById("dmtphcp").value = dmt;
        
}

