Moved javascript code to lib directory and cached jquery variables
Removed apply