Are you are getting a message "This software cannot be installed on this computer?" - And is your 10.5 DVD grey (part of a 2-DVD set from another Mac?)
If that's the case, then erasing the hard drive will not help, because you have a restore DVD designed to install on only one Mac model.