Your brackets are out of line for the if statements. Remove them all, and re add them in the correct spots, being careful to not put an else statement with a conditional (should be else if, in that case, or just else (without the (condition)) and add the accompanying bracket on the right, as in line 24
Also, white spaces and indentation really improve readability of code with multiple nested control structures.