When a minor is delivered to the court, or to the place designated by the court under Section 4-6 of this Act, a probation officer or such other public officer designated by the court shall immediately investigate the circumstances of the minor and the facts surrounding the minor being taken into custody. The minor shall be immediately released to the custody of the minor's parent, guardian, legal custodian or responsible relative, unless the probation officer or such other public officer designated by the court finds that further temporary custody is necessary, as provided in Section 4-6.
705 ILCS 405/4-7