Arrangements for children

If both parties decide to divorce, how should they decide on children custody arrangements?

What if the parties cannot reach an agreement on custody and access arrangements for the children?