Spectral lags in different episodes of gamma-ray bursts