Density-functional study of the structure and stability of ZnO surfaces