Yep Tony is on the ball.
Try this, next time it won't start, get some water and pour it on the bottom pulley (the big one - crank pulley) and make sure it goes all over that sensor that is sitting to the right of that pulley.
If you can't see the sensor, look for wires coming out on the right hand side.
If it starts after you've soaked it, then its definatly the crank angle sensor.
if you replace it, make sure you install it correctly or else it will keep having the same problems.