How do you know it's the hard drive that's bad? What year is the iMac? Was it diagnosed somehow?
It could be a damaged I/O controller or a blown stage in a buffer as well. To be honest, it could be a lot of things. The comment:
P.S. The computer turns on but never makes it to the main screen before turning off
is troubling.
I don't know if you've done this but you might want to try one or more of the following:
1. See if it will boot from either an install CD (if you have one) or another external, bootable drive. This is a classic example of why people should have some type of emergency boot media available. If you can get it to boot you at least know that most of the logic board is functioning.
2. If you've confirmed that it's the drive you might want to check out the following article:
http://scsc-online.com/Bad Hard Drive Signs and Symptoms.html
That's got a bunch of sub articles about drive problems in it, and in one of them is a bunch of resets you can do. Possibly, if you're lucky, maybe just some of the system parameters just got messed up. At this point I think task number one would be to just try and get the drive to boot off of
something.
With that said, if it turns out the logic board is bad the drive may actually be in good condition and you can pull it and, like the others said, put it in an external enclosure.
Hope this helps, and good luck.