Electronic structure of the bulk and layers of the alkaline earths (Be-Ba)