Alternate Call Routing for QoS

I am new to Asterisk and hope to start testing 1st Q 2008. Is it possible to setup alternate call routing for inter-office calls? If we setup voip for inter-office calls across our WAN, can we limit the number of channels used for voip and make a rule that the system will use provider analog lines?

For example, if we can only tolerate 5 voip calls, can Asterisk follow a rule automatically so that the 6th inter-office call goes out an analog line from a phone carrier?

Thanks

Sure. You can put in your dial plan that every time a call is created it should add a number to a value in the asterisk data base. When a call hangs up it should it remove a 1. When you make a call you check his variable.

How about re-routing of failed calls. E.g. congesting calls due to slow response on IAX trunks?