The crystallization of hydroxyapatite and fluorapatite in the presence of magnesium ions