How do I replace this switch with a timer?
I've annotated your image...



It's not possible from the image to tell which of the wires marked with red is the feeder from the breaker, and which is the feeder to other devices on the circuit. However, since you're simply replacing a switch with a timer, you'll not have to touch these wires anyway. The neutrals can also be ignored, unless you're installing a "smart" switch that requires a neutral wire.

Without knowing the exact make and model of the timer being installed, it's not possible to provide exact installation instructions. Instead I'll provide basic "typical" installation steps.


Start by turning off the power to this circuit at the breaker/fuse box, and verifying the power is off using a non-contact voltage tester.
Remove the two black wires from the switch you'll be replacing (One marked orange, and one marked blue in the image above). 
Throw the now disconnected switch haphazardly over your left shoulder.
Connect a bare or green wire from the grounding screw in the box to the green screw or wire labeled Ground on the device. 
Connect the black wire coming from the twist-on wire connector (labeled orange in the image above) to the black screw or wire labeled Common on the device.
Connect the other black wire to the brass screw or wire labeled Load on the device.
(Optionally) If a neutral is required, follow steps 7a - 7c
a. Remove the twist-on wire connectors connecting the neutral wires.
b. Include a short bit of white wire in the bundle, and reinstall the twist-on wire connector (make sure the connector is rated for the proper number of conductors, a new twist-on wire connector may be required).
c. Connect the other end of the short bit of white wire to the silver screw or wire labeled Neutral on the device.
Restore power at the breaker/fuse box.
Turn the fan on/off a few times and marvel at how awesome you are. YOU have harnessed ELECTRICITY!!!




Here's some wiring diagrams from various timers on the market...