Child custody is the ruling of a court that determines who should have physical and/or legal control of a minor under eighteen years old. Custody cases take place during a divorce if questions arise regarding one or both parents being unfit, absent, in prison, dead, or a danger to the child's well-being. Custody may be awarded to a foster parent, orphanage, grandparent or other relative, or an organization or institution. Temporary custody is granted to one of the parents when a divorce is pending. The court may require conferences or an investigation during this time and if the parents cannot agree, custody is usually referred to a mediator, commissioner, or social worker prior to a final determination. Physical custody refers to where the child resides, while legal custody provides the custodial person(s) with the right to make legal decisions for the child's behalf. Joint custody, which is increasingly common, can be awarded by the court if both parents agree. Visitation rights are granted to the non-custodial parent. When determining custody matters, the basic consideration is the child's best interest. The court may adapt custody under warranted circumstances.