setTimeout and anonymous function problem
<p>This is my code, SetOpacity get invoked with wrong values, why?</p>

<pre><code>function SetOpacity(eID, opacity){                  
   eID.style.opacity = opacity / 100;
   eID.style.filter = 'alpha(opacity=' + opacity + ')';
}
function fade(eID, startOpacity, endOpacity){           
    var timer = 0;
    if (startOpacity &lt; endOpacity) { 
       for (var i = startOpacity; i &lt;= endOpacity; i++) {
           setTimeout(function() {SetOpacity(eID, i);}, timer * 30);
           timer++;
        }
    }           
}
</code></pre>
