Phase Transition Model of Earthquakes