Function Not Defined Error In Javascript Example Code