JavaScript for..in and enum strange behaviour
<p>I have trouble with strange behavior of for..in cycle in JavaScript. I have the following HTML:</p>

<pre><code>&lt;div id="quarter_circle_top_left"&gt;...&lt;/div&gt;
&lt;div id="quarter_circle_top_right"&gt;...&lt;/div&gt;
&lt;div id="quarter_circle_bottom_right"&gt;...&lt;/div&gt;
&lt;div id="quarter_circle_bottom_left"&gt;...&lt;/div&gt;    

&lt;div id="author_dimension"&gt;&lt;/div&gt;
&lt;div id="similar_dimension"&gt;&lt;/div&gt;
&lt;div id="citation_dimension"&gt;&lt;/div&gt;
&lt;div id="concept_dimension"&gt;&lt;/div&gt;
</code></pre>

<p>What I want is that when I hover over one of the "dimensions" (the latter 4 divs) one of the quarter circles (the first 4 divs) will be highlighted. I have the following enum in JS:</p>

<pre><code>var DIMENSIONS = {
    DIM_AUTHORS: {value: 1, dimCode: "author_dimension", areaCode: "quarter_circle_top_left"},
    DIM_SIMILAR: {value: 2, dimCode: "similar_dimension", areaCode: "quarter_circle_top_right"},
    DIM_CITATIONS: {value: 3, dimCode: "citation_dimension", areaCode: "quarter_circle_bottom_right"},
    DIM_CONCEPTS: {value: 4, dimCode: "concept_dimension", areaCode: "quarter_circle_bottom_left"}
};
</code></pre>

<p>And this for..in cycle which should do the highlighting:</p>

<pre><code>for (var key in DIMENSIONS) {
    $("#" + DIMENSIONS[key]['dimCode']).hover(
        function() {
            $("#" + DIMENSIONS[key]['areaCode']).addClass("hover");
        }, 
        function() {
            $("#" + DIMENSIONS[key]['areaCode']).removeClass("hover");
        }
    );
}
</code></pre>

<p>This sort of works but what happens is that the "dimensions" don't highlight the respective quarter circle but instead hovering over any of them highlights only the last (bottom left) quarter circle. So when I hover over authors "dimension" I expect the top left quarter circle to be highlighted but instead only the last one (bottom left) is highlighted.</p>

<p>I tried to print the values of <code>DIMENSIONS[key]['dimCode']</code> and <code>DIMENSIONS[key]['areaCode']</code> and they are correct. Any ideas why my code doesn't work as expected?</p>
