Bug fix interating through arrays. Move err to last parameter to better ...

...determine amount of space left. Minor code clean-up (missing semi-colons and var statements).

See: http://stackoverflow.com/questions/3010840/loop-through-array-in-javascript for a reference to issues interating through JavaScript arrays.

Looks great by the way. Am folding into an ASP.NET MVC app, posting to my own service which uses the ELMAH error handler to log and email the error.