Topic: AJAX Date Calculations

I have a project management application - project(parent)/task(child)for which I need to do calculations of several dates on the fly.  A new project is created by making use of the RoR sublist plugin to allow for dynamically adding tasks to a project before saving the new project.  Fields entered by the user are: project target end date, task duration and task lead time.  From those fields, I need to calculate: project start date, task start date and task end date.

Project start date = project target end date - number of days of lead time for the task with the longest lead time
Task start date = project target end date - task lead time
Task end date = task start date + task duration

Any suggestions for a newbie wanting some slick AJAX functionality with date calculations would be greatly appreciated!

new.rhtml

 
Choose New Project Name<input type="text" name="project[projectName]" id="project_projectName" value="">
Project Summary:<textarea name="project[projectSummary]" id="project_projectSummary"></textarea>
Target End Date:<%= toolbocks_date_select :project, :dateTargetEnd, { :format => 'mm/dd/yyyy', :autoRollOver => false } %>
Scheduled Start Date:<input type="hidden" name="project[dateScheduledStart]" id="project_dateScheduledStart" value=""><!--calculate start date here

Add a Task
<%= sub_list_content 'Task', 'project' %>

<%= sub_list_add_link 'Task', image_tag('btn_addtask.gif', :border => 0, :mouseover => 'btn_addtask_ro.gif') %>


_task.rhtml
<% @task = task %>
  <fieldset>
<div id="<%= "task_#{task.id}" %>">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
    <td align="left" class="normalText"><%= text_field 'task[]', 'task', :size => 25 %></td>
    <td align="left" class="normalText"><%= text_field 'task[]', 'leadTime', :size => 3 %></td>
    <td align="left" class="normalText"><%= text_field 'task[]', 'duration', :size => 3 %></td>
    <td align="left" class="normalText"><%= text_field 'task[]', 'dateStart', :value => '03/08/2007' %></td>
    <td align="left" class="normalText"><%= text_field 'task[]', 'dateTargetEnd', :value => '03/08/2007' %></td>
    <td align="left" class="normalText"><%= select('task[]', 'userID', User.find(:all).collect {|u| [u.firstName, u.id]}) %></td>
    <td align="left" class="normalText"><%= select('task[]', 'taskTypeID', Tasktype.find(:all).collect {|t| [t.taskType, t.id]}) %></td>
    <td align="left" class="normalText"><%= select('task[]', 'criticalTaskID', Criticaltask.find(:all).collect {|c| [c.criticalTask, c.id]}, {:include_blank => true }) %></td>
    <td align="left" class="normalText"><%= sub_list_remove_link task, 'Tasks', 'Remove' %></td>
</tr>
</table>
</div>
  </fieldset>