Declare functions before they're used.

I implemented this plugin in a site using RequireJS. I kept running into an issue where the _rows function had not already been defined and would fail on this line:

rows = _rows($elements);

By moving the functions to the top of the file, the functions should always be available.