Fixed possible issues with your js.

I used JSLint on your JS to fix potential issues.

1. Cleaned trailing whitespaces.
2. Removed unnecessary semicolons.
3. Added necessary semicolons.
4. 0 value should be checked using === or !==
5. Fixed a possible bug where same variable was being declared thrice.