Non-markovian theory of molecular relaxation. I. Vibrational relaxation and dephasing in condensed phases