id is misleading here because you get a position so "pos" would be a better choice.
Also declare the variable before (var pos;) so it isn't placed in the global namespace