for (var i = 0; i < barValues.length; i++) {
actualBarHeight = Math.floor((barValues[i] / chartMaxY) * barchartHeight);
var barChartID = \"#barChart\"
Since you are using jQuery you can use the $.each function instead of a for loop. The callback used instead of the loop will create a new closure.
$.each(barValues, function(i, barValue){
actualBarHeight = Math.floor((barValue/chartMaxY)*barchartHeight);
var barChartID = "#barChart" + (i+1)
$(barChartID + " .value span").css('background-color','transparent');
$(barChartID + " img").animate({
height: actualBarHeight
}, 500, function(){$(barChartID + " .value span").css('background-color','white');}
);
$(barChartID + " .value span").html("$"+Math.floor(barValue));
$(barChartID + " .value").css("bottom",actualBarHeight+"px");
$(barChartID + " .ylabel").html(chartMaxY);
});