Focusing wedget using javascript PROBLEM

Hello,

I needed to know, using javascript along with rails, that is in an rhtml
file how do i make the focus of the widget on the first field when a
given page is loaded.

I have two problems

1 => I would like to know if there is a general functionality written in
a given application , if so in which file does it exist

2 => If I have to write this for individual pages…that is individual
rhtml page, how do I write this.

Thank You

Advait