if you have a spare pc floating around, you can build yourself an asterisk box. Doesn't need to be very high spec (runs on linux, and you aren't exactly going for enterprise telephony by the sounds of things). Asterisk acts like a PBX system and has plenty of features. It's free of course but that means you'll need to read up a bit on setting it up. The forums are generally pretty helpful.
Asterisk :: The Open Source PBX & Telephony Platform |
LAN to LAN etc etc, yep, you can do all that. You can run everything off the asterisk box, or have multiple boxes on each site if the connections aren't up 24/7.
As far as compatible phones, check the asterisk site - there should be a compatibility list floating around somewhere there. I know it supports most of the cisco stuff/polycoms and all that at the very least.
I haven't looked into whether voip providers like skype offer gateway services to ip pbx systems, but if they don't, then there are a certainly other providers around that do. There are ISPs around that allow trunk connections etc, but I've only ever used them for access from an IP system to the PSTN.
Hopefully that helps. Asterisk should do everything you need, but unfortunately I don't know of many free systems that are easy to set up properly without much knowledge.... even the ones that aren't free generally require a bit of experience to set them up quickly, and correctly