How can I tell when the Unity window is inactive?

When the Unity web player is a background window, Input.GetMouseButtonDown are still received. In other words, mouse clicks are handled even if another window is in front of the web page hosting the web player.

Is there any way to tell if the Unity window is currently selected?

Note that I do not want to disable the window when it is background, and I mean the main Unity window, and not GUI window controls.

You could try this forum posting for a start: Knowing when a web game loses focus

It's not trivial and does involve some JavaScript coding ("the real JavaScript" in the browser, not UnityScript) and it seems this doesn't work in all cases - but it certainly is a good point to start from.