Handle relative elements correctly, as well as elements at the edges

of a page. Also fixes a few jshint issues, like redeclaring variables
and bad line breaking.
Merge pull request #4 from tmcw/jshint-relative

Handle relative elements correctly, as well as elements at the edges