function calculate() 
{
    if (document.getElementById('age').value>=65) 
        {
		var lump_sum_low;
		var lump_sum_high;
		var annual_payments_low;
		var annual_payments_high;
		var home_value;
		
        lump_sum_low = document.getElementById('home_value').value * 0.12;
		lump_sum_high = document.getElementById('home_value').value * 0.15;
		annual_payments_low = document.getElementById('home_value').value * 0.009;
		annual_payments_high = document.getElementById('home_value').value * 0.025;
		home_value = document.getElementById('home_value').value;
		document.getElementById('lump_sum_low').value = formatNumber(lump_sum_low,0,',','','','','-','') 
		document.getElementById('lump_sum_high').value = formatNumber(lump_sum_high,0,',','','','','-','') 
		document.getElementById('annual_payments_low').value = formatNumber(annual_payments_low,0,',','','','','-','') 
		document.getElementById('annual_payments_high').value = formatNumber(annual_payments_high,0,',','','','','-','') 
		document.getElementById('home_value').value = formatNumber(home_value,0,',','','','','-','') 
        }
    else  
		alert("You must be 65 to qualify")        
}

// number formatting function
// copyright Stephen Chapman 24th March 2006, 10th February 2007
// permission to use this function is granted provided
// that this copyright notice is retained intact

function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {var x = Math.round(num * Math.pow(10,dec));if (x >= 0) n1=n2='';var y = (''+Math.abs(x)).split('');var z = y.length - dec; if (z<0) z--; for(var i = z; i < 0; i++) y.unshift('0');y.splice(z, 0, pnt); while (z > 3) {z-=3; y.splice(z,0,thou);}var r = curr1+n1+y.join('')+n2+curr2;return r;}
