separated some of the js functions

Learned how to use $.each instead of repeating myself. Added an option
for the hamburger position because why not.