Hi
The following line of javascript code will set the focus on the button:
document.getElementById('form1:button1').focus();
This above line of code can be entered for any of the javascript events associated with the textField which include onFocus, onBlur, OnKeyPress depending on your use case and requirement.
Hope this helps
Cheers
Girish