You're trying to call a function before you've defined it. Move the definition before the call, and it will work.
[EDIT] After answering the question, I noticed a duplicate, and merged the threads. It's a little messy but I prefer not deleting anything.
[EDIT] After answering the question, I noticed a duplicate, and merged the threads. It's a little messy but I prefer not deleting anything.