Take a look at item #7 at http://prototype-window.xilinus.com/samples.html
I'd really like the "login or register" of r_a to d that! Wouldn't you?
Of course it would also need to be triggered programmatically, in a 'before_filter' or in an 'login_required' in an action, to get the authentication before proceeding with the action. (Which strikes me as better than a redirect to a login page then redirect back!)
Has this been done? I can't find it goggling.