A Mean Field Theory of CuO_2 Layers in Superconducting Compounds