This "one-size-fits-all" routine performs all of the tasks in bulk -- similar to what Lotus Notes does automatically. The logic then can be encoded directly in the HTML attributes for any input and div tags involved.
This example adds hidewhen attributes to the div tags, but they can also be used with other tags. For the input tags, validation and prompt attributes were added.
The challenge we presented ourselves with was to use getElementById instead of document.all in HideWhen() and combine "validation" and "prompt" to one HTML attribute.