Quantum Dynamics of Intramolecular Hydrogen Bonds in Gas and Condensed Phase