//alert("wut");
$(document).ready(function(){
	$("#submit").click(function(){
		
		var agedelta = eval(65 - $("#age").val());
		if (isNaN(agedelta)) {
			alert("Please input your age.");
			return false;
		}
		var userincome = $("#income").val().replace(/ /g,"");
		userincome = userincome.replace(/\$/g,"");
		userincome = userincome.replace(/\,/g,"");
		var yearlyincome = eval(12 * userincome);
		
		// compute future value
		var total = yearlyincome;
		var income = yearlyincome;
		for (var i=1; i < agedelta; i++) {
			income = income*1.03;
			//alert(income);
			total += income;
		}
		total = commify(Math.round(total*100)/100);
		//alert(total);
		$("#earnings").html("<p>By the age of 65 you will earn...<br><strong>"+total+"</strong>");
    $.scrollTo( "#earnings", {speed:1500} );
		return false;
	});
});

