Chemical reactions and local charge redistribution at metal-CdS and CdSe interfaces