If you use var to declare a variable in a function, then it's a local variable. If you don't use var, then the variable is global.
Any variable declared locally in a function is a local variable, and you won't be able to access the global variable when there's a local one with the same name. Learned this by experience when I forgot to use var one time in a function, and what was supposed to be a local variable affected a global one. Using var fixed the problem with no other changes.
Lee