Josephson current in superconductor-ferromagnet structures with a nonhomogeneous magnetization