possibly one of the weirder attempts at a function call I have seen.
but it's a basic problem: your getElementById runs in the head, which comes before the body
your "txtHint" div gets created in the body. ie, after your script has run
so the code tries to get an element that doesn't exist yet
and it pretty much goes all downhill from there. there may be other conceptual problems with what you are trying to do, but that's the dealbreaker for now.
can I ask why you are trying to do it that way instead of something a little more, uh... normal?