ASP.Net site with masterpage - root page works, subpages do not

ASP.Net site with masterpage - root page works, subpages do not

Hi there,
I am building an ASP.Net site. All pages on my site share the same masterpage. This masterpage has...

<script language="javascript" type="text/javascript" src="<%# ResolveClientUrl("~/JS/jquery-1.4.2.min.js") %>"></script>
<script language="javascript" type="text/javascript" src="<%# ResolveClientUrl("~/JS/jquery-ui-1.8.custom.min.js") %>"></script>

... in the head tag (with runat="server" set); an OnLoad method in the code behind that performs a databind; and the following mark-up...

<div id="logindialog" title="Log In" class="off">
  <asp:Login ID="Login_Control" runat="server" />
</div>

<script type="text/javascript">
  $(function() {
    $("#logindialog").dialog({ width: 400, height: 170, autoOpen: false, modal: true, resizable: false, draggable: false });
    $("#logindialog").removeClass('off');
  });
</script>

... within the body of my document. When I open the root document of my site (/Default.aspx), the dialog is initialised correctly. When I open a subpage (i.e. /Register/Default.aspx), I receive the error: $("#logindialog").dialog is not a function.

I can confirm that...

- The code on my masterpage assigns the correct path to the .js files (JS/ in the root, ../JS/ in subpages).
- Both script files are loaded, and appear correct (I use Firebug in Firefox).

Is there anything that would prevent jQuery plug-ins from initialising when invoked in this way? Has anyone had similar issues?

Thanks!