Refactored js code from cz.htm to common.js

Moved some js code from cz.htm to common.js.