Added  CSS styling to popups.
Fiddled with formatting. Added comments to JS code. Refactored a bit.