Using jquery datepicker within a jquery dialog

so I have datepicker working just fine in a normal window but I cannot
for the life of me get it to work within a dialog.

I have some javascript that opens a dialog in my application.js file
as well as the datepicker js
is as follows:

$(function() {
$("#version_release_date").datepicker({dateFormat: ‘yy-mm-dd’});
});

$(document).ready(function() {
$(‘a.popup’).click(function() {
$(’

’).appendTo(‘body’).load($(this).attr(‘href’) + ’
form’).dialog({
title: $(this).text()
}
});
return false;
});
});

now the first function works fine if I just go straight to that page
but if the page is rendered via the second function in a dialog the
datepicker no longer appears.

this is where the dialog is created:
<%= link_to ‘Close Escalation’, new_version_path, :class => ‘popup’ %>

these are my includes
<%= stylesheet_link_tag “http://ajax.googleapis.com/ajax/libs/
jqueryui/1.7.2/themes/redmond/jquery-ui.css”, “application” %>
<%= javascript_include_tag “http://ajax.googleapis.com/ajax/libs/
jquery/1.4.2/jquery.min.js”, “http://ajax.googleapis.com/ajax/libs/
jqueryui/1.8.1/jquery-ui.min.js”, “application” %>
<%= javascript_include_tag “jquery.rails.js” %>

any help is appreciated. basically from what I can tell I can’t get
any javascript to work in the dialog.

I even tried adding the script to the page but that didn’t work
either.

Thanks,
Dal