The CD is found on Amazon and eBay at various sources. Make sure it looks like:
Does not say Update, Dropin, or OEM or a Mac model # on it.
Keep in mind:
iMac 5,1 model is an Intel model. You can upgrade iMac 5,1 to 10.7.5 following this process by this process..
10.6.8 is the last version of Mac OS X that supports Rosetta, the ability to run older PowerPC applications on the same system like AppleWorks. 10.7.5 does offer better compatibility with web browsers. Depending on what software dependencies you have, you may want to upgrade to 10.6.8 or 10.7.5. 10.5 is not that different from 10.6 except that 10.6 removes a lot of unnecessary 10.5 PowerPC code that never shows up in Rosetta.