Simple menu problem

I’ve been playing around with Dojo and have created the following to change that state of a “li” parent of an “a” tag upon mouseover

for($x = 0; $x < dojo.doc.getElementById("main-menu").getElementsByTagName('a').length; $x++ ) {
			var linkA = dojo.doc.getElementById("main-menu").getElementsByTagName('a')[$x];
			dojo.connect(linkA, "onmouseover", function(evt){
							var linkB = linkA.parentNode;
					, "opacity", 0.5);

It almost works in the right hand side menu:

But it changes the state of the last li rather than the one corresponding to the link… any ideas how I can make this right?