  Bifurcations of solitary waves propagating along the interface between two
ideal fluids are considered. The study is based on a Hamiltonian approach. It
concentrates on values of the density ratio close to a critical one, where the
supercritical bifurcation changes to the subcritical one. As the solitary wave
velocity approaches the minimum phase velocity of linear interfacial waves (the
bifurcation point), the solitary wave solutions transform into envelope
solitons. In order to describe their behavior and bifurcations, a generalized
nonlinear Schr\"{o}dinger equation describing the behavior of solitons and
their bifurcations is derived. In comparison with the classical NLS equation
this equation takes into account three additional nonlinear terms: the
so-called Lifshitz term responsible for pulse steepening, a nonlocal term
analogous to that first found by Dysthe for gravity waves and the six-wave
interaction term. We study both analytically and numerically two solitary wave
families of this equation for values of the density ratio $\rho$ that are both
above and below the critical density ratio $\rho_{cr}$. For $\rho>\rho_{cr}$,
the soliton solution can be found explicitly at the bifurcation point. The
maximum amplitude of such a soliton is proportional to $\sqrt{\rho-\rho_{cr}}$,
and at large distances the soliton amplitude decays algebraically. A stability
analysis shows that solitons below the critical ratio are stable in the
Lyapunov sense in the wide range of soliton parameters. Above the critical
density ratio solitons are shown to be unstable with respect to finite
perturbations.
