how to select a rectangle with mouse

Hi,
I have 2 blue rectangles drawn with gl_line_loop.
if I click one of them with mouse I want it to be red. So an object selection problem.
I use ortho projection.

if you could give some sample code it would be very helpful.
Since I m extremely newbie, if you mention where should I put the code(mousedown,render?) it will would be nice for me.
Thanks for help.regards

Hi !

Here is one example that use GLUT: http://www.sdsc.edu/~mjb/cse167/Handouts/Picking/picking.pdf

There are lots of others, give google a quick search and you will get lots of examples.

Mikael