K-Shell Photoabsorption of Magnesium Ions