try adding this to the beginning of the function:

Code:
global $var1, $var2, $var3;
Just change $var1, etc. to the name of the variables you want the function to access. As far as I know there aren't limits to how many variables you can declare as global.