511. (5) Where the prosecutor shows cause why the detention of the accused in custody is justified, the justice shall order that the accused be detained in custody until he is dealt with according to law and shall include in the record a statement of his reasons for making the order.
(6) Unless the accused, having been given a reasonable opportunity to do so, shows cause why the accused’s detention in custody is not justified, the justice shall order, despite any provision of this section, that the accused be detained in custody until the accused is dealt with according to law, if the accused is charged
(a) with an indictable offence, other than an offence listed in section 469,
(i) that is alleged to have been committed while at large after being released in respect of another indictable offence pursuant to the provisions of this Part or section 679 or 680,
(ii) that is an offence under section 467.11, 467.12 or 467.13, or a serious offence alleged to have been committed for the benefit of, at the direction of, or in association with, a criminal organization,
(iii) that is an offence under any of sections 83.02 to 83.04 and 83.18 to 83.23 or otherwise is alleged to be a terrorism offence,
(iv) an offence under subsection 16(1) or (2), 17(1), 19(1), 20(1) or 22(1) of the Security of Information Act,
(v) an offence under subsection 21(1) or 22(1) or section 23 of the Security of Information Act that is committed in relation to on offence referred to in subparagraph (iv),
(vi) that is an offence under section 99, 100 or 103,
(vii) that is an offence under section 244 or 244.2, or an offence under section 239, 272 or 273, subsection 279(1) or section 279.1, 344 or 346 that is alleged to have been committed with a firearm, or
(viii) that is alleged to involve, or whose subject-matter is alleged to be, a firearm, a cross-bow, a prohibited weapon, a restricted weapon, a prohibited device, any ammunition or prohibited ammunition or an explosive substance, and that is alleged to have been committed while the accused was under a prohibition order within the meaning of subsection 84(1);
(b)with an indictable offence, other than an offence listed in section 469 and is not ordinarily resident in Canada,
(c) with an offence under any of subsections 145(2) to (5) that is alleged to have been committed while he was at large after being released in respect of another offence pursuant to the provisions of this Part or section 679, 680 or 816, or
(d) with having committed an offence punishable by imprisonment for life under any of sections 5 to 7 of the Controlled Drugs and Substances Act or the offence of conspiring to commit such an offence.
(c) A person being transported shall be detained in custody during the period of transit;