..The opto-isolator sort of looks like a relay. Would a plain old relay work there as well? I am guessing the opto-isolator is just a lot cheaper and much smaller than a relay? Never the less I am going to get some of the ones you suggest as I don't have any and have never fiddled with them.
Right. When the opto-isolator is triggered, the transistors on the output side effectively "shorts" the capacitor like a relay would. The key is the voltage across that cap is always of the same polarity (more positive on the "top" side) so a transistor works since transistors are, in-effect, DC devices. Also, the currents involved are quite small, measured in milli-Amps, so the "puny" transistor in an opto-isolator is adequate; you do not need the Amp level switching capacity of a relay.
And, yes, if you like to fiddle with electronic parts or just want to learn more about what goes on under-the-hood you definitely need to add opto-isolators to your bag of tricks. That is, since O-gauge uses AC for track and accessory power while all the new-fangled electronics uses DC, you will frequently need to bridge that gap which, in one way of thinking, essentially means using (opto) isolators to allow the two systems to inter-operate.