Quantum state of two trapped Bose-Einstein condensates with a Josephson coupling