Please declare variables at the top of function to prevent hoisting.
http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html