function inside javascript loop
<p>I'm having trouble understanding this problem.  I'm assuming its a scope issue, but I don't know how to get around it.</p>

<p>I created an array to store the x and y positions of 6 separate elements</p>

<pre><code>var pos = new Array();
for(i=1;i&lt;7;i++){
    pos['box'+i] = $('.box'+i).position();
}
</code></pre>

<p>I would like to then add this to each element with another loop</p>

<pre><code>for(i=1;i&lt;7;i++){
    $('.box'+i).draggable({zIndex: 9999, revert: function(){
        $(this).animate({top:pos['box'+i].top, left:pos['box'+i].left}, 500, "easeOutElastic");
    }});
}
</code></pre>

<p>The dragging works, but the revert function doesn't.  With some alerts I found that it is trying to get the position of pos['box7'] which doesn't exist.  Why isn't it adding each 'box'+i ?</p>
