  Phase transitions of a flux lattice in layered superconductors with magnetic
field perpendicular to the layers and in presence of disorder are studied. We
find that disorder generates a random Josephson coupling between layers which
leads to a Josephson glass (JG) phase at low temperatures; vanishing of the JG
order identifies a depinning transition. We also find that disorder and thermal
fluctuations lead to layer decoupling where the renormalized Josephson coupling
vanishes. Near decoupling an anharmonic regime is found, where usual elasticity
and the resulting Bragg glass are not valid. The depinning line crosses the
decoupling line at a multicritical point, resulting in three transition lines
and a crossover line. The phase diagram is consistent with the unusual data on
Bi2Sr2CaCu2O8 such as the "second peak" and depinning transitions. The
Josephson plasma frequency is evaluated in the various phases.
