function calculate()
{
    var ajaxObj = new Ajax.Request('/Tools/Calculators/Savings_Calculator',
            {method: 'post',
             parameters : 'start_balance='+ encodeURIComponent($('start_balance').value) +'&deposit='+ encodeURIComponent($('deposit').value) +'&roi='+ encodeURIComponent($('roi').value) +'&inflation='+ encodeURIComponent($('inflation').value)  +'&years='+ encodeURIComponent($('years').value),
             onComplete: function(originalRequest)
            {
            	if (originalRequest.responseJSON && typeof originalRequest.responseJSON == 'object') {
            		$('txtSavings').value = originalRequest.responseJSON.savings;
            		$('txtSavingsAdj').value = originalRequest.responseJSON.savings_adj;
            	}
            }
    });

    ajaxObj = null;
    return false;
}

function calculatorReset() {
	['txtSavings', 'txtSavingsAdj'].each(function (field) {
		$(field).value = '';
	});
	
	$('start_balance').value = '10000.00';
	$('deposit').value = '1000.00';
	$('roi').value = '5';
	$('inflation').value = '3';
	$('years').value = '3';

	return false;
}
