Activating a specific toggle state?

Activating a specific toggle state?

To make this easier to explain, I'll use a simpler example.

Suppose I have a big square that changes color from red to blue and vice-versa when clicked.
Now suppose I have several of these squares aligned vertically on the page - each one is able to have it's color toggled independently of the others.

Now, what I'm trying to do is have a third option - let's say it's a simple key-press that toggles ALL boxes to be red (or blue, for argument's sake).  Basically what I would need to do is somehow be able to access the toggle variable and set it manually.  This way, all squares that need to be toggled - will toggle...and all squares that are already in the correct toggle-state - will stay that way.

Anyone have any ideas how this might be done?

Hopefully this example makes sense.  I'll try to clarify any points if needed.