function CalcCalories() {
    if (validateForm(document.getElementById('CalorieCalc'))) {
        var a = new Date();
        var b = document.CalorieCalc.inpBirthMonth.value;
        var c = document.CalorieCalc.inpBirthDay.value;
        var d = document.CalorieCalc.inpBirthYear.value;
        if (d.length == 2) d = (d > (a.getYear() - 2000)) ? '19' + d : '20' + d;
        var e = new Date(d, b - 1, c, 0, 0, 0);
        var f = Math.floor((a.getTime() - e.getTime()) / (365.25 * 24 * 60 * 60 * 1000));
        var g = false;
        var h = false;
        if (document.CalorieCalc.inpGender[1].checked) {
            g = true;
            h = document.CalorieCalc.inpLactating.checked
        }
        var i = document.CalorieCalc.inpSmoker.checked;
        var j = document.CalorieCalc.inpFeet.value;
        var k = document.CalorieCalc.inpInches.value;
        var l = (Number(j * 12) + Number(k));
        var m = document.CalorieCalc.inpWeight.value;
        var n = document.CalorieCalc.inpGoalWeight.value;
        var o = document.CalorieCalc.inpEmail.value;
        var p = document.CalorieCalc.inpTargetMonth.value;
        var q = document.CalorieCalc.inpTargetDay.value;
        var r = document.CalorieCalc.inpTargetYear.value;
        if (r.length == 2) r = '20' + r;
        var s = new Date(r, p - 1, q, 0, 0, 0);
        var t = Math.floor((s.getTime() - a.getTime()) / (24 * 60 * 60 * 1000));
        if (g == true) {
            var u = 655.1 + (9.56 * m / 2.2) + (1.8 * l * 2.54) - (4.68 * f)
        } else {
            var u = 66.5 + (13.5 * m / 2.2) + (5.0 * l * 2.54) - (6.75 * f)
        }
        if (i == true) {
            u = u * 1.1
        }
        if (f <= 18) {
            u = u * 1.03
        }
        if (h == true) {
            u = u + 500
        }
        u = u * 1.3;
        u = Math.round(u * 10) / 10;
        var v = Math.round((u + ((n - m) / t) * 3500 + .5));
        var w = Math.round((0.031746 * m) * 10) / 10;
        var x = "below";
        if (Number(u - v) < 0) {
            x = "above"
        }
        if (n == m) {
            var y = '<p>To maintain your current weight, you should eat about ' + Math.round(Number(u)) + ' calories per day.</p>'
        } else {
            var y = '<p>To reach your goal weight on your target date, you should eat about ' + v + ' calories per day.  This is ' + Math.round(Math.abs(Number(u - v))) + ' calories or '+ Math.round(Math.abs(Number(((u - v)/u)*100))) + ' percent ' + x + ' the ' + Math.round(Math.abs(Number(u))) + ' required to maintain your current weight.</p>\r\n';
            if (v < 900) {
                y = y + '<p style="color:#CC0000;">Caution: A budget under 1200 calories per day is too low for adequate nutrition. Please choose a safer goal.</p>'
            } else if (v < 1200) {
                y = y + '<p><em>Caution:</em> A budget under 1200 calories per day is too low for adequate nutrition. You can bring your budget to 1200 without jeopardizing your goal, however, by earning extra calories from exercise. At your current weight, a rapid, 4-mph walk, for example, will burn off about ' + w + ' calories per minute.'
            } else {
                y = y + '<p>You can earn extra calories through exercise.  A rapid, 4-mph walk, for example, will burn off about ' + w + ' calories per minute at your current weight.</p>'
            }
        }
        y += '<p>(To track your calories and 32 other nutrients on your PC, try DietPower\'s Personal Eating Coach&trade; by clicking "Try" on the red navigation bar at the top of this page.)</p>';
        document.getElementById("Result").innerHTML = y
    }
}
