small problem

Here’s the problem:

Write a program using glut to

1.Set background color to white.
2.if the left half of window is clicked it should be colored red.
3.If right half is clicked it should be colored blue.
4.If any of either half is clicked even number of times the corresponding half is colored white.
5.If any of the either half is clicked odd number of times it should be colored red(left half) or blue(right half).

for example:
step1:click left.
step2:click right.
SCREEN after above two steps:left half is RED and right half is BLUE.
step3:click left.
SCREEN after above three steps:left half is white and right half is blue.

My problem is I am only able to color any one half at a time. i.e after first two step my screen is white on the left side and blue on the right side.

please help.