I have no actual experience of implementing a VOIP PBX which is basically what you are looking to do..
However if you want to roll your own.. then get Asterisk
http://www.asterisk.org they also have a demo server you can play with..
And purchase a PSTN card, you can get a 4 port card for about £40 and Asterisk is free.. you can later integrate to external VOIP providers..
Alternatively BT are pushing their VOIP solutions, for which you could use your existing numbers..
Obviously if you didn't want IP phones, you could just get a regular PBX, plenty on ebay as everyone upgrades to IP and use the Cat 5 adaptors to connect handsets, over cat5 not via the switch.