My understanding is that cramps are related to hydration, electrolyte ballance and salts. Sweating during exercise can lead to an imballance and also dehydration, so its important to keep hydrated and relplace the critical neutreints.
Stretching and staying warm are also important to reducing cramps.
The tonic water trick mentiond by someone earlier is known to work as is taking vitamin B supplements, although its not really understood why.
An old airforce trick we used to use was a teaspoon of table salt in a glass of water. Tastes awful but works fantastically for curing cramps. Basically replacing the salts lost during sweating.
... not suggesting that you take a swig of sea water though.
Some really good stuff on Wikipedia which may help to formulate your own diagnosis/cure
en.wikipedia.org/wiki/Cramp