If it was working a little bit after you installed the HD then you have a chance here in saving it.
Often the optical lens in the unit gets dirty so it can't see the disk and it then assumes the disk is bad which is why it ejects it. See if you can get a CD/DVD head cleaning disk which has a very small brush on its surface that can clean the lens. Also a small blast of can'ed air might also clean the rails if they are dirty. Just be careful not to spray the liquid out.
If that fails its time for a new optical drive. These aren't too expensive used, take a look on eBay, just make sure its for your model. Follow the IFIXIT guide on how to do it.
If you still want to get your OS installed without fixing the optical drive, I'm sure you have a friend with a Mac or can make your way to an Apple Store. Just make an appointment with the Genus Bar and have proof you have a copy of the OS (Apple logo'ed CD/DVD). In any case they can even get you up to Mavericks (the latest OS as its free).
If you use your friends Mac take your OS CD/DVD with you and a 16GB USB thumb drive. Prep the drive to be bootable using your friends system. Then copy over the installer files to the drive. You should then be able to boot up your MacBook Pro using the thumb drive and install the OS.
An alternative way is using a network cable or FireWire cable to interconnect the two Macs setting yours up in Target mode. It will then look like an external HD to your friends Mac and you can then install the OS that way.
You could be having a few problems here:
As is the internal optical drive is still working you have a confused system as it's expecting the disk to be in that drive. The best thing here is to disconnect the internal drive so the system is not confused.
But you have another problem here as well!
The Mac OS-X you are trying to install is too old for your system. This version does not come with the needed drivers your system is expecting. You need to get Snow Leopard (10.6.3 or newer)