Changed js to jquery plugin. Changed the logic of the program.