First-Principles Study Of Layered Transition-Metal Oxides And Sulfides For Battery Applications