Added comments to the javascript code.