I would check for a vacuum leak first. You can do this with a propane plumber's torch (not lit). With the torch valve on and gas going out of it, wave it around the vacuum lines etc. If the idle straightens out when the gas hits a certain area, inspect that area closely.
Another part that will do this is the throttle position sensor. This will confuse the computer if it's malfunctioning. A good parts store will be able to test this part.