* Ceasefire to be implemented in 24 hours
* Legal process for Juba detainees to continue
* Pact calls for withdrawal of "allied forces"
By Aaron Maasho
ADDIS ABABA, Jan 23 (Reuters) - South Sudan's government and rebels signed a ceasefire on Thursday to end more than five weeks of fighting that divided Africa's newest nation and brought it to the brink of civil war.