Yes it is possible. The engines are generally known as LS motors. You have a B18a1 in your car and the motor would most likely be a B18b1, it could also be a B18a1. Long story short- it's the same motor.
However, $500 off eBay isn't really a good deal. There are probably a dozen companies locally that will sell you a motor. I found lots of 50k or lower motors with a warranty for under $800. And like it was already said.. if you don't know how to do it, you might want to research a bit more or let someone else take over for you.