how to do a show and focus on form

how to do a show and focus on form

I have the following jquery code that hides a form, but if you click a link it shows the form. It works correctly but I can't seem to set the focus on the form after the show. After i click the "show_form" link the pages goes up to the top.. how can i make this work
 

 

<script type="text/javascript">

$(document).ready(

function () {

       

$("#form").hide();

       

$("#show_form").click(function () {

$("#form").show();

    // the focus doesn't work       

$("#form").focus();

 

});

});

</

</script>