You might want to indent your code blocks, to make it easier to read your code. You are currently missing a } before the else if statement. Also, you have an extra } at the end of your function. This is why properly indenting your code as you write it helps you find these kinds of syntax errors.

EDIT: You seemed to have changed your code to no longer have the missing or extra }.