Multilayered optical memory with bits stored as refractive index change. I. Electromagnetic theory.