Richness of dynamics and global bifurcations in systems with a homoclinic figure-eight