Cavity QED with cold atoms trapped in a double-well potential