Revamped JS

This was done to prevent unnecessary specificity within the script,
causing this to be less scalable/more dififcult to implement should the
need to expand the content arise.
I left the old application commented out so that the changes could be
seen, but essentially reduced to one block of script what was
previously set as 3 differnet variables and functions.