What causes leg cramps (aka Charlie Horse)?

I had the "luck" of getting not 1 but 2 leg cramps last night while I was sleeping. What causes them? Is there away to prevent/avoid them?

Please, serious replies only. Thanks!
37 answers 37