Javascript Uncaught Reference Error Variable Used Without Being Declared