OpenGL color map mode

I have a problem. I want to draw three squares on a window. I draw the first one, then second one and then third one with the region masked. Due to masking of the region for the third sqaure, parts of other two squares are occluded. I want to make the second square visible while making the first square occluded. Basically I need a masking zone for third square, but I should be able to see the second square not the first one. I don’t want to use glut or any other tools, only want to use openGL. How can I do it, please help, any help will be appreciated. Attaching the code portion which draws the squares to any window.

void draw(void)
{

/* clear all pixels  */
glClear (GL_COLOR_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluOrtho2D(-250.0,250.0, -250.0, 250.0);
gluOrtho2D(250.0,-250.0, 250.0, -250.0);

glColor3f (1.0, 1.0, 1.0);

/* 1 Draw the first square */
glColor3f(0.0,0,0); 

/* for a halo one pixel masking zone around the lines */    glLineWidth(6); 
glBegin(GL_LINE_LOOP);
glVertex2f(-100,100);
glVertex2f(-100,-100);
glVertex2f(100,-100);
glVertex2f(100,-100);
glVertex2f(100,100);
glEnd();
glColor3f (1.0, 1.0, 1.0);
glLineWidth(3); 
glBegin(GL_LINE_LOOP);
glVertex2f(-100,100);
glVertex2f(-100,-100);
glVertex2f(100,-100);
glVertex2f(100,-100);
glVertex2f(100,100);
glEnd();



/* 2 draw the second square*/
glColor3f (0.0, 0.0, 0.0); 
glLineWidth(6);
glBegin(GL_LINE_LOOP);
glVertex2f(-175,50);
glVertex2f(-175,-150);
glVertex2f(50,-150);
glVertex2f(50,50);
glEnd();

glColor3f (1.0, 0.0, .50); 
glLineWidth(2);
glBegin(GL_LINE_LOOP); 
glVertex2f(-175,50);
glVertex2f(-175,-150);
glVertex2f(50,-150);
glVertex2f(50,50);
glEnd();

/* 3 Draw the third square*/
glPushMatrix();
/* mask the entire region with black color
 * but makes the other two squares invisible
 * Need to have this masking but I need the second
 * square to be transparent, but not the first one
 */  
glColor3f(0.0,0,0); 
glPopMatrix();
glPushMatrix();
glLineWidth(6);
glBegin(GL_POLYGON);
glVertex2f(-150,75);
glVertex2f(-150,-125);
glVertex2f(75,-125);
glVertex2f(75,75);
glEnd();


glColor3f(1.0,1.0,0); 
glLineWidth(1); 
glBegin(GL_LINE_LOOP);
glVertex2f(-150,75);
glVertex2f(-150,-125);
glVertex2f(75,-125);
glVertex2f(75,75);
glEnd();
glPopMatrix();

}