Commentted the javascript and formatted to coding standards