Cache $document jQuery object.
Check more strictly against boolean type for `animated` argument.