Are IDs for an html element always available from the window object?
No. It is a non-standard Microsoft-ism that some other browsers have adopted for compatibility reasons. It is prone to namespace collisions, and not completely cross-browser compatible: don't do it.
What's the point of the second approach?
It is standard, well-supported cross-browser (and also cross-language).