The influence of a time-varying ram pressure on spiral galaxies in clusters is explored with a new simulation method based on the N-body SPH/tree code GADGET. We have adapted the code to describe the interaction of two different gas phases, the diffuse hot intracluster medium (ICM) and the denser and colder interstellar medium (ISM). Both the ICM and ISM components are introduced as SPH particles. As a galaxy arrives on a highly radial orbit from outskirts to cluster center, it crosses the ICM density peak and experiences a time-varying wind. Depending on the duration and intensity of the ISM-ICM interaction, early and late type galaxies in galaxy clusters with either a large or small ICM distribution are found to show different stripping efficiencies, amounts of reaccretion of the extra-planar ISM, and final masses. We compare the numerical results with analytical approximations of different complexity and indicate the limits of the Gunn & Gott simple stripping formula. Our investigations emphasize the role of the galactic orbital history to the stripping amount. We discuss the contribution of ram pressure stripping to the origin of the ICM and its metallicity. We propose gas accumulations like tails, filaments, or ripples to be responsible for stripping in regions with low overall ICM occurrence.