wow.. considering that Sanity only reports on the first non-declaration of a variable, 51 vars in 250 lines is a new var every 5 lines (including blank lines!). The first error is a pretty significant issue. By passing a global in a function, that's auto-defined as a local in the function. Since it's global, just remove it from the function declaration entirely. If you need a copy, you need to give it a unique name in the function.

This is one reason I use a standard varname convention - $GLOBALVAR, $LocalVar, and $_FunctionVar.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D