G'day and welcome to the forums.
Go to auction sites such as eBay and look for a Leopard OS X.5 full retail install DVD. Make sure it is a black disc and not a silver/grey system disc which will work only with the model computer it came with. Expect to pay in the vicinity of $100, or even more.
Even better purchase Snow Leopard OS X.6 from the Apple store or online, install and update to OS X.6.8, and later this week purchase as a download the new release OS X.7. The model iMac you describe are 2009, 2010 or 2011 models and all are Intel. These will cost you $29 each, and the Snow Leopard disc will be a boot disc.