In determining custody, the court shall give primary consideration to the best interests of the child. The court shall consider and may award joint legal, joint physical, or sole custody, and there shall be no presumption in favor of any form of custody. The court shall assure minor children of frequent and continuing contact with both parents, when appropriate, and encourage parents to share in the responsibilities of rearing their children. As between the parents, there shall be no presumption or inference of law in favor of either. The court shall give due regard to the primacy of the parent-child relationship but may upon a showing by clear and convincing evidence that the best interest of the child would be served thereby award custody or visitation to any other person with a legitimate interest.