All-optical switch with two periodically modulated nonlinear waveguides