Code cleaned/corrected after inspection
Encapsulated Javascript, bugfix