$(document).ready(function() {
  $('body').addClass('enhanced');
  
  $('div#mortgage-assessor form').submit(function() {
    var $this = $(this);
    
    // Retrieve the submitted values.
    var rate = $this.find('#hourly-rate').val();
    
    // Simple RegExp to match numbers (commas are not supported).
    var regexp = /^\d*(\.?)\d+$/;
    
    // Test the submitted values.
    if (!regexp.test(rate)) {
      // Error code goes here.
      alert('Please enter some valid values.');
      return false;
    }

		// Calculate the likely loan amount.
		loan = rate * 7200;
    
    // Populate the results.
    $results = $this.parent('div').find('dl');      
    $results.find('dd:nth-child(2)').html('&pound;' + loan.toFixed(2));
    
    // Display the results.
    $results.slideDown(650, function() {
      $results.fadeIn(900);
    });
    
    return false;   // Don't submit the form.
  });
  
});