Displaying a form

I am using Rails 3.0.1 with Devise for user authentication. I am
trying Rails out so if the answer is blindingly obvious please bear
with me.

I have an index page, which has links to the sign up/sign in forms.
All the logic works fine but what I can't work out is how to display
the forms in the index page rather than opening the forms and losing
the formatting of the index page.

Here's the code (I'm using HAML which I know not everyone likes !)

    .box
      - if user_signed_in?
        Signed in as #{current_user.email}.
        .quiet Not you ?
        \#{link_to "Sign out", destroy_user_session_path}
      - else
        = link_to "Sign up", new_user_registration_path
        or
        \#{link_to "Sign in", new_user_session_path}

So what I'm trying to do is once the link is clicked, the relevant
form is displayed in the .box div rather than on a new page.

Any tips or pointers would be gratefully received.

Thanks

I think the simplest way would be to just output all the HTML on the
page, then just hide or show the proper divs using JavaScript. Hide
the form div by default, then have the "sign up" or "sign in" links
hide/show the proper divs:

#links.box
  ...etc...
#login.box{:style=>"display:none;"}
  ...etc...

Then calling the following function will hide the links and show the
login form.
$('links', 'login').invoke('toggle');