Interlayer distance and magnetic properties of Hg-based superconductors