using jquery (dialog) across frames?

using jquery (dialog) across frames?

i have a frameset with a topFrame and a mainFrame. the topFrame is static and loads with all the supporting jquery files and is where the jquery object resides. the mainFrame is fairly dynamic and loads multple page sources. i'm trying open a .dialog() inside mainFrame using jquery from topFrame. i've tried different techniques to access mainFrame from topFrame. an eaxmple would be:
 
    $("body",window.parent.mainFrame.document).append("<div id='test'></div>);
    $("#test",window.parent.mainFrame.document).dialog({});
 
the append actualy works, but i get an error with the .dialog().
 
i've also tried to move jquery into mainFrame using:
    window.parent.mainFrame.$ = $;
and then:
    window.parent.mainFrame.$("#test").dialog({});
 
but then the dialog displays in the topFrame.
 
i'm kinda stumped, and now wondering if its possible. I'd hate to have to add the jquery files to every page that loads into mainFrame.
 
any ideas?
 
thanks,