function validate()
{
    if (!isNaturalNumber(document.dcf.e, " for the Earnings per share."))
    {
        return false;
    }

    if (!isValueInRange(document.dcf.g1, 1, 100, " for the Intial growth."))
    {
        return false;
    }

    if (!isNaturalNumber(document.dcf.n, " for the Number of years."))
    {
        return false;
    }

    if (!isValueInRange(document.dcf.g2, 1, 100, " for the Stable Growth Rate."))
    {
        return false;
    }

    if (!isValueInRange(document.dcf.m, 1, 100, " for the Market return."))
    {
        return false;
    }

    if (parseFloat(document.dcf.m.value) <= parseFloat(document.dcf.g2.value))
    {
        alert('Market return must be greater than stable growth');
        document.dcf.m.value = "";
        document.dcf.m.focus();
        return false;
    }

    if (parseFloat(document.dcf.m.value) == parseFloat(document.dcf.g1.value))
    {
        alert('Market  return and Initial growth must not be equal');
        document.dcf.m.value = "";
        document.dcf.m.focus();
        return false;
    }

    return true;
}

function calc()
{
    var e = parseFloat(document.dcf.e.value);
    var g1 = parseFloat(document.dcf.g1.value) / 100;
    var n = parseFloat(document.dcf.n.value);
    var g2 = parseFloat(document.dcf.g2.value) / 100;
    var m = parseFloat(document.dcf.m.value) / 100;
    var k = parseFloat(Math.pow(((1 + g1) / (1 + m)), (n + 1)));
    var k1 = parseFloat((1 + g1) / (1 + m));
    var k2 = parseFloat(Math.pow((1 + g1), n));
    var k3 = parseFloat((1 + g2) / (m - g2));
    var sv = parseFloat((e * (k - 1) / (k1 - 1)) + (e * k2 * k3));
    document.dcf.svps.value = round(sv, 2);
}

function clean()
{
    document.dcf.e.value = "";
    document.dcf.g1.value = "";
    document.dcf.n.value = "";
    document.dcf.g2.value = "";
    document.dcf.m.value = "";
    document.dcf.svps.value = "";
}
