When it comes to child custody in Virginia, it is not a matter of whatever the Judge wants or feels like doing under the circumstances. It is a matter of the Court following the laws established by the Code of Virginia. Here are some links to those laws so that you can have a foundation for any questions.
This is the definitions section. It is what defines certain terms that the Court must follow.
This is the Code section that gives a listing of the options of the Court.
Finally, these are the factors that the Court must consider in making a custody determination.