Changing the battery will not lose the code and will not void warranty.
The battery is considered a 'user servicable' part and is replacable, as mentioned for bew bux from any electronics store.
The coding of the key itself is hard coded, and does not change. The way it integrates with the car is that the car has a reciever, when programmed, it is set to recieve a signal from a transponder (the key).
You can effectively code numberous keys to one car.
Think of it like fingerprints, and your key being your actual finger and your fingerprint being the code. The fingerprint reader (car's reciever) is programmed to read a fingerprint (code). If you cut your fingernails (change the battery) then the code (fingerprint) is still the same.
It works on the same principle as your garage door remote. The actual opener on the roof of your garage is the bit that gets programmed, the buttons are universal. You tell the opened you weant to program a new remote and press the button and the opener recognises the code from the remote. This is why you reset the opener's codes when you lose one of your button things....
If your battery is dead, change it yourself. You will need a small phillips head (like the ones you get in a set
LIKE THIS) and a
BATTERY1 - Undo the screw on the back of the key transponder
2 - Remove transponder componant from key enclosure
3 - Remove the old battery
4 - Insert the new battery
5 - Re-assemble transponder unit and insert back in key enclosure
6 - Re-screw key enclosure back together
7 - Use it...