OK, a quick google search rang a few bells. What you are looking for is CustomContext module for FreePBX. Here is a youtube video that talks about what I stumbled through in my last post.
But the idea is you will have two outbound routes one with a 9. dial plan and one that accepts the 7 digit or 10 digit format. You will restrict access to the 10 digit route so only your fax extensions will use them.