Switch between Edit and Read-Only mode on web form

A question on Stack Overflow made me remember some code I wrote a few years ago. It allows you switch a form between regular edit mode and read mode, without having to reload the page. It works just like you are used to in the Notes client. So I thought I would post it here on my blog as well.
This is a companion discussion topic for the original entry at http://blog.texasswede.com/switch-between-edit-and-read-only-mode-on-web-form/