Here come a couple of useful tips:
Our final target is the opcheckout.js, located at: skin/frontend/default/default/js/opcheckout.js
Before we jump into hundreds of lines of JS codes, our first stop should be the template files for the Onepage Checkout. At the end of those files, you will see something like:
var billing = new Billing(‘co-billing-form’, …);
Yes, this is the critical link between our PHP part and JS part.