Sub-femtojoule all-optical switching using a photonic-crystal nanocavity