Xj 40 radio problems

When I turn the ignition on the radio comes on. If I try to start the car the radio goes completely dead. When I turn the ignition on again the radio requests the code so I know it has lost all power. Sometimes the relay controlling the radio and ac is slow but it always connects.