Nondestructive optical measurement of relative phase between two Bose-Einstein condensates