﻿$(function() {
    $('#Calculate').click(function() {
        $('#EstimatedPayment').fadeOut('fast', function() {
            var calculator = new Calculator();
            calculator.Action = 'MonthlyPayment';
            calculator.DownPayment = $('#DownPayment').val();
            calculator.Months = $('#Months').val();
            calculator.SellingPrice = $('#SellingPrice').val();
            calculator.ZipCode = $('#ZipCode').val();
            calculator.get(function() {
                $('#DownPayment').val(calculator.DownPayment);
                $('#MonthlyPayment').val(calculator.MonthlyPayment);
                $('#Months').val(calculator.Months);
                $('#SellingPrice').val(calculator.SellingPrice);
                $('#ZipCode').val(calculator.ZipCode);
                $('#EstimatedPayment').fadeIn('slow');
            });
        });
    });
});