A 2007 iMac will have a button style battery on its motherboard somewhere. These are not great fun to replace, you need to remove the front case in order to get at it. I think the battery is a CR2032 so they are easy and cheap to buy.
Find your model on ifixit.com and check the guide for replacing the PRAM battery, see if you fancy it.