(g) If a petition is filed under subsection (c) of this section and it appears that the interests of the child or the family may be best served, prior to adjudication, by a referral to community-based or other services, the judge may permit the matter to be continued for a reasonable period of time not to exceed six months, which time period may be extended by an additional three months for cause.