(a) The judge, juvenile referee or magistrate shall inform the juvenile of his or her right to remain silent, that any statement may be used against him or her and of his or her right to counsel, and no interrogation may be made without the presence of a parent or counsel. If the juvenile or his or her parent, guardian or custodian has not retained counsel, counsel shall be appointed as soon as practicable. The referee, judge or magistrate shall hear testimony concerning the circumstances for taking the juvenile into custody and the possible need for detention in accordance with section two, article five-a of this chapter. The sole mandatory issue at the detention hearing is whether the juvenile should be detained pending further court proceedings. The court shall, if the health, safety and welfare of the juvenile will not be endangered thereby, release the juvenile on recognizance to his or her parents, custodians or an appropriate agency; however, if warranted, the court may require bail, except that bail may be denied in any case where bail could be denied if the accused were an adult. The court shall:
(1) Immediately notify the juvenile's parent, guardian or custodian or, if the parent, guardian or custodian cannot be located, a close relative;
(2) Release the juvenile into the custody of his or her parent, guardian or custodian unless:
(A) Circumstances present an immediate threat of serious bodily harm to the juvenile if released;
(B) No responsible adult can be found into whose custody the juvenile can be delivered: Provided, That each day the juvenile is detained, a written record must be made of all attempts to locate such a responsible adult; or
(C) The juvenile is charged with an act of delinquency for which secure detention is permissible; and
(3) If the juvenile is an alleged status offender, immediately notify the Department of Health and Human Resources, and, if the circumstances of either paragraph (A) or (B), subdivision (2) of this subsection exist and the requirements therein are met, the court may order the juvenile detained, but only in a nonsecure or staff-secure facility. Any juvenile detained pursuant to this subdivision shall be placed in the legal custody of the Department of Health and Human Resources pending further proceedings by the court.
(b) The judge of the circuit court or the juvenile referee may, in conjunction with the detention hearing, conduct a preliminary hearing pursuant to section nine of this article: Provided, That all parties are prepared to proceed and the juvenile has counsel during such hearing.