I used to get very bad cramps before I started on a nutritional program. Caffeine and alcohol would make them worse, but I think they were caused by excess sweating brought about by being anaemic and overexerting myself.
What helped most was this stuff
http://new.eletewater.com (I'm not trying to sell it!). Magnesium also helps some people - the Citrate format is supposed to be better tolerated and more effective. I use magnesium oil which you rub onto your skin and is particularly good if you suffer from restless legs.
Go for a test if you can, as deficiencies/imbalances of all the electrolytes (calcium, magnesium, potassium, sodium) can cause cramps.