I design a mains voltage (220V, 50Hz) detector to provide, via an optoisolator as 4N35, the real time status of the mains voltage to the MCU interrupt pin (as of ATmega8A that I got lately).
It should provide:
 The AC voltage polarity.
 Less than 0.5ms delay to signal the OFF state that may occur at any phase of the mains cycle.
 signal a low voltage limit (as being an off state, below it) with a suitable hysteresis (for restart).
Naturally, it could also be used as a zero-crossing detector (at times when polarity is reversed).
My first topology worked on the LTspice simulator but I prefer testing it on a breadboard first before uploading its circuit file, so that I can be sure it works as expected.
Meanwhile, some of you who have already worked on such a detector may like sharing their experience on it.