AC detection for switching to battery source
I am designing a DC-powered ceiling fan.
  I want to make a circuit which senses that AC power is gone
  and automatically switches fan supply to the battery sources.


I assume that the fan has a 120 VAC to ~= 12VDC supply to operate it from mains.  

If so, easiest of all is to make the mains based supply produce a voltage that is slightly higher than the battery voltage, and feed both supplies to the fan via diodes
(Schottky diodes perhaps, but silicon diodes probably OK.)
Whichever supply has the highest voltage will operate the fan and the diode to the lower voltage supply will be reverse biased so the lower voltage (battery) supply will supply no power. 

When the mains supply ceases the battery will automatically operate the fan. 

See diagram d in second row here. or in commented form below. 

If "V+ ex line" is greater than "V+ bat" then the top diode will conduct and the bottom diode will be reverse biased. The fan will operate from the top supply and the battery will provide no current.

If the mains power is removed the battery will operate the fan via the bottom diode. TYhe series diodes will cause a small power loss compared to operation directly from battery or mains supply.