I apologise for the lack of information.
vars fColor and sColor are global (i do hope variables defined outside of functions are considered global in Javascript). I need to use them in other function, so I moved the declaration. I've tried declaring them direclty in the function like you sugessted, but it did not help.
xDim is also global variable, sorry that I failed to include it in the sample code.
Didn't know about the alert function =) was wondering how to output variables, to test them, I'll try at work tomorrow, however, i'm quite sure that all the variable that I use have correct values.
The function makeQI is called from main function, which in turn called from actionscript. I can provide more code, if needed, but the makeQI functions fails to work on its own, not depending on other code.