Cleaned up the Javascript code, fixed indentation, added semi-colons where necessary. Minor updates.