I'm a big fan of jQuery It's a javascript library which makes life much easier in my opinion.

Anyway, to get to your question, jQuery has a function 'ready', which is executed after the whole document has completed.

About the function: http://docs.jquery.com/Tutorials:Int...29.ready%28%29