"function-definition is not allowed" error

When posting code, please do not just paste it into the forum. Use the CODE button above the text box when entering text and paste it in between the commands that appear. Thanks.