Whilst this ins't difficult to-do, it's not user level programming.

There are 5 or 6 different sections depending on if you want the calls to go via normal lines if the gsm is in use or not.

Plus another 4 sections to check after you make the changes.