Costa Rica's giant stone balls

Costa Rica's giant stone spheres were first discovered in the 1930s by workers clearing the jungle for banana plantations. Local legend had it that gold was supposed to be hidden inside the mysterious stone spheres. Many of the petrospheres had been split open, some of them blown up. But they were empty. So where did these giant stone spheres come from and, just as importantly, what was their purpose?